Termux SSHD service
This commit is contained in:
parent
caf49db140
commit
96751acaab
61
termux/services/sshd
Executable file
61
termux/services/sshd
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/data/data/com.termux/files/usr/bin/bash
|
||||
#
|
||||
# Start SSH server daemon
|
||||
#
|
||||
|
||||
PIDFILE="/data/data/com.termux/files/usr/var/run/sshd.pid"
|
||||
LOGFILE="$HOME/.local/log/sshd.log"
|
||||
|
||||
start() {
|
||||
printf "Starting SSHD: "
|
||||
start-stop-daemon -p "$PIDFILE" -x sshd -S -- -E "$LOGFILE"
|
||||
termux-toast "Started SSHD"
|
||||
echo "OK"
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf "Stopping SSHD: "
|
||||
start-stop-daemon -p "$PIDFILE" -x sshd -K
|
||||
termux-toast "Stopped SSHD"
|
||||
echo "OK"
|
||||
}
|
||||
|
||||
status() {
|
||||
printf "SSHD: "
|
||||
PID="$(cat "$PIDFILE" 2> /dev/null)"
|
||||
if [[ -n "$PID" && -d "/proc/$PID" ]]
|
||||
then
|
||||
echo "running"
|
||||
else
|
||||
echo "stopped"
|
||||
fi
|
||||
}
|
||||
|
||||
log() {
|
||||
tail "$@" "$LOGFILE"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
log)
|
||||
shift
|
||||
log "$@"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status|log}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
|
@ -22,7 +22,7 @@ stop() {
|
|||
|
||||
status() {
|
||||
printf "Syncthing: "
|
||||
PID="$(sudo cat "$PIDFILE")"
|
||||
PID="$(sudo cat "$PIDFILE" 2> /dev/null)"
|
||||
if [[ -n "$PID" && -d "/proc/$PID" ]]
|
||||
then
|
||||
echo "running"
|
||||
|
|
Loading…
Reference in a new issue