Browse Source

systemd: Add missing clean for init sh script

Sebastien Badia 10 years ago
parent
commit
6501f75519
3 changed files with 34 additions and 25 deletions
  1. 22 14
      conf/init_ynh-torclient
  2. 7 6
      scripts/install
  3. 5 5
      scripts/remove

+ 22 - 14
conf/init_ynh-torclient

@@ -1,13 +1,21 @@
 #!/bin/bash
-### BEGIN INIT INFO
-# Provides: ynh-torclient
-# Required-Start:    $network $remote_fs $syslog ynh-hotspot
-# Required-Stop:     $network $remote_fs $syslog ynh-hotspot
-# Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
-# Short-Description: Set prerequisites for wifi torclient.
-# Description:       Set prerequisites for wifi torclient.
-### END INIT INFO
+
+# TOR Client app for YunoHost
+# Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
+# Contribute at https://github.com/jvaubourg/torclient_ynh
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Functions
 ## State functions
@@ -25,7 +33,7 @@ is_nat_set() {
 }
 
 is_tor_running() {
-  service tor status &> /dev/null
+  systemctl is-active tor --quiet &> /dev/null
 }
 
 is_running() {
@@ -50,7 +58,7 @@ unset_nat() {
 }
 
 stop_tor() {
-  service tor stop &> /dev/null
+  systemctl stop tor --quiet &> /dev/null
 }
 
 start_tor() {
@@ -58,7 +66,7 @@ start_tor() {
 
   sed "s|<TPL:TOR_NETWORK>|${ynh_wifi_prefix}|g" -i /etc/tor/torrc
 
-  service tor start
+  systemctl start tor --quiet
 }
 
 ## Tools
@@ -99,7 +107,7 @@ moulinette_hotspot_get() {
   fi
 
   echo "${value}"
-} 
+}
 
 do_start() {
   if is_running; then
@@ -174,7 +182,7 @@ do_status() {
 # Restart php5-fpm at the first start (it needs to be restarted after the slapd start)
 if [ ! -e /tmp/.ynh-torclient-boot ]; then
   touch /tmp/.ynh-torclient-boot
-  service php5-fpm restart
+  systemctl restart php5-fpm --quiet
 fi
 
 # Variables

+ 7 - 6
scripts/install

@@ -1,20 +1,20 @@
 #!/bin/bash
 
-# Tor Client app for YunoHost 
+# Tor Client app for YunoHost
 # Copyright (C) 2015 Emile Morel <emile@bleuchtang.fr>
 # Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
 # Contribute at https://github.com/bleuchtang/torclient_ynh
-# 
+#
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU Affero General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
@@ -29,7 +29,7 @@ if [ ! $? -eq 0 ]; then
 fi
 
 if [ ! -e /tmp/.ynh-hotspot-started ]; then
-  echo "hotspot not started and/or not installed" 
+  echo "hotspot not started and/or not installed"
 fi
 
 echo 'deb http://deb.torproject.org/torproject.org wheezy main' | sudo tee "/etc/apt/sources.list.d/torproject.list"
@@ -75,7 +75,8 @@ sudo sed 's|^;\?\s*max_execution_time.\+|max_execution_time = 600|' -i /etc/php5
 sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i /var/www/torclient/config.php
 
 # Copy init script
-sudo install -o root -g root -m 0755 ../conf/init_ynh-torclient /etc/init.d/ynh-torclient
+sudo install -o root -g root -m 0755 ../conf/ynh-torclient /usr/local/bin/
+sudo install -o root -g root -m 0755 ../conf/ynh-torclient.service /lib/systemd/system/ynh-torclient.service
 
 # Allow Tor ports in firewall
 sudo yunohost firewall allow --no-upnp UDP 9053

+ 5 - 5
scripts/remove

@@ -1,20 +1,20 @@
 #!/bin/bash
 
-# Tor Client app for YunoHost 
+# Tor Client app for YunoHost
 # Copyright (C) 2015 Emile Morel <emile@bleuchtang.fr>
 # Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
 # Contribute at https://github.com/bleuchtang/torclient_ynh
-# 
+#
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU Affero General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
@@ -45,7 +45,7 @@ sudo systemctl reload nginx --quiet
 # Remove sources
 sudo rm -rf /var/www/torclient/
 
-sudo rm -rf /etc/apt/sources.list.d/torproject.list 
+sudo rm -rf /etc/apt/sources.list.d/torproject.list
 sudo apt-get update
 
 exit 0