2020-11-10 18:01:15 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# start an "rclone serve" server
|
|
|
|
|
|
|
|
PIDFILE=/tmp/${NAME}.pid
|
|
|
|
DATADIR=/tmp/${NAME}-data
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
if status ; then
|
2021-01-29 16:07:17 +00:00
|
|
|
pid=$(cat "$PIDFILE")
|
|
|
|
kill "$pid"
|
|
|
|
rm "$PIDFILE"
|
2020-11-10 18:01:15 +00:00
|
|
|
echo "$NAME stopped"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
status() {
|
2021-01-29 16:07:17 +00:00
|
|
|
if [ -e "$PIDFILE" ]; then
|
|
|
|
pid=$(cat "$PIDFILE")
|
|
|
|
if kill -0 "$pid" >/dev/null 2>&1; then
|
2020-11-10 18:01:15 +00:00
|
|
|
# echo "$NAME running"
|
|
|
|
return 0
|
|
|
|
else
|
2021-01-29 16:07:17 +00:00
|
|
|
rm "$PIDFILE"
|
2020-11-10 18:01:15 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# echo "$NAME not running"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
run() {
|
|
|
|
if ! status ; then
|
2021-01-29 16:07:17 +00:00
|
|
|
mkdir -p "$DATADIR"
|
|
|
|
nohup "$@" >> "/tmp/${NAME}.log" 2>&1 </dev/null &
|
2020-11-10 18:01:15 +00:00
|
|
|
pid=$!
|
2021-01-29 16:07:17 +00:00
|
|
|
echo $pid > "$PIDFILE"
|
|
|
|
disown "$pid"
|
2020-11-10 18:01:15 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-01-29 16:07:17 +00:00
|
|
|
# shellcheck disable=SC1090
|
|
|
|
. "$(dirname "$0")/run.bash"
|