Created
June 24, 2014 12:55
-
-
Save sctfic/0509a90f0de72c3c1b77 to your computer and use it in GitHub Desktop.
tunnel-ssh New
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh -e | |
DAEMON="/usr/bin/ssh" #ligne de commande du programme | |
DEAMON_OPT=$2 #argument à utiliser par le programme | |
DAEMONUSER="coaxis" #utilisateur du programme | |
DEAMON_NAME="tunnelSsh" #Nom du programme (doit être identique à l'exécutable) | |
PATH="/sbin:/bin:/usr/sbin:/usr/bin" #Ne pas toucher | |
test -x $DAEMON || exit 0 | |
. /lib/lsb/init-functions | |
d_start () { | |
grep -q "Host $DEAMON_OPT" "/home/$DAEMONUSER/.ssh/config" || d_status | |
log_daemon_msg "Starting system $DEAMON_NAME Daemon" | |
start-stop-daemon --background --name $DEAMON_NAME --start --quiet --chuid $DAEMONUSER --exec $DAEMON -- $DEAMON_OPT | |
log_end_msg $? | |
} | |
d_stop () { | |
log_daemon_msg "Stopping system $DEAMON_NAME Daemon" | |
start-stop-daemon --name $DEAMON_NAME --stop --retry 5 --quiet --name $DEAMON_NAME | |
log_end_msg $? | |
} | |
d_status () { | |
status_of_proc "$DEAMON_NAME" "$DAEMON" "system-wide $DEAMON_NAME" && exit 0 || exit $? | |
} | |
case "$1" in | |
start|stop) | |
d_${1} | |
;; | |
restart|reload|force-reload) | |
d_stop | |
d_start | |
;; | |
force-stop) | |
d_stop | |
killall -q $DEAMON_NAME || true | |
sleep 2 | |
killall -q -9 $DEAMON_NAME || true | |
;; | |
status) | |
d_status | |
;; | |
*) | |
echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|force-stop|restart|reload|force-reload|status}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment