Fixes in install/onionr
- Replace := with :- as := causes an extra unnecessary assignment each time it is used - Use system-wide default dirs based on being EUID 0 rather than not having $HOME set - with previous logic you needed to unset $HOME to interact with the GUI - Default XDG_DATA_HOME to $HOME/.local/share rather than $HOME/.local/share/onionr as it should not be set to an app specific dir, and usage as if it is one would result in files being set in the user's chosen XDG_DATA_HOME directly (not in an onionr subdir) - Default ONIONR_HOME to $XDG_DATA_HOME/onionr rather than $XDG_DATA_HOME - see previous - Put $LOG_DIR under $ONIONR_HOME rather than $XDG_DATA_HOME - see previous - Don't bother setting XDG_DATA_HOME since we only use it here - Default ONIONR_HOME to /var/lib/onionr rather than /etc/onionr for system-wide as it's mostly state data, not just config - Make assignments more concise - Removed -R from chmod - 700 already restricts access to subdirectories and files, and this chmod would require all files to be marked executable, which is not necessary - Specified 0700 in chmod - Make sure setuid/setgid/sticky isn't set for some reason - Removed chown - chown is usually reserved for root - Specify python3 rather than 3.7 - We support 3.6 and probably want to support 3.8+ too - Rename OUTPUT_DIR to the more descriptive ONIONR_BASEDIR - Call onionr.sh rather than onionr.py (nonexistent, presumably intended __init__.py, but this is better anyway)
This commit is contained in:
parent
f0e7810342
commit
ec6cda7de9
@ -1,23 +1,16 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
export OUTPUT_DIR=${OUTPUT_DIR:=/usr/share/onionr}
|
if [[ $EUID -eq 0 ]]; then
|
||||||
|
export ONIONR_HOME=${ONIONR_HOME:-/var/lib/onionr}
|
||||||
if [ -n "$HOME" ]; then
|
export LOG_DIR=${LOG_DIR:-/var/log/onionr}
|
||||||
export XDG_DATA_HOME=${XDG_DATA_HOME:=$HOME/.local/share/onionr}
|
|
||||||
|
|
||||||
export ONIONR_HOME=${ONIONR_HOME:=$XDG_DATA_HOME}
|
|
||||||
export LOG_DIR=${LOG_DIR:=$XDG_DATA_HOME/logs}
|
|
||||||
else
|
else
|
||||||
export ONIONR_HOME=${ONIONR_HOME:=/etc/onionr}
|
export ONIONR_HOME=${ONIONR_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/onionr}
|
||||||
export LOG_DIR=${LOG_DIR:=/var/log/onionr}
|
export LOG_DIR=${LOG_DIR:-$ONIONR_HOME/logs}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$ONIONR_HOME" "$LOG_DIR"
|
mkdir -p "$ONIONR_HOME" "$LOG_DIR"
|
||||||
|
|
||||||
chmod -R 700 "$ONIONR_HOME" "$LOG_DIR"
|
chmod 0700 "$ONIONR_HOME" "$LOG_DIR"
|
||||||
chown -R $USER:$USER "$ONIONR_HOME" "$LOG_DIR"
|
|
||||||
|
|
||||||
cd "$OUTPUT_DIR/onionr"
|
exec ${ONIONR_BASEDIR:-/usr/share/onionr}/onionr.sh "$@"
|
||||||
exec python3.7 onionr.py "$@"
|
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Onionr Daemon
|
Description=Onionr Daemon
|
||||||
Documentation=https://onionr.net/docs/
|
Documentation=https://onionr.net/docs/
|
||||||
After=network.target tor.service
|
After=network-online.target
|
||||||
Requires=network.target tor.service systemd-networkd-wait-online.service
|
Requires=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment="DATA_DIR=/usr/share/onionr"
|
Environment="ONIONR_HOME=/var/lib/onionr"
|
||||||
Environment="LOG_DIR=/var/log/onionr/"
|
Environment="LOG_DIR=/var/log/onionr"
|
||||||
|
|
||||||
ExecStart=/usr/bin/onionr --start
|
ExecStart=/usr/bin/onionr start
|
||||||
ExecStop=/usr/bin/onionr --stop
|
ExecStop=/usr/bin/onionr stop
|
||||||
|
|
||||||
KillMode=mixed
|
KillMode=mixed
|
||||||
KillSignal=SIGQUIT
|
KillSignal=SIGQUIT
|
||||||
TimeoutStopSec=5s
|
TimeoutStopSec=30s
|
||||||
Type=simple
|
|
||||||
Restart=on-abnormal
|
Restart=on-abnormal
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=tor.service
|
WantedBy=multi-user.target
|
||||||
|
Loading…
Reference in New Issue
Block a user