Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read download/incomplete directory paths from settings.json #277

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions root/etc/s6-overlay/s6-rc.d/init-transmission-config/run
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# make folders
mkdir -p \
/downloads/{complete,incomplete} /watch
SETTINGS=/config/settings.json

# copy config
if [[ ! -f /config/settings.json ]]; then
cp /defaults/settings.json /config/settings.json
if [[ ! -f $SETTINGS ]]; then
cp /defaults/settings.json $SETTINGS
fi

# Default values
DOWNLOAD_DIR="/downloads/complete"
INCOMPLETE_DIR="/downloads/incomplete"

# Check `settings.json` for custom download/incomplete directories
settings_download_dir=$(grep -o '"download-dir": "[^"]*' "$SETTINGS" | sed 's/"download-dir": "//')
aptalca marked this conversation as resolved.
Show resolved Hide resolved
if [ ! -z "$settings_download_dir" ]; then
DOWNLOAD_DIR="$settings_download_dir"
fi
settings_incomplete_dir=$(grep -o '"incomplete-dir": "[^"]*' "$SETTINGS" | sed 's/"incomplete-dir": "//')
if [ ! -z "$settings_incomplete_dir" ]; then
INCOMPLETE_DIR="$settings_incomplete_dir"
fi

# make folders
mkdir -p $DOWNLOAD_DIR
mkdir -p $INCOMPLETE_DIR
mkdir -p /watch

if [[ -n "$USER" ]] && [[ -n "$PASS" ]]; then
sed -i '/rpc-authentication-required/c\ "rpc-authentication-required": true,' /config/settings.json
sed -i "/rpc-username/c\ \"rpc-username\": \"$USER\"," /config/settings.json
Expand Down Expand Up @@ -49,16 +66,16 @@ echo /transmissionic /combustion-release /flood-for-transmission /kettu /transmi
lsiown abc:abc \
/config/settings.json

if [[ "$(stat -c '%U' /downloads)" != "abc" ]]; then
if [[ -d /downloads && "$(stat -c '%U' /downloads)" != "abc" ]]; then
lsiown abc:abc /downloads
fi

if [[ "$(stat -c '%U' /downloads/complete)" != "abc" ]]; then
lsiown abc:abc /downloads/complete
if [[ "$(stat -c '%U' $DOWNLOAD_DIR)" != "abc" ]]; then
lsiown abc:abc $DOWNLOAD_DIR
fi

if [[ "$(stat -c '%U' /downloads/incomplete)" != "abc" ]]; then
lsiown abc:abc /downloads/incomplete
if [[ "$(stat -c '%U' $INCOMPLETE_DIR)" != "abc" ]]; then
lsiown abc:abc $INCOMPLETE_DIR
fi

if [[ "$(stat -c '%U' /watch)" != "abc" ]]; then
Expand Down