diff --git a/scripts/install b/scripts/install index b3f8bcc..911c65b 100644 --- a/scripts/install +++ b/scripts/install @@ -101,20 +101,19 @@ exec_cmd php mud.php config --loglevel=1 \ --username="$admin" --password="$password" # Copy init script or systemd service -sudo sed -i "s@YHURL@$domain$path@g" ../conf/movim.{service,init} -sudo sed -i "s@YHDIR@$DESTDIR@g" ../conf/movim.{service,init} -sudo sed -i "s@YHPORT@$port@g" ../conf/movim.{service,init} -initcheck=`pgrep -ox systemd` -if [ "$initcheck" = "1" ]; -then - sudo cp ../conf/movim.service /etc/systemd/system/ - sudo systemctl enable movim.service - sudo systemctl start movim.service +sudo sed -i "s@YHURL@${domain}${path}@g" ../conf/movim.{service,init} +sudo sed -i "s@YHDIR@${DESTDIR}@g" ../conf/movim.{service,init} +sudo sed -i "s@YHPORT@${port}@g" ../conf/movim.{service,init} +if [ -d /run/systemd/system ]; then + sudo cp ../conf/movim.service /etc/systemd/system/ + sudo systemctl --quiet daemon-reload + sudo systemctl --quiet enable movim.service + sudo systemctl --quiet start movim.service else - sudo cp ../conf/movim.init /etc/init.d/movim - sudo chmod 755 /etc/init.d/movim - sudo update-rc.d movim defaults - sudo /etc/init.d/movim start + sudo cp ../conf/movim.init /etc/init.d/movim + sudo chmod 755 /etc/init.d/movim + sudo update-rc.d movim defaults + sudo /etc/init.d/movim start fi # php-fpm configuration @@ -137,6 +136,6 @@ else apply_sso_patch fi -# Start Movim +# Reload services sudo service php5-fpm restart sudo service nginx reload diff --git a/scripts/remove b/scripts/remove index 9a7dd2c..c5db8e1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -8,14 +8,16 @@ source /usr/share/yunohost/helpers # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) -# Stop service and remove init -sudo service php5-fpm stop -sudo /etc/init.d/movim stop -sudo systemctl stop movim.service -sudo systemctl disable movim.service -sudo update-rc.d -f movim remove -sudo rm -f /etc/init.d/movim -sudo rm -f /lib/systemd/system/movim.service +# Stop service and remove it +sudo service movim stop +if [ -d /run/systemd/system ]; then + sudo systemctl --quiet disable movim.service + sudo rm -f /lib/systemd/system/movim.service + sudo systemctl --quiet daemon-reload +else + sudo update-rc.d -f movim remove + sudo rm -f /etc/init.d/movim +fi # Drop MySQL database and user db_user=movim @@ -32,6 +34,6 @@ sudo rm -rf /var/www/movim sudo rm -f /etc/nginx/conf.d/$domain.d/movim.conf sudo rm -f /etc/php5/fpm/pool.d/movim.conf -# Restarting services +# Reload services sudo service nginx reload -sudo service php5-fpm start +sudo service php5-fpm restart diff --git a/scripts/upgrade b/scripts/upgrade index 4d37b25..c1f44f5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -70,21 +70,19 @@ else fi # Update init scripts -sudo sed -i "s@YHURL@$domain$path@g" ../conf/movim.{service,init} -sudo sed -i "s@YHDIR@$DESTDIR@g" ../conf/movim.{service,init} -sudo sed -i "s@YHPORT@$port@g" ../conf/movim.{service,init} -initcheck=`pgrep -ox systemd` -if [ "$initcheck" = "1" ]; -then - sudo rm -f /lib/systemd/system/movim.service - sudo cp ../conf/movim.service /etc/systemd/system/ - sudo systemctl daemon-reload +sudo sed -i "s@YHURL@${domain}${path}@g" ../conf/movim.{service,init} +sudo sed -i "s@YHDIR@${DESTDIR}@g" ../conf/movim.{service,init} +sudo sed -i "s@YHPORT@${port}@g" ../conf/movim.{service,init} +if [ -d /run/systemd/system ]; then + sudo rm -f /lib/systemd/system/movim.service + sudo cp ../conf/movim.service /etc/systemd/system/ + sudo systemctl --quiet daemon-reload else - sudo /etc/init.d/movim stop - sudo cp ../conf/movim.init /etc/init.d/movim - sudo chmod 755 /etc/init.d/movim - sudo update-rc.d movim defaults - sudo /etc/init.d/movim start + sudo /etc/init.d/movim stop + sudo cp ../conf/movim.init /etc/init.d/movim + sudo chmod 755 /etc/init.d/movim + sudo update-rc.d movim defaults + sudo /etc/init.d/movim start fi # Update php-fpm configuration @@ -98,7 +96,7 @@ sed -i "s@YHPORT@$port@g" ../conf/nginx.conf sed -i "s@//ws/@/ws/@g" ../conf/nginx.conf # Avoid duplicate / sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf -# Reload +# Reload services sudo service movim restart sudo service php5-fpm restart sudo service nginx reload