<commit_before>#!/bin/bash
##########################################################################
# This script configures Deluge daemon to be ready to use.
#
# Author: <NAME>
# Version: 1.0
# Last modified date (dd/mm/yyyy): 05/05/2014
# Licence: MIT
##########################################################################

# Get common variables and check if the script is being running by a root or sudoer user
if [ "$1" != "" ]; then
	scriptRootFolder="$1"
else
	scriptRootFolder=".."
fi
. $scriptRootFolder/common/commonVariables.sh

# Variables
DELUGE_DAEMON_DOWNLOAD_FOLDER="$homeDownloadFolder/deluge"
DELUGE_DAEMON_TEMP_FOLDER="$homeFolder/.Temporal/deluge"
DELUGE_DAEMON_TORRENT_FOLDER="$homeDownloadFolder/torrents"
DELUGE_DAEMON_USERNAME="$username"
DELUGE_DAEMON_PASSWORD="<PASSWORD>"
DELUGE_DAEMON_CLIENT_PORT="58846"
DELUGE_DAEMON_WEB_PORT="8112"

# Set variables in deluge-daemon config files
echo "# Configuration for /etc/init.d/deluge-daemon
# The init.d script will only run if this variable non-empty.
DELUGED_USER=\"$username\"
# Should we run at startup?
RUN_AT_STARTUP=\"YES\"" > /etc/default/deluge-daemon
# Add username and password to Deluge's authentication file
sudo -u $username deluged
echo "$DELUGE_DAEMON_USERNAME:$DELUGE_DAEMON_PASSWORD:10" >> $homeFolder/.config/deluge/auth
chown $username:$username $homeFolder/.config/deluge/auth
# Set deluge folders
sudo -u $username deluge-console "config -s move_completed_path \"$DELUGE_DAEMON_DOWNLOAD_FOLDER\""
sudo -u $username deluge-console "config move_completed_path"
sudo -u $username deluge-console "config -s download_location \"$DELUGE_DAEMON_TEMP_FOLDER\""
sudo -u $username deluge-console "config download_location"
sudo -u $username deluge-console "config -s torrentfiles_location \"$DELUGE_DAEMON_TORRENT_FOLDER\""
sudo -u $username deluge-console "config torrentfiles_location"
sudo -u $username deluge-console "config -s autoadd_location \"$DELUGE_DAEMON_TORRENT_FOLDER\""
sudo -u $username deluge-console "config autoadd_location"
# Allow remote connection
sudo -u $username deluge-console "config -s allow_remote True"
sudo -u $username deluge-console "config allow_remote"
# Set Deluge daemon client and web ports
sudo -u $username deluge-console "config -s daemon_port $DELUGE_DAEMON_CLIENT_PORT"
sudo -u $username deluge-console "config daemon_port"
sudo -u $username sed -i "s/\"port\":.*/\"port\": $DELUGE_DAEMON_WEB_PORT/g" $homeFolder/.config/deluge/web.conf
pkill deluged

# Create menu launcher for deluge-daemon's web client.
echo "[Desktop Entry]
Name=Deluge Web
Exec=xdg-open http://localhost:$DELUGE_DAEMON_WEB_PORT
Icon=deluge<commit_msg>Fixes in Deluge server's setup subscript<commit_after>#!/bin/bash
##########################################################################
# This script configures Deluge daemon to be ready to use.
#
# Author: <NAME>
# Version: 1.0
# Last modified date (dd/mm/yyyy): 07/05/2014
# Licence: MIT
##########################################################################

# Get common variables and check if the script is being running by a root or sudoer user
if [ "$1" != "" ]; then
	scriptRootFolder="$1"
else
	scriptRootFolder=".."
fi
. $scriptRootFolder/common/commonVariables.sh

# Variables
DELUGE_DAEMON_DOWNLOAD_FOLDER="$homeDownloadFolder/deluge"
DELUGE_DAEMON_TEMP_FOLDER="$homeFolder/.Temporal/deluge"
DELUGE_DAEMON_TORRENT_FOLDER="$homeDownloadFolder/torrents"
DELUGE_DAEMON_USERNAME="$username"
DELUGE_DAEMON_PASSWORD="<PASSWORD>"
DELUGE_DAEMON_CLIENT_PORT="58846"
DELUGE_DAEMON_WEB_PORT="8112"

# Set variables in deluge-daemon config files
echo "# Configuration for /etc/init.d/deluge-daemon
# The init.d script will only run if this variable non-empty.
DELUGED_USER=\"$username\"
# Should we run at startup?
RUN_AT_STARTUP=\"YES\"" > /etc/default/deluge-daemon
# Add username and password to Deluge's authentication file
sudo -u $username deluged
sudo -u $username mkdir -p "$homeFolder/.config/deluge"
echo "$DELUGE_DAEMON_USERNAME:$DELUGE_DAEMON_PASSWORD:10" >> $homeFolder/.config/deluge/auth
chown $username:$username $homeFolder/.config/deluge/auth
# Set deluge folders
sudo -u $username deluge-console "config -s move_completed_path \"$DELUGE_DAEMON_DOWNLOAD_FOLDER\""
sudo -u $username deluge-console "config move_completed_path"
sudo -u $username deluge-console "config -s download_location \"$DELUGE_DAEMON_TEMP_FOLDER\""
sudo -u $username deluge-console "config download_location"
sudo -u $username deluge-console "config -s torrentfiles_location \"$DELUGE_DAEMON_TORRENT_FOLDER\""
sudo -u $username deluge-console "config torrentfiles_location"
sudo -u $username deluge-console "config -s autoadd_location \"$DELUGE_DAEMON_TORRENT_FOLDER\""
sudo -u $username deluge-console "config autoadd_location"
# Allow remote connection
sudo -u $username deluge-console "config -s allow_remote True"
sudo -u $username deluge-console "config allow_remote"
# Set Deluge daemon client port
sudo -u $username deluge-console "config -s daemon_port $DELUGE_DAEMON_CLIENT_PORT"
sudo -u $username deluge-console "config daemon_port"
pkill deluged

# Set Deluge daemon web port
echo "{
  \"file\": 1, 
  \"format\": 1
}{
  \"port\": $DELUGE_DAEMON_WEB_PORT
}" > "$homeFolder/.config/deluge/web.conf"
chown $username:$username "$homeFolder/.config/deluge/web.conf"

# Create menu launcher for deluge-daemon's web client.
echo "[Desktop Entry]
Name=Deluge Web
Exec=xdg-open http://localhost:$DELUGE_DAEMON_WEB_PORT
Icon=deluge
{'fraction_non_alphanumeric': 0.15916134913400182, 'fraction_numerical': 0.008751139471285323, 'mean_word_length': 6.3049267643142475, 'pattern_counts': {'":': 5, '<': 7, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4983412', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1810, 'n_words': 462}