Browse Source

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

Sebastien Badia 10 years ago
parent
commit
c8dfc31266
3 changed files with 14 additions and 14 deletions
  1. 6 7
      scripts/install
  2. 4 3
      scripts/remove
  3. 4 4
      sources/controller.php

+ 6 - 7
scripts/install

@@ -83,18 +83,17 @@ sudo yunohost firewall allow --no-upnp TCP 9040
 
 # Set default inits
 #php-fpm is already installed by yunohost hotspot app
-sudo service php5-fpm stop
-sudo service php5-fpm start
-sudo service nginx reload
+sudo systemctl restart php5-fpm --quiet
+sudo systemctl reload nginx --quiet
 
 # Update SSO for vpnadmin
 sudo yunohost app ssowatconf
 
 # Set default inits
-sudo service tor stop &> /dev/null
-sudo insserv -r tor
+sudo systemctl stop tor --quiet &> /dev/null
+sudo systemctl disable tor --quiet
 
-sudo insserv ynh-torclient
-sudo service ynh-torclient start
+sudo systemctl reenable ynh-torclient --quiet
+sudo systemctl start  ynh-torclient --quiet
 
 exit 0

+ 4 - 3
scripts/remove

@@ -22,9 +22,10 @@
 domain=$(sudo yunohost app setting torclient domain)
 
 # The End
-sudo service ynh-torclient stop
+sudo systemctl stop ynh-torclient --quiet
+sudo systemctl disable ynh-torclient --quiet
 sudo yunohost service remove ynh-torclient
-sudo rm -f /etc/init.d/ynh-torclient
+sudo rm -f /lib/systemd/system/ynh-torclient.service /usr/local/bin/ynh-torclient
 sudo rm -f /tmp/.ynh-torclient-*
 
 # Update firewall for DHCP
@@ -39,7 +40,7 @@ sudo rm -f /etc/php5/fpm/pool.d/torclient.conf
 # Restart services
 sudo yunohost service stop php5-fpm
 sudo yunohost service start php5-fpm
-sudo service nginx reload
+sudo systemctl reload nginx --quiet
 
 # Remove sources
 sudo rm -rf /var/www/torclient/

+ 4 - 4
sources/controller.php

@@ -13,23 +13,23 @@ function moulinette_set($var, $value) {
 }
 
 function stop_service() {
-  exec('sudo service ynh-torclient stop');
+  exec('sudo systemctl stop ynh-torclient --quiet');
 }
 
 function start_service() {
-  exec('sudo service ynh-torclient start', $output, $retcode);
+  exec('sudo systemctl start ynh-torclient --quiet', $output, $retcode);
 
   return $retcode;
 }
 
 function service_status() {
-  exec('sudo service ynh-torclient status', $output);
+  exec('sudo systemctl is-active ynh-torclient --quiet', $output);
 
   return $output;
 }
 
 function service_faststatus() {
-  exec('sudo service ynh-torclient status', $output, $retcode);
+  exec('sudo systemctl is-active ynh-torclient --quiet', $output, $retcode);
 
   return $retcode;
 }