From dc5b9f52cdc7ebd71fc2a492c51cf7e8af8c0996 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Thu, 31 May 2018 04:03:14 +0530 Subject: [PATCH] Install backports only for jessie,Stop service before upgrade and backup --- scripts/backup | 13 +++++++++++++ scripts/install | 15 ++++++++++----- scripts/remove | 7 ++++++- scripts/restore | 13 +++++++++---- scripts/upgrade | 15 ++++++++++++--- 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/scripts/backup b/scripts/backup index 864f5e6..5a13c3c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -34,6 +34,9 @@ final_path=$(ynh_app_setting_get "$app" final_path) domain=$(ynh_app_setting_get "$app" domain) db_name=$(ynh_app_setting_get "$app" psql_db) +# Stop Peertube for backup +systemctl stop "$app" + #================================================= # STANDARD BACKUP STEPS #================================================= @@ -73,3 +76,13 @@ ynh_backup "/etc/logrotate.d/$app" #================================================= ynh_backup "/etc/systemd/system/$app.service" + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx +systemctl enable "$app" +systemctl start "$app" +# App needs time to start +sleep 15 diff --git a/scripts/install b/scripts/install index 6d49eae..60370d2 100644 --- a/scripts/install +++ b/scripts/install @@ -95,9 +95,12 @@ wget -nv https://github.com/yarnpkg/yarn/releases/download/v1.6.0/yarn_1.6.0_all echo "96866d835da94a1f01a616f3d637c9100e826f65cb38a65e5d96ccf01ff6d692 yarn_1.6.0_all.deb" | sha256sum -c || ynh_die dpkg -i yarn_1.6.0_all.deb -# add backports (required to install ffmpeg) -echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list -ynh_package_update +# add backports for Debian Jessie (required to install ffmpeg) +if [ "$(lsb_release --codename --short)" == "jessie" ]; then + echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list + ynh_package_update +fi + # install postgresql, ffmpeg, redis ynh_install_app_dependencies postgresql ffmpeg redis-server redis-tools mailutils @@ -202,12 +205,16 @@ then ynh_app_setting_set "$app" unprotected_uris "/" fi +# Give permisiion to the final_path +chown -R "$app":"$app" "$final_path" "$datadir" + #================================================= # SETUP SYSTEMD #================================================= # Create a dedicated systemd config ynh_add_systemd_config +systemctl enable "$app" systemctl start "$app" #================================================= @@ -221,8 +228,6 @@ systemctl start "$app" echo $admin_pass | NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production PATH="/opt/node_n/bin:$PATH" npm run reset-password -- -u root ) -# Give permisiion to the final_path -chown -R "$app":"$app" "$final_path" "$datadir" #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index b940a43..4901b78 100644 --- a/scripts/remove +++ b/scripts/remove @@ -43,11 +43,16 @@ fi #================================================= # REMOVE DEPENDENCIES #================================================= - # Remove metapackage and its dependencies ynh_remove_app_dependencies ynh_remove_nodejs +# Remove yarn +sudo apt-get remove --purge -y yarn + +# Delete backport from source.list +ynh_secure_remove /etc/apt/sources.list.d/jessie-backports.list + #================================================= # REMOVE THE MYSQL DATABASE #================================================= diff --git a/scripts/restore b/scripts/restore index 999aebd..8ba1780 100644 --- a/scripts/restore +++ b/scripts/restore @@ -98,9 +98,11 @@ wget -nv https://github.com/yarnpkg/yarn/releases/download/v1.6.0/yarn_1.6.0_all echo "96866d835da94a1f01a616f3d637c9100e826f65cb38a65e5d96ccf01ff6d692 yarn_1.6.0_all.deb" | sha256sum -c || ynh_die dpkg -i yarn_1.6.0_all.deb -# add backports (required to install ffmpeg) -echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list -ynh_package_update +# add backports for Debian Jessie (required to install ffmpeg) +if [ "$(lsb_release --codename --short)" == "jessie" ]; then + echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list + ynh_package_update +fi # Define and install dependencies ynh_install_app_dependencies postgresql ffmpeg redis-server redis-tools mailutils @@ -145,4 +147,7 @@ chown -R "$app":"$app" "$datadir" #================================================= systemctl reload nginx -service "$app" restart +systemctl enable "$app" +systemctl start "$app" +# App needs time to start +sleep 15 diff --git a/scripts/upgrade b/scripts/upgrade index 2e46b73..0fe3db2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -51,6 +51,9 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +# Stop Peertube for upgrade +systemctl stop "$app" + #================================================= # REMOVE APP MAIN DIR #================================================= @@ -89,9 +92,11 @@ wget -nv https://github.com/yarnpkg/yarn/releases/download/v1.6.0/yarn_1.6.0_all echo "96866d835da94a1f01a616f3d637c9100e826f65cb38a65e5d96ccf01ff6d692 yarn_1.6.0_all.deb" | sha256sum -c || ynh_die dpkg -i yarn_1.6.0_all.deb -# add backports (required to install ffmpeg) -echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list -ynh_package_update +# add backports for Debian Jessie (required to install ffmpeg) +if [ "$(lsb_release --codename --short)" == "jessie" ]; then + echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list + ynh_package_update +fi # install postgresql, ffmpeg, redis ynh_install_app_dependencies postgresql ffmpeg redis-server redis-tools mailutils @@ -190,3 +195,7 @@ fi #================================================= systemctl reload nginx +systemctl enable "$app" +systemctl start "$app" +# App needs time to start +sleep 15