Skip to content

Commit

Permalink
Transmission fixes (anandslab#45)
Browse files Browse the repository at this point in the history
* Transmission Startup fixes

Added Type=simple to the override.conf due to the repo breaking the app starting. 
Other general code cleanup.
  • Loading branch information
TommyE123 authored Mar 16, 2018
1 parent c460492 commit 8155834
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 42 deletions.
11 changes: 6 additions & 5 deletions transmission-daemon/transmission-daemon-default-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ echo -e "${YELLOW}--->Updating Default file...$ENDCOLOR"
# [optional] change to 1 to enable daemon
if [[ -f /etc/default/$APPNAME ]]; then
echo 'Updating default file'
sudo sed -i "s@/var/lib/transmission-daemon/info@$APPPATH@g" \
/etc/default/transmission-daemon || \
{ echo -e \
"${RED}Replacing config directory in default failed.$ENDCOLOR"; \
exit 1; }
if sudo sed -i "s@/var/lib/transmission-daemon/info@$APPPATH@g" \
/etc/default/transmission-daemon || \
{ echo -e "${RED}Replacing config directory in default failed.$ENDCOLOR"; \
exit 1; }; then
echo "Set CONFIG DIR to $APPPATH"
fi
fi

echo 'Updated Default file with new values'
5 changes: 4 additions & 1 deletion transmission-daemon/transmission-daemon-init-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@

if [[ -f /etc/init.d/$APPINITD ]]; then
echo 'Updating init.d file'
sudo sed -i "s@USER=debian-transmission@USER=$UNAME@g" /etc/init.d/transmission-daemon || { echo -e $RED'Replacing daemon username in init failed.'$ENDCOLOR ; exit 1; }
if sudo sed -i "s@USER=debian-transmission@USER=$UNAME@g" /etc/init.d/transmission-daemon || \
{ echo -e "${RED}Replacing daemon username in init.d failed.$ENDCOLOR" ; exit 1; }; then
echo "Set USER to $UNAME"
fi
fi
9 changes: 8 additions & 1 deletion transmission-daemon/transmission-daemon-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ source "$SCRIPTPATH/inc/app-install-deps.sh"
source "$SCRIPTPATH/inc/app-folders-create.sh"

# Just adds the override and updates it for systemd.
source "$SCRIPTPATH/inc/app-autostart-configure.sh"
if IsSystemdSupported; then
source "$SCRIPTPATH/inc/app-systemd-add.sh"
source "$SCRIPTPATH/$APPNAME/$APPNAME-systemd-update.sh"
fi

source "$SCRIPTPATH/inc/app-install.sh"

if ! grep -qF 'net.core.rmem_max' /etc/sysctl.conf;then
Expand All @@ -37,7 +41,10 @@ source "$SCRIPTPATH/transmission-daemon/transmission-daemon-constants.sh"
source "$SCRIPTPATH/inc/app-start.sh"
sleep 2
source "$SCRIPTPATH/$APPNAME/$APPNAME-settings-configurator.sh"

# Command which reloads the settings file.
kill -s SIGHUP "$(pidof transmission-daemon)" >/dev/null 2>&1

source "$SCRIPTPATH/inc/app-install-confirmation.sh"
source "$SCRIPTPATH/inc/thankyou.sh"
source "$SCRIPTPATH/inc/exit.sh"
1 change: 1 addition & 0 deletions transmission-daemon/transmission-daemon-override.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[Service]
Type=simple
User=ReplaceMe
Group=ReplaceMe
57 changes: 35 additions & 22 deletions transmission-daemon/transmission-daemon-settings-configurator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,42 @@ echo
echo -e "$YELLOW--->Configuring Transmission Settings...$ENDCOLOR"

#Set to allow network access instead of localhost.
sudo sed -i "s@\"rpc-whitelist-enabled\": \
true@\"rpc-whitelist-enabled\": false@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying whitelist enabled in \
$APPSETTINGS file failed.$ENDCOLOR"; exit 1; }
if sudo sed -i "s@\"rpc-whitelist-enabled\": \
true@\"rpc-whitelist-enabled\": false@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying whitelist enabled in \
$APPSETTINGS file failed.$ENDCOLOR"; exit 1; }; then
echo 'Whitelist disabled'
fi

#Enable incomplete folder & destination
sudo sed -i "s@\"incomplete-dir-enabled\": false@\"incomplete-dir-enabled\": true@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying incomplete enabled in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }
sudo sed -i "s@\"incomplete-dir\": \"/home/$UNAME/Downloads\"@\"incomplete-dir\": \"/home/$UNAME/Downloads/transmission/incomplete\"@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying incomplete location in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }
if sudo sed -i "s@\"incomplete-dir-enabled\": false@\"incomplete-dir-enabled\": true@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying incomplete enabled in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }; then
echo 'incomplete-dir-enabled'
fi

#Set download folder destination
sudo sed -i "s@\"download-dir\": \"/home/$UNAME/Downloads\"@\"download-dir\": \"/home/$UNAME/Downloads/transmission/completed\"@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying completed location in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }

#Set Watch folder enabled & destination
sudo sed -i "s@\"utp-enabled\": true@\"utp-enabled\": true,@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying Utp in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }

sudo sed -i '/\"utp-enabled\": true,/a \\ \\ \\ \\ \"watch-dir-enabled\": true' "$APPSETTINGS" || \
{ echo -e "${RED}Adding Watch enabled in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }
if sudo sed -i "s@\"incomplete-dir\": \"/home/$UNAME/Downloads\"@\"incomplete-dir\": \"/home/$UNAME/Downloads/transmission/incomplete\"@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying incomplete location in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }; then
echo "incomplete-dir set to /home/$UNAME/Downloads/transmission/incomplete"
fi

sudo sed -i "/\"utp-enabled\": true,/a \\ \\ \\ \\ \"watch-dir\": \"/home/$UNAME/Downloads/transmission/watch\"," "$APPSETTINGS" || \
{ echo -e "${RED}Adding watch location in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }

echo 'Done'
#Set download folder destination
if sudo sed -i "s@\"download-dir\": \"/home/$UNAME/Downloads\"@\"download-dir\": \"/home/$UNAME/Downloads/transmission/completed\"@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying completed location in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }; then
echo "download-dir set to /home/$UNAME/Downloads/transmission/completed"
fi

#Set Watch folder enabled & destination (utp now needs a comma)
if sudo sed -i "s@\"utp-enabled\": true@\"utp-enabled\": true,@g" "$APPSETTINGS" || \
{ echo -e "${RED}Modifying Utp in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }; then
echo 'utp-enabled'
fi

if sudo sed -i "/\"utp-enabled\": true,/a \\ \\ \\ \\ \"watch-dir-enabled\": true" "$APPSETTINGS" || \
{ echo -e "${RED}Adding Watch enabled in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }; then
echo 'watch-dir-enabled'
fi

if sudo sed -i "/\"utp-enabled\": true,/a \\ \\ \\ \\ \"watch-dir\": \"/home/$UNAME/Downloads/transmission/watch\"," "$APPSETTINGS" || \
{ echo -e "${RED}Adding watch location in $APPSETTINGS file failed.$ENDCOLOR"; exit 1; }; then
echo "Watch location set to /home/$UNAME/Downloads/transmission/watch"
fi
13 changes: 8 additions & 5 deletions transmission-daemon/transmission-daemon-systemd-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
echo
echo -e "$YELLOW--->Updating transmission-daemon.service.d/override.conf to run as $CYAN$UNAME$ENDCOLOR ...$ENDCOLOR"

sudo sed -i "s@User=ReplaceMe@User=$UNAME@g" /etc/systemd/system/transmission-daemon.service.d/override.conf || \
{ echo -e "${RED}Modifying USER in SYSTEMD file failed.$ENDCOLOR"; exit 1; }
sudo sed -i "s@Group=ReplaceMe@Group=$UGROUP@g" /etc/systemd/system/transmission-daemon.service.d/override.conf || \
{ echo -e "${RED}Modifying GROUP in SYSTEMD file failed.$ENDCOLOR"; exit 1; }
if sudo sed -i "s@User=ReplaceMe@User=$UNAME@g" /etc/systemd/system/transmission-daemon.service.d/override.conf || \
{ echo -e "${RED}Modifying USER in SYSTEMD file failed.$ENDCOLOR"; exit 1; }; then
echo -e "Set USER to ${CYAN}$UNAME$ENDCOLOR"
fi

echo 'OK'
if sudo sed -i "s@Group=ReplaceMe@Group=$UGROUP@g" /etc/systemd/system/transmission-daemon.service.d/override.conf || \
{ echo -e "${RED}Modifying GROUP in SYSTEMD file failed.$ENDCOLOR"; exit 1; }; then
echo -e "Set GROUP to ${CYAN}$UGROUP$ENDCOLOR"
fi
20 changes: 12 additions & 8 deletions transmission-daemon/transmission-daemon-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ if DoesAppFolderExist; then
source "$SCRIPTPATH/inc/app-stop.sh"
source "$SCRIPTPATH/utils/nzbtomedia/nzbtomedia-update.sh"
source "$SCRIPTPATH/transmission-daemon/transmission-daemon-constants.sh"

#Temp fixes previous incorrect permissions
sudo chown root:root "/etc/systemd/system/$APPNAME.service.d" || \
{ echo -e "${RED}Chown on $APPSYSTEMDOVERIDELOC failed.$ENDCOLOR"; exit 1; }

sudo chmod -R 644 "/etc/systemd/system/$APPNAME.service.d" || \
{ echo -e "${RED}Chmod on $APPSYSTEMDOVERIDELOC failed.$ENDCOLOR"; exit 1; }

source "$SCRIPTPATH/inc/app-install-deps.sh"
source "$SCRIPTPATH/inc/app-update.sh"

# Added 15/03/2018 - Can be removed when felt everyone has picked up the required fix
# New installs has this as default
if IsSystemdSupported; then
if ! grep -i 'Type=simple' /etc/systemd/system/transmission-daemon.service.d/override.conf; then
if sudo sed -i '/\[Service\]/a Type=simple' /etc/systemd/system/transmission-daemon.service.d/override.conf; then
echo 'Inserted Type=simple into /etc/systemd/system/transmission-daemon.service.d/override.conf'
systemctl daemon-reload
fi
fi
fi

source "$SCRIPTPATH/inc/app-start.sh"
source "$SCRIPTPATH/inc/app-update-confirmation.sh"
source "$SCRIPTPATH/inc/thankyou.sh"
Expand Down

0 comments on commit 8155834

Please sign in to comment.