Skip to content

Commit

Permalink
v6.22 (#2594)
Browse files Browse the repository at this point in the history
+ DietPi-Software | Deluge: Fix deluge-console login by applying users home dir system-side
+ DietPi-Software | Deluge: Do not install transitional/meta "deluge-webui" package, replaced even on Jessie by "deluge-web"
+ DietPi-Software | Deluge: Update systemd units according to official packaging sources
+ DietPi-Software | Deluge: Do not touch "/etc/default/deluged" which is only used by the init.d service
+ DietPi-Software | Deluge: Do not run deluged for config file creation since this runs as wrong user (home dir) and we download our config files anyway.
+ DietPi-Software | Deluge: Use "usermod" in case the user does already exist, which is the case with the APT install
+ DietPi-Software | Deluge: Switch to debian-deluged user, which is pre-generated by Debian APT package
+ DietPi-Software | Deluge: Switch to /var/log/deluged dir for logging, which is pre-generated by Debian APT package
+ DietPi-Software | Deluge: Add deluge-web log file to logrotate config
+ DietPi-Software | Deluge: Only download/edit config files, if not yet existent (fresh install)
+ DietPi-Software | Deluge: Delete init.d service traces, installed by Debian APT package
+ DietPi-Software | Kodi: Fix Buster install due to changed NFS library package: libnfs11 => libnfs12
+ DietPi-Software | Minor coding
+ DietPi-Set_Software | setpermissions: Update deluge permissions according to installer rewrite
+ DietPi-Set_Software | Minor coding
+ DietPi-Patch | Deluge: Patch according to installer rework
+ DietPi-Patch | Deluge: Remove obsolete Deluge configs
+ DietPi-Patch | Deluge: Inform user about Deluge rework and user change
  • Loading branch information
MichaIng authored Feb 28, 2019
1 parent d1844f5 commit f301916
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 86 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Changes / Improvements / Optimisations:
- DietPi-Software | GMediaRender: Enabled support for Debian/Raspbian Buster by using the up-to-date APT repo package.
- DietPi-Software | Aria2: Tweaked settings to enhance 3rd party plugin support and removed deprecated/doubled entries. Many thanks to @msongz for the commit: https://github.com/MichaIng/DietPi/pull/2538
- DietPi-Software | UrBackup: Updated installed version to 2.3.7. Thanks to @DeathIsUnknown for the information: https://github.com/MichaIng/DietPi/issues/2577
- DietPi-Software | Deluge: Reworked the installer to better match the Debian package defaults and recommendations/examples from the official documentation. Deluge now runs as user "debian-deluged", logs have been moved to "/var/log/deluged/" and the init.d service with its traces are removed, which are all pre-generated by the Debian APT package. The systemd units have been adjusted according to the official documentation. These changes are applied as well to existing systems during DietPi update, the old user "deluge" and obsolete configurations are removed. Your active configurations and data are preserved, the installer has been as well enhanced to better handle existing installs and never touch existing configs. Note that access to the Deluge console has to be done as user "debian-deluged" (sudo -u debian-deluged deluge-console). A related access issue to the console has been fixed by this as well. Thanks to @seanmikhaels for reporting this issue: https://dietpi.com/phpbb/viewtopic.php?f=11&t=5525

Bug Fixes:
- General | Resolved an issue where /etc/bashrc.d entries could be run multiple times. Many thanks to @jonare77 for reporting this: https://github.com/MichaIng/DietPi/issues/2529
Expand Down
118 changes: 60 additions & 58 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ _EOF_
aSOFTWARE_WHIP_DESC[$software_id]='bittorrent server with web interface (python)'
aSOFTWARE_CATEGORY_INDEX[$software_id]=3
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&start=10#p61'
aSOFTWARE_ONLINEDOC_URL[$software_id]='p=61#p61'

#------------------
software_id=46
Expand Down Expand Up @@ -3002,11 +3002,7 @@ _EOF_
output=2

# - Bump up for x86
if (( $G_HW_MODEL == 20 || $G_HW_MODEL == 21 )); then

output=3

fi
(( $G_HW_ARCH == 10 )) && output=3

#Max global connections
elif (( $1 == 2 )); then
Expand Down Expand Up @@ -4051,7 +4047,7 @@ _EOF_

else

package_list+=' libnfs11 libcec4'
package_list+=' libnfs12 libcec4'

fi

Expand Down Expand Up @@ -4227,12 +4223,11 @@ _EOF_

fi

#DELUGE
software_id=45
software_id=45 # Deluge
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then

Banner_Installing
G_AGI deluged deluge-web deluge-webui deluge-console
G_AGI deluged deluge-web deluge-console

fi

Expand Down Expand Up @@ -9057,82 +9052,90 @@ _EOF_

fi

#Deluge
software_id=45
software_id=45 # Deluge
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then

Banner_Configuration

useradd -rM deluge -G dietpi -s /usr/sbin/nologin
usercmd='useradd -r'
getent passwd debian-deluged &> /dev/null && usercmd='usermod'
$usercmd debian-deluged -G dietpi -d $G_FP_DIETPI_USERDATA/deluge -s /usr/sbin/nologin

mkdir -p $G_FP_DIETPI_USERDATA/deluge/.config/deluge
chown -R debian-deluged:debian-deluged $G_FP_DIETPI_USERDATA/deluge
mkdir -p /var/log/deluged
chown -R debian-deluged /var/log/deluged

> /var/log/deluged.log
> /var/log/deluge-web.log

# https://git.deluge-torrent.org/deluge/tree/packaging/systemd/deluged.service
cat << _EOF_ > /etc/systemd/system/deluged.service
[Unit]
Description=Deluged (DietPi)
Description=Deluge Daemon (DietPi)
Documentation=man:deluged
[Service]
Type=simple
User=deluge
User=debian-deluged
Group=dietpi
UMask=002
Environment=USER=deluge HOME=$G_FP_DIETPI_USERDATA/deluge
ExecStart=$(command -v deluged) -d -l /var/log/deluged.log -L warning
UMask=007
ExecStart=$(command -v deluged) -d -l /var/log/deluged/daemon.log -L warning
Restart=on-failure
TimeoutStopSec=300
[Install]
WantedBy=multi-user.target
_EOF_

# https://git.deluge-torrent.org/deluge/tree/packaging/systemd/deluge-web.service
cat << _EOF_ > /etc/systemd/system/deluge-web.service
[Unit]
Description=Deluge-web (DietPi)
Description=Deluge Web UI (DietPi)
Documentation=man:deluge-web
[Service]
# forking causes systemd-tty-ask-password-agent hang
Type=simple
User=deluge
Group=dietpi
Environment=USER=deluge HOME=$G_FP_DIETPI_USERDATA/deluge
ExecStart=$(command -v deluge-web) -l /var/log/deluge-web.log -L warning
User=debian-deluged
UMask=027
ExecStart=$(command -v deluge-web) -l /var/log/deluged/web.log -L warning
Restart=on-failure
[Install]
WantedBy=multi-user.target
_EOF_

#Generate deluge default config
deluged
killall -w deluged
# Add web.log to logrotate config
if [[ -f /etc/logrotate.d/deluged ]] && ! grep -q 'web.log' /etc/logrotate.d/deluged; then

#Copy DietPi configs
G_BACKUP_FP $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf $G_FP_DIETPI_USERDATA/deluge/.config/deluge/web.conf
dps_index=$software_id Download_Install 'deluge.conf' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
dps_index=$software_id Download_Install 'deluge_web.conf' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/web.conf
echo -e "\n$(</etc/logrotate.d/deluged)" >> /etc/logrotate.d/deluged
sed -i '1,1s/daemon.log/web.log/' /etc/logrotate.d/deluged

# - Enable service run:
G_CONFIG_INJECT 'ENABLE_DELUGED=' 'ENABLE_DELUGED=1' /etc/default/deluged
fi

#Set remote access login details
cat << _EOF_ > $G_FP_DIETPI_USERDATA/deluge/.config/deluge/auth
root:$GLOBAL_PW:10
_EOF_
# Adjust config files only, if not yet existent
if [[ ! -f $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf ]]; then

#Apply Optimized settings
# - Cache size is in steps of 16 KiB. (Cachesize * 16 = total KiB)
local deluge_cache_size=$(( $(echo -e "scale=0; $(Optimize_BitTorrent 0) * 1024 / 16" | bc -l ) ))
sed -i '/"cache_size": /c\ "cache_size": '"$deluge_cache_size"',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
# Copy DietPi configs
dps_index=$software_id Download_Install 'deluge.conf' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
dps_index=$software_id Download_Install 'deluge_web.conf' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/web.conf

sed -i '/"max_active_limit": /c\ "max_active_limit": '"$(Optimize_BitTorrent 1)"',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
sed -i '/"max_active_downloading": /c\ "max_active_downloading": '"$(Optimize_BitTorrent 1)"',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
sed -i '/"max_connections_global": /c\ "max_connections_global": '"$(Optimize_BitTorrent 2)"',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
sed -i '/"max_upload_slots_global": /c\ "max_upload_slots_global": '"$(Optimize_BitTorrent 3)"',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
# Set remote access login details
echo "root:$GLOBAL_PW:10" > $G_FP_DIETPI_USERDATA/deluge/.config/deluge/auth

# Apply optimised settings
# - Cache size is in steps of 16 KiB. (Cachesize * 16 = total KiB)
sed -i '/"cache_size": /c\ "cache_size": '$(( $(Optimize_BitTorrent 0) * 1024 / 16 ))',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
sed -i '/"max_active_limit": /c\ "max_active_limit": '$(Optimize_BitTorrent 1)',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
sed -i '/"max_active_downloading": /c\ "max_active_downloading": '$(Optimize_BitTorrent 1)',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
sed -i '/"max_connections_global": /c\ "max_connections_global": '$(Optimize_BitTorrent 2)',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf
sed -i '/"max_upload_slots_global": /c\ "max_upload_slots_global": '$(Optimize_BitTorrent 3)',' $G_FP_DIETPI_USERDATA/deluge/.config/deluge/core.conf

fi

# Remove init.d service leftovers, installed by Debian APT package
[[ -f /etc/init.d/deluged ]] && rm /etc/init.d/deluged
[[ -f /etc/default/deluged ]] && rm /etc/default/deluged
[[ -d /var/lib/deluged ]] && rm -R /var/lib/deluged

fi

#Webmin
software_id=115
software_id=115 # Webmin
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then

Banner_Configuration
Expand Down Expand Up @@ -13407,12 +13410,11 @@ _EOF_
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then

Banner_Uninstalling
G_AGP deluged deluge-web deluge-webui deluge-console
rm /etc/systemd/system/deluged.service
rm /etc/systemd/system/deluge-web.service
rm -R $G_FP_DIETPI_USERDATA/deluge

userdel -rf deluge
G_AGP deluged deluge-web deluge-console
userdel -rf debian-deluged
[[ -f /etc/systemd/system/deluged.service ]] && rm /etc/systemd/system/deluged.service
[[ -f /etc/systemd/system/deluge-web.service ]] && rm /etc/systemd/system/deluge-web.service
[[ -d $G_FP_DIETPI_USERDATA/deluge ]] && rm -R $G_FP_DIETPI_USERDATA/deluge

fi

Expand Down
40 changes: 18 additions & 22 deletions dietpi/func/dietpi-set_software
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
#
FP_SCRIPT='/DietPi/dietpi/func/dietpi-set_software'
AVAIABLE_COMMANDS="
Available commands
$FP_SCRIPT locale en_GB.UTF-8 / any other UTF-8 locale
$FP_SCRIPT allo eth_dhcp / eth_static
$FP_SCRIPT useradd X=create user with name X and default permissions, using global DietPi password (dietpi)
$FP_SCRIPT userdel X=delete user with name X
$FP_SCRIPT apt-mirror url / default
$FP_SCRIPT ntpd-mode [0-4] configures time sync mode (eg: daily/hourly/daemon)
$FP_SCRIPT verify_dietpi.txt Verifies dietpi.txt entries, adds missing entries if required
$FP_SCRIPT passwords NULL=Prompt user to change DietPi related passwords | X=optional set X as global password for future dietpi-software installations and \"root\" + \"dietpi\" login passwords.
$FP_SCRIPT setpermissions Applies required filesystem permissions to DietPi specific content, and, DietPi userdata directory for software installs
Available commands:
$FP_SCRIPT locale en_GB.UTF-8 / any other UTF-8 locale
$FP_SCRIPT allo eth_dhcp / eth_static
$FP_SCRIPT useradd X=create user with name X and default permissions, using global DietPi password (dietpi)
$FP_SCRIPT userdel X=delete user with name X
$FP_SCRIPT apt-mirror url / default
$FP_SCRIPT ntpd-mode [0-4] configures time sync mode (eg: daily/hourly/daemon)
$FP_SCRIPT verify_dietpi.txt Verifies dietpi.txt entries, adds missing entries if required
$FP_SCRIPT passwords NULL=Prompt user to change DietPi related passwords | X=optional set X as global password for future dietpi-software installations and \"root\" + \"dietpi\" login passwords.
$FP_SCRIPT setpermissions Applies required filesystem permissions to DietPi specific content, and, DietPi userdata directory for software installs
"
#////////////////////////////////////

Expand All @@ -49,15 +49,15 @@ $FP_SCRIPT setpermissions Applies required filesystem permissions to DietPi

EXIT_CODE=1
G_DIETPI-NOTIFY 2 "Unknown input name ($INPUT_MODE_NAME). Nothing has been applied."
echo -e "$AVAIABLE_COMMANDS"
echo "$AVAIABLE_COMMANDS"

}

Unknown_Input_Mode(){

EXIT_CODE=1
G_DIETPI-NOTIFY 2 "Unknown input value ($INPUT_MODE_VALUE). Nothing has been applied."
echo -e "$AVAIABLE_COMMANDS"
echo "$AVAIABLE_COMMANDS"

}

Expand All @@ -71,12 +71,8 @@ $FP_SCRIPT setpermissions Applies required filesystem permissions to DietPi

echo "$INPUT_MODE_VALUE UTF-8" > /etc/locale.gen

# - Add en_GB.UTF-8 back in, if its not the default
if [[ $INPUT_MODE_VALUE != 'en_GB.UTF-8' ]]; then

echo 'en_GB.UTF-8 UTF-8' >> /etc/locale.gen

fi
# - Add en_GB.UTF-8 back in, if not chosen, as DietPi scripts require it
[[ $INPUT_MODE_VALUE != 'en_GB.UTF-8' ]] && echo 'en_GB.UTF-8 UTF-8' >> /etc/locale.gen

# - Remove exisiting settings that will break dpkg-reconfigure
[[ -f /etc/default/locale ]] && rm /etc/default/locale
Expand Down Expand Up @@ -362,11 +358,11 @@ _EOF_
chown -R www-data:www-data $G_FP_DIETPI_USERDATA/pydio_data

local datadir="$(grep -m1 '^[[:blank:]]*SOFTWARE_OWNCLOUD_DATADIR=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
[[ -z $datadir ]] && datadir="$G_FP_DIETPI_USERDATA/owncloud_data"
[[ $datadir ]] || datadir="$G_FP_DIETPI_USERDATA/owncloud_data"
chown -R www-data:www-data "$datadir"

datadir="$(grep -m1 '^[[:blank:]]*SOFTWARE_NEXTCLOUD_DATADIR=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
[[ -z $datadir ]] && datadir="$G_FP_DIETPI_USERDATA/nextcloud_data"
[[ $datadir ]] || datadir="$G_FP_DIETPI_USERDATA/nextcloud_data"
chown -R www-data:www-data "$datadir"

# - Home Assistant Permissions
Expand Down Expand Up @@ -444,8 +440,8 @@ _EOF_
chown -R plexpy:dietpi $G_FP_DIETPI_USERDATA/plexpy

# - Deluge
chown -R deluge:dietpi $G_FP_DIETPI_USERDATA/deluge
chown deluge:dietpi /var/log/deluged.log /var/log/deluge-web.log
chown -R debian-deluged:debian-deluged $G_FP_DIETPI_USERDATA/deluge
chown -R debian-deluged /var/log/deluged

# - Jackett
chown -R jackett:jackett /opt/jackett
Expand Down
34 changes: 28 additions & 6 deletions dietpi/patch_file
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ _EOF_
#-------------------------------------------------------------------------------
# - Reinstalls
# Blynk: Apply new run user, update binary (jar)
# Deluge: https://github.com/MichaIng/DietPi/issues/2339
# v6.22 Deluge: https://github.com/MichaIng/DietPi/issues/2339
# Netdata: https://github.com/MichaIng/DietPi/pull/2337
# NAA Daemon: https://github.com/MichaIng/DietPi/issues/2387#issue-395321320
# MPD: https://github.com/MichaIng/DietPi/issues/2377
Expand All @@ -1496,7 +1496,7 @@ _EOF_
# Grafana: https://github.com/MichaIng/DietPi/issues/2449
if (( $G_DIETPI_INSTALL_STAGE == 2 )); then

/DietPi/dietpi/dietpi-software reinstall 37 45 65 77 108 124 128 131
/DietPi/dietpi/dietpi-software reinstall 37 65 77 108 124 128 131

# - Samba: Link disk cache to RAM: https://github.com/MichaIng/DietPi/issues/2396
if grep -q '^aSOFTWARE_INSTALL_STATE\[96\]=2' /DietPi/dietpi/.installed; then
Expand Down Expand Up @@ -1708,11 +1708,33 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=sid\nPin-Prior

fi
#-------------------------------------------------------------------------------
#Transfer project and lead over to Micha (legend!) :) #: https://github.com/Fourdee/DietPi/issues/2589#issue-413925061
if grep -q '^[[:blank:]]*DEV_GITOWNER=Fourdee' /DietPi/dietpi.txt; then
#Transfer project and lead over to Micha (legend!) :) #: https://github.com/MichaIng/DietPi/issues/2589#issue-413925061
grep -q '^[[:blank:]]*DEV_GITOWNER=Fourdee' /DietPi/dietpi.txt && G_CONFIG_INJECT 'DEV_GITOWNER=' 'DEV_GITOWNER=MichaIng' /DietPi/dietpi.txt
grep -q '^[[:blank:]]*G_GITOWNER=Fourdee' /DietPi/dietpi/.version && G_CONFIG_INJECT 'G_GITOWNER=' 'G_GITOWNER=MichaIng' /DietPi/dietpi/.version
#-------------------------------------------------------------------------------
#Deluge: Patch according to installer rework: https://github.com/MichaIng/DietPi/pull/2594
if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[45\]=2' /DietPi/dietpi/.installed; then

G_AGP deluge-webui
[[ -e ~deluge ]] && mv ~deluge $G_DIETPI_USERDATA/deluge_home_backup
userdel -rf deluge
rm -Rf /{root,home/*}/.config/deluge
mkdir -p /var/log/deluged
[[ -f /var/log/deluged.log ]] && mv /var/log/deluged.log /var/log/deluged/daemon.log
[[ -f /var/log/deluge-web.log ]] && mv /var/log/deluge-web.log /var/log/deluged/web.log

/DietPi/dietpi/dietpi-software reinstall 45

G_CONFIG_INJECT 'DEV_GITOWNER=' 'DEV_GITOWNER=MichaIng' /DietPi/dietpi.txt
G_CONFIG_INJECT 'G_GITOWNER=' 'G_GITOWNER=MichaIng' /DietPi/dietpi/.version
G_WHIP_MSG '[ INFO ] Deluge rework\n
Our Deluge installer has been reworked to match Debian APT package defaults and official documentations. This also resolves an issue when attempting to access "deluge-console".
- It runs now as user "debian-deluged".
- The user "deluge" has been removed, its home directory has been backed up to:
/mnt/dietpi_userdata/deluge_home_backup
in case it existed.
- Logs have been moved to /var/log/deluged/daemon.log|web.log.
- Apart from that, all your settings and data have been preserved.\n
NB: When accessing "deluge-console" you need to do that as user "debian-deluged":
sudo -u debian-deluged deluge-console'

fi
#-------------------------------------------------------------------------------
Expand Down

0 comments on commit f301916

Please sign in to comment.