Browse Source

systemd: Convert services (SySv init) to systemctl (systemd) commands

Sebastien Badia 10 years ago
parent
commit
2db43f3623
4 changed files with 13 additions and 13 deletions
  1. 3 3
      conf/init_ynh-piratebox
  2. 4 4
      scripts/install
  3. 3 3
      scripts/remove
  4. 3 3
      sources/controller.php

+ 3 - 3
conf/init_ynh-piratebox

@@ -99,7 +99,7 @@ set_captive() {
 
   cp /etc/nginx/{,conf.d/}captive-piratebox.conf
 
-  service nginx reload
+  systemctl reload nginx --quiet
 }
 
 start_fakedns() {
@@ -128,7 +128,7 @@ unset_filt4_nofwd() {
 unset_captive() {
   rm -f /etc/nginx/conf.d/captive-piratebox.conf
 
-  service nginx reload
+  systemctl reload nginx --quiet
 }
 
 stop_fakedns() {
@@ -168,7 +168,7 @@ if [ "$1" != restart ]; then
   # Restart php5-fpm at the first start (it needs to be restarted after the slapd start)
   if [ ! -e /tmp/.ynh-piratebox-boot ]; then
     touch /tmp/.ynh-piratebox-boot
-    service php5-fpm restart
+    systemctl restart php5-fpm --quiet
   fi
   
   # Variables

+ 4 - 4
scripts/install

@@ -145,12 +145,12 @@ sudo yunohost firewall allow --no-upnp TCP 4280
 sudo yunohost service add php5-fpm
 sudo yunohost service enable php5-fpm
 
-sudo service php5-fpm restart
-sudo service nginx reload
+sudo systemctl restart php5-fpm --quiet
+sudo systemctl reload nginx --quiet
 
 sudo yunohost service add ynh-piratebox
-sudo yunohost service enable ynh-piratebox
-sudo service ynh-piratebox start
+sudo yunohost service reenable ynh-piratebox
+sudo systemctl start ynh-piratebox --quiet
 
 # Update SSO
 sudo yunohost app ssowatconf

+ 3 - 3
scripts/remove

@@ -21,9 +21,9 @@
 domain=$(sudo yunohost app setting piratebox domain)
 
 # The End
-sudo service ynh-piratebox stop
+sudo systemctl stop ynh-piratebox --quiet
 sudo yunohost service remove ynh-piratebox
-sudo rm -f /etc/init.d/ynh-piratebox
+sudo systemctl disable ynh-piratebox --quiet
 sudo rm -f /tmp/.ynh-piratebox-*
 
 # Update firewall
@@ -41,7 +41,7 @@ sudo rm -f /usr/local/bin/piratebox_fakedns
 # Restart services
 sudo yunohost service stop php5-fpm
 sudo yunohost service start php5-fpm
-sudo service nginx reload
+sudo systemctl reload nginx --quiet
 
 # Remove tmp folder
 sudo rm -rf /var/spool/piratebox/

+ 3 - 3
sources/controller.php

@@ -31,17 +31,17 @@ function moulinette_hotspot_get($var) {
 }
 
 function stop_service() {
-  exec('sudo service ynh-piratebox stop');
+  exec('sudo systemctl stop ynh-piratebox --quiet');
 }
 
 function start_service() {
-  exec('sudo service ynh-piratebox start', $output, $retcode);
+  exec('sudo systemctl start ynh-piratebox --quiet', $output, $retcode);
 
   return $retcode;
 }
 
 function service_status() {
-  exec('sudo service ynh-piratebox status', $output);
+  exec('sudo systemctl is-active ynh-piratebox --quiet', $output);
 
   return $output;
 }