Termux service love
This commit is contained in:
parent
75462e7e5d
commit
caf49db140
7
bashrc
7
bashrc
|
@ -4,10 +4,6 @@
|
|||
|
||||
# ENVIRONMENT VARIABLES
|
||||
|
||||
# Region preferences
|
||||
export LANG=fr_FR.utf8
|
||||
export TZ=/usr/share/zoneinfo/Europe/Paris
|
||||
|
||||
# Favourite commands
|
||||
export PAGER=less
|
||||
export EDITOR=vim
|
||||
|
@ -19,6 +15,9 @@ export PATH="/usr/lib/ccache/bin/:$PATH"
|
|||
if [ -d $HOME/.gem/ruby/2.4.0/bin ]; then
|
||||
export PATH="$HOME/.gem/ruby/2.4.0/bin/:$PATH"
|
||||
fi
|
||||
if [ -d /data/data/com.termux/ ]; then
|
||||
export PATH="$HOME/.termux/scripts:$HOME/.termux/bin:$PATH"
|
||||
fi
|
||||
#export PATH="$(echo "$PATH" | sed 's|:|\n|g' | sort | uniq | tr '\n' ':' | sed 's|:$||')"
|
||||
export JAVA_FONTS=/usr/share/fonts/TTF
|
||||
export ANDROID_HOME=/opt/android-sdk
|
||||
|
|
|
@ -293,7 +293,7 @@ if [ $EXTRA == 1 ]; then
|
|||
inst cmake clang llvm npm
|
||||
|
||||
# Extra CLI
|
||||
inst sl ffmpeg youtube-dl optipng
|
||||
inst sl ffmpeg youtube-dl optipng syncthing
|
||||
|
||||
if [ $ARCH == 1 ]; then
|
||||
inst jq
|
||||
|
|
2
termux/bin/.gitignore
vendored
Normal file
2
termux/bin/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
22
termux/scripts/service
Executable file
22
termux/scripts/service
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/data/data/com.termux/files/usr/bin/bash
|
||||
#
|
||||
# Run & stop Termux services
|
||||
#
|
||||
|
||||
if [ $# -lt 1 ]
|
||||
then
|
||||
echo "Expected a service name as first argument."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
service="$1"
|
||||
file="$HOME/.termux/services/$1"
|
||||
|
||||
if [ -f "$file" ]
|
||||
then
|
||||
shift
|
||||
$file "$@"
|
||||
else
|
||||
echo "Service not found: $1"
|
||||
fi
|
||||
|
6
termux/scripts/sudo
Executable file
6
termux/scripts/sudo
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/data/data/com.termux/files/usr/bin/bash
|
||||
#
|
||||
# Substitution for sudo
|
||||
#
|
||||
|
||||
echo "$@" | tsu
|
61
termux/services/syncthing
Executable file
61
termux/services/syncthing
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/data/data/com.termux/files/usr/bin/bash
|
||||
#
|
||||
# Start Syncthing synchronization service
|
||||
#
|
||||
|
||||
PIDFILE="$HOME/.local/run/syncthing.pid"
|
||||
LOGFILE="$HOME/.local/log/syncthing.log"
|
||||
|
||||
start() {
|
||||
printf "Starting Syncthing: "
|
||||
sudo start-stop-daemon -p "$PIDFILE" -x syncthing -S -b -N 5 -m -- -logfile="$LOGFILE"
|
||||
termux-toast "Started Syncthing"
|
||||
echo "OK"
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf "Stopping Syncthing: "
|
||||
sudo start-stop-daemon -p "$PIDFILE" -x syncthing -K
|
||||
termux-toast "Stopped Syncthing"
|
||||
echo "OK"
|
||||
}
|
||||
|
||||
status() {
|
||||
printf "Syncthing: "
|
||||
PID="$(sudo cat "$PIDFILE")"
|
||||
if [[ -n "$PID" && -d "/proc/$PID" ]]
|
||||
then
|
||||
echo "running"
|
||||
else
|
||||
echo "stopped"
|
||||
fi
|
||||
}
|
||||
|
||||
log() {
|
||||
sudo 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 $?
|
Loading…
Reference in a new issue