Use systemd folders in rpxy-start.sh
This commit is contained in:
parent
ce4316d15f
commit
c241215149
1 changed files with 30 additions and 7 deletions
|
|
@ -8,12 +8,35 @@ CONFIG_FILE="$CONFIG_DIR/config.toml"
|
||||||
WEBUI_CONFIG="/var/www/rpxy-webui/storage/app/config.toml"
|
WEBUI_CONFIG="/var/www/rpxy-webui/storage/app/config.toml"
|
||||||
COMMENT_MARKER="# IMPORTANT: DEACTIVATED This config is deactivated because rpxy-webui is installed"
|
COMMENT_MARKER="# IMPORTANT: DEACTIVATED This config is deactivated because rpxy-webui is installed"
|
||||||
|
|
||||||
# Ensure the cache directory exists as it could get deleted on system restart
|
setup_directories() {
|
||||||
create_cache_dir() {
|
# Check if systemd is available
|
||||||
# Create the temporary directory for rpxy
|
if [ -d /run/systemd/system ]; then
|
||||||
|
# Use systemd RuntimeDirectory if available
|
||||||
|
if [ -d /run/rpxy ]; then
|
||||||
|
RUNTIME_DIR="/run/rpxy"
|
||||||
|
# If not available use PrivateTmp
|
||||||
|
elif [ -d /tmp/systemd-private-*/tmp ]; then
|
||||||
|
RUNTIME_DIR=$(find /tmp/systemd-private-*/tmp -type d -name "rpxy" 2>/dev/null | head -n 1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create subdirectory for cache
|
||||||
|
CACHE_DIR="$RUNTIME_DIR/.cache"
|
||||||
|
# Ensure the cache directory exists as it could get deleted on system restart
|
||||||
mkdir -p "$CACHE_DIR"
|
mkdir -p "$CACHE_DIR"
|
||||||
chown -R rpxy:rpxy /tmp/rpxy
|
chown rpxy:rpxy "$CACHE_DIR" # not recursively because parent folder is managed by systemd
|
||||||
chmod 700 "$CACHE_DIR"
|
chmod 700 "$CACHE_DIR"
|
||||||
|
else
|
||||||
|
# Fallback to linux tmp directory if no systemd is found
|
||||||
|
RUNTIME_DIR="/tmp/rpxy"
|
||||||
|
CACHE_DIR="$RUNTIME_DIR/.cache"
|
||||||
|
# Ensure the cache directory exists as it could get deleted on system restart
|
||||||
|
mkdir -p "$CACHE_DIR"
|
||||||
|
chown -R rpxy:rpxy "$RUNTIME_DIR"
|
||||||
|
chmod 700 "$CACHE_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using runtime directory: $RUNTIME_DIR"
|
||||||
|
echo "Using cache directory: $CACHE_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if rpxy-webui is installed
|
# Check if rpxy-webui is installed
|
||||||
|
|
@ -45,7 +68,7 @@ remove_comment_from_config() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
[ -d "$CACHE_DIR" ] || create_cache_dir
|
setup_directories
|
||||||
ensure_config_exists
|
ensure_config_exists
|
||||||
|
|
||||||
if is_package_installed rpxy-webui; then
|
if is_package_installed rpxy-webui; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue