1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/peertube_ynh.git synced 2024-09-03 19:56:29 +02:00

Cleanup upgrade script

This commit is contained in:
yalh76 2019-04-03 04:44:26 +02:00
parent b4e2972470
commit c2b127eda7

View file

@ -41,6 +41,13 @@ elif [ "$is_public" = "No" ]; then
is_public=0 is_public=0
fi fi
# Close a port
if yunohost firewall list | grep -q "\- $port$"
then
ynh_print_info "Closing port $port"
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
# Remove repository # Remove repository
ynh_secure_remove /etc/apt/sources.list.d/jessie-backports.list ynh_secure_remove /etc/apt/sources.list.d/jessie-backports.list
ynh_secure_remove /etc/apt/sources.list.d/yarn.list ynh_secure_remove /etc/apt/sources.list.d/yarn.list
@ -89,23 +96,6 @@ datadir="/home/yunohost.app/${app}/storage"
# Create app folders # Create app folders
mkdir -p "$datadir" mkdir -p "$datadir"
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port"
yunohost firewall disallow Both "$port" 2>&1
fi
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path "$path_url")
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -115,6 +105,7 @@ ynh_print_info "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source "$final_path"
cp ../conf/production.yaml "$final_path/config/production.yaml" cp ../conf/production.yaml "$final_path/config/production.yaml"
#Copy the admin saved settings from tmp directory to final path #Copy the admin saved settings from tmp directory to final path
@ -123,11 +114,6 @@ cp -a "$tmpdir/local-production.json" "$final_path/config/local-production.json
# Remove the tmp directory securely # Remove the tmp directory securely
ynh_secure_remove "$tmpdir" ynh_secure_remove "$tmpdir"
(
cd "$final_path"
yarn install --production --pure-lockfile
)
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -136,12 +122,6 @@ ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
chown -R root:root "$final_path"
chown -R "$app" "$datadir"
# Reload Nginx
systemctl reload nginx
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -174,18 +154,15 @@ ynh_system_user_create "$app"
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# MODIFY A CONFIG FILE # BUILD YARN DEPENDENCIES
#================================================= #=================================================
ynh_replace_string "__domain__" "$domain" "$final_path/config/production.yaml" pushd "$final_path"
ynh_replace_string "__db_name__" "$app" "$final_path/config/production.yaml" yarn install --production --pure-lockfile
ynh_replace_string "__app__" "$app" "$final_path/config/production.yaml" popd
ynh_replace_string "__db_pwd__" "$db_pwd" "$final_path/config/production.yaml"
ynh_replace_string "__email__" "$admin_email" "$final_path/config/production.yaml"
ynh_replace_string "__PORT__" "$port" "$final_path/config/production.yaml"
ynh_backup_if_checksum_is_different "$final_path/config/production.yaml"
# Recalculate and store the config file checksum into the app settings # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$final_path/config/production.yaml" ynh_store_file_checksum "$final_path/config/production.yaml"
#================================================= #=================================================
@ -211,19 +188,15 @@ ynh_add_systemd_config
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
# Set right permissions # Set permissions on app files
chown -R "$app":"$app" "$final_path" "$datadir" chown -R "$app":"$app" "$final_path"
chown -R "$app":"$app" "$datadir"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info "Upgrading SSOwat configuration..." ynh_print_info "Upgrading SSOwat configuration..."
if [ "$is_public" -eq 0 ]
then # Remove the public access
ynh_app_setting_delete "$app" skipped_uris
fi
# Make app public if necessary # Make app public if necessary
if [ "$is_public" -eq 1 ] if [ "$is_public" -eq 1 ]
then then