From f139ad13f70de9d8ee0bf33a626c9d3678890bc8 Mon Sep 17 00:00:00 2001 From: MichaIng <28480705+MichaIng@users.noreply.github.com> Date: Tue, 16 Apr 2019 04:57:47 +0200 Subject: [PATCH] v6.23 (#2705) + DietPi-Software | Subsonic: Failsafe FFmpeg transcoder symlink creation, similar how we did with Airsonic + DietPi-Software | Subsonic: Now runs as limited user "subsonic" + DietPi-Patch | Reinstall Subsonic to apply "subsonic" user and transcoder fix + DietPi-Patch | Prevent initial stops and final start of services during DietPi-Software reinstalls. This new variable needs to implemented into DietPi-Software and in case other scripts, where applicable + DietPi-Software | Skip initial stop and final start of services, if $G_SERVICE_CONTROL == 0 was exported. Currently this is done by patch_file (DietPi-Update) which already has services stopped and starts or reboots after finish. Skip DietPi-Survey call for the same reason. + DietPi-Software | Visual-only syntax fix + DietPi-Software | Minor coding and wording --- CHANGELOG.txt | 2 + dietpi/dietpi-software | 148 +++++++++++++++++++---------------------- dietpi/patch_file | 11 ++- 3 files changed, 81 insertions(+), 80 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 81fa907525..1c72e9feab 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -11,6 +11,7 @@ Changes / Improvements / Optimisations: - DietPi-Config | Serial/UART device handling has been reworked. Serial login consoles can now be toggled for every found serial device individually. On RPi the primary UART can be completely disabled and warnings are prompted if Bluetooth and login console are to be enabled both on ttyAMA0. On update existing systems will be patched so that serial-getty masks and enabled instances are removed if the related serial device does not exist. This solves some error messages during boot. - DietPi-Config | Network Adapter menu has been cleaned up. Proxy variables are now sourced from "/etc/bashrc.d/dietpi-proxy.sh" and proxy setup outside of DietPi scripts is detected. - DietPi-Software | Subsonic: Package has been updated to v6.1.5. Many thanks to @spectrumcomputing: https://github.com/MichaIng/DietPi/pull/2702 +- DietPi-Software | Subsonic: Runs now as limited user "subsonic". This change is as well applied to existing installs via patch during DietPi-Update: https://github.com/MichaIng/DietPi/pull/2705 - DietPi-Software | WireGuard APT packages are now upgraded when running "apt-get upgrade". Many thanks to @swrobel for reporting this issue: https://github.com/MichaIng/DietPi/issues/2671 Bug Fixes: @@ -20,6 +21,7 @@ Bug Fixes: - DietPi-Software | Emby Server: Resolved an issue where download failed if the latest release does not contain a Debian package. Many thanks to @niblettr for reporting this issue: https://dietpi.com/phpbb/viewtopic.php?f=11&t=5755 - DietPi-Software | Transmission: Resolved an issue where double quotes in global software password caused a service startup failure. Many thanks to @Drew80 for reporting this issue: https://github.com/MichaIng/DietPi/issues/2484#issuecomment-480675168 - DietPi-Software | WireGuard: Resolved an issue where IPv6 connections did not work with enabled IPv6 forwarding. Many thats to @schnuckz for reporting this issue: https://github.com/MichaIng/DietPi/issues/2691 +- DietPi-Software | Subsonic: Resolved an issue where FFmpeg transcoder might not have been applied correctly. Many thanks to @spectrumcomputing for reporting this issue: https://github.com/MichaIng/DietPi/issues/2697 As always, many smaller code performance and stability improvements, visual and spelling fixes have been done, too much to list all of them here. Check out all code changes of this release on GitHub: https://github.com/MichaIng/DietPi/pull/XXXX/files diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index f01a2acb75..129aa09244 100644 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -579,14 +579,14 @@ _EOF_ #------------------ software_id=34 - aSOFTWARE_WHIP_NAME[$software_id]='Subsonic' - aSOFTWARE_WHIP_DESC[$software_id]='web interface media streaming server' - aSOFTWARE_CATEGORY_INDEX[$software_id]=2 - aSOFTWARE_TYPE[$software_id]=0 - aSOFTWARE_REQUIRES_ALSA[$software_id]=1 - aSOFTWARE_REQUIRES_FFMPEG[$software_id]=1 - aSOFTWARE_REQUIRES_JAVA_JRE_JDK[$software_id]=1 - aSOFTWARE_ONLINEDOC_URL[$software_id]='p=213#p213' + aSOFTWARE_WHIP_NAME[$software_id]='Subsonic' + aSOFTWARE_WHIP_DESC[$software_id]='web interface media streaming server' + aSOFTWARE_CATEGORY_INDEX[$software_id]=2 + aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_REQUIRES_ALSA[$software_id]=1 + aSOFTWARE_REQUIRES_FFMPEG[$software_id]=1 + aSOFTWARE_REQUIRES_JAVA_JRE_JDK[$software_id]=1 + aSOFTWARE_ONLINEDOC_URL[$software_id]='p=213#p213' #------------------ software_id=35 @@ -1154,13 +1154,13 @@ _EOF_ #-------------------------------------------------------------------------------- software_id=108 - aSOFTWARE_WHIP_NAME[$software_id]='AmiBerry' - aSOFTWARE_WHIP_DESC[$software_id]='amiga emulator' - aSOFTWARE_CATEGORY_INDEX[$software_id]=5 - aSOFTWARE_TYPE[$software_id]=0 - aSOFTWARE_REQUIRES_ALSA[$software_id]=1 - aSOFTWARE_ONLINEDOC_URL[$software_id]='p=64#p64' - aSOFTWARE_REQUIRES_XSERVERXORG[$software_id]=1 + aSOFTWARE_WHIP_NAME[$software_id]='AmiBerry' + aSOFTWARE_WHIP_DESC[$software_id]='amiga emulator' + aSOFTWARE_CATEGORY_INDEX[$software_id]=5 + aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_REQUIRES_ALSA[$software_id]=1 + aSOFTWARE_ONLINEDOC_URL[$software_id]='p=64#p64' + aSOFTWARE_REQUIRES_XSERVERXORG[$software_id]=1 # - Disable for All non-RPi for ((i=10; i<=$MAX_G_HW_MODEL; i++)) @@ -4305,7 +4305,7 @@ _EOF_ Banner_Installing - #G_AGI lame # Conflicts with our ffmpeg package: https://github.com/MichaIng/DietPi/issues/946#issuecomment-300738228 + #DEPS_LIST='lame' # Conflicts with our ffmpeg package: https://github.com/MichaIng/DietPi/issues/946#issuecomment-300738228 Download_Install 'https://dietpi.com/downloads/binaries/all/subsonic.deb' fi @@ -5281,8 +5281,7 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=sid\nPin-Prior fi - #MINEOS - software_id=53 + software_id=53 # MineOS if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -6722,7 +6721,7 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix Banner_Installing - #RPi + OpenMAX HW Encoding: https://github.com/MichaIng/DietPi/issues/869 + # RPi + OpenMAX HW Encoding: https://github.com/MichaIng/DietPi/issues/869 if (( $G_HW_MODEL < 10 )); then Download_Install 'https://dietpi.com/downloads/binaries/rpi/ffmpeg_rpi.7z' ffmpeg_rpi @@ -6730,7 +6729,7 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix dpkg -i ffmpeg_rpi/*.deb rm -R ffmpeg_rpi - #Everything else + # Everything else else G_AGI ffmpeg @@ -9238,7 +9237,7 @@ Do you want to enable the Pi-hole blocking page?'; then getent passwd airsonic &> /dev/null && usercmd='usermod' $usercmd airsonic -G dietpi,audio -d $G_FP_DIETPI_USERDATA/airsonic -s /usr/sbin/nologin - #Optimize memory limit + # Optimize memory limit local airsonic_memory_max=$(( $RAM_TOTAL / 5 )) (( $airsonic_memory_max < 200 )) && airsonic_memory_max=200 airsonic_memory_max+='m' @@ -9258,10 +9257,10 @@ ExecStart=$(command -v java) -Xmx$airsonic_memory_max -Dairsonic.home=$G_FP_DIET WantedBy=multi-user.target _EOF_ - #Symlink FFmpeg to Airsonic transcoder - ln -sf $(command -v ffmpeg) $G_FP_DIETPI_USERDATA/airsonic/transcode + # Symlink FFmpeg to Airsonic transcoder + command -v ffmpeg &> /dev/null && ln -sf $(command -v ffmpeg) $G_FP_DIETPI_USERDATA/airsonic/transcode - #Grab our test media for user + # Grab our test media for user Download_Test_Media fi @@ -9271,48 +9270,45 @@ _EOF_ Banner_Configuration - #Optimize memory limit - local subsonic_memory_max=$(( $RAM_TOTAL / 5 )) - if (( $subsonic_memory_max < 200 )); then - - subsonic_memory_max=200 + local usercmd='useradd -rM' + getent passwd subsonic &> /dev/null && usercmd='usermod' + $usercmd subsonic -G dietpi,audio -d /var/subsonic -s /usr/sbin/nologin - fi + # Optimize memory limit + local subsonic_memory_max=$(( $RAM_TOTAL / 5 )) + (( $subsonic_memory_max < 200 )) && subsonic_memory_max=200 - cat << _EOF_ > /etc/default/subsonic -SUBSONIC_USER=root -SUBSONIC_ARGS='--quiet --pidfile=/run/subsonic.pid --max-memory=$subsonic_memory_max --default-music-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC --default-podcast-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC --default-playlist-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC' -_EOF_ + G_CONFIG_INJECT 'SUBSONIC_USER=' 'SUBSONIC_USER=subsonic' /etc/default/subsonic + G_CONFIG_INJECT 'SUBSONIC_ARGS=' "SUBSONIC_ARGS='--quiet --pidfile=/run/subsonic.pid --max-memory=$subsonic_memory_max --default-music-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC --default-podcast-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC --default-playlist-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC'" /etc/default/subsonic - #Symlink FFmpeg to Subsonic transcoder - ln -fs $(command -v ffmpeg) /var/subsonic/transcode + # Symlink FFmpeg to Subsonic transcoder + mkdir -p /var/subsonic/transcode + command -v ffmpeg &> /dev/null && ln -sf $(command -v ffmpeg) /var/subsonic/transcode - #Grab our test media for user + # Grab our test media for user Download_Test_Media fi - #WEBIOPI - software_id=71 + software_id=71 # WEBIOPI if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Configuration - #auto start + # autostart update-rc.d webiopi defaults fi - #DIETPICLOUDSHELL - software_id=62 + software_id=62 # DietPi-CloudShell if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Configuration - #Enable DietPi-Cloudshell autostart + # Enable DietPi-Cloudshell autostart /DietPi/dietpi/dietpi-autostart 5 - #Service + # Service cat << _EOF_ > /etc/systemd/system/dietpi-cloudshell.service [Unit] Description=dietpi-cloudshell on main screen (DietPi) @@ -10725,18 +10721,17 @@ _EOF_ fi - #MINEOS - software_id=53 + software_id=53 # MineOS if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Configuration - # - Add underprivilged user for web access | no longer works, could be a nodejs v8 issue? + # Add underprivilged user for web access | no longer works, could be a nodejs v8 issue? useradd mineos echo -e "$GLOBAL_PW\n$GLOBAL_PW\n" | passwd mineos - #Stop mineos from running while we config it. When we didnt do this, the program would constantly overwrite our symlink from (/var/games/minecraft). - /DietPi/dietpi/dietpi-services stop + # Stop mineos from running while we config it. When we didnt do this, the program would constantly overwrite our symlink from (/var/games/minecraft). + #/DietPi/dietpi/dietpi-services stop # Already done after install step now killall -w supervisord &> /dev/null killall -w node &> /dev/null killall -w nodejs &> /dev/null @@ -13556,6 +13551,7 @@ _EOF_ Banner_Uninstalling G_AGP subsonic + getent passwd subsonic &> /dev/null && userdel -rf subsonic [[ -d /var/subsonic ]] && rm -R /var/subsonic fi @@ -14811,7 +14807,7 @@ _EOF_ # Unmask all services: https://github.com/MichaIng/DietPi/issues/1320 DISABLE_SERVICES_START=1 /DietPi/dietpi/dietpi-services unmask all # Stop services - /DietPi/dietpi/dietpi-services stop + [[ $G_SERVICE_CONTROL == 0 ]] || /DietPi/dietpi/dietpi-services stop #------------------------------------------------------------ #Generate userdata folders: Create_UserContent_Folders @@ -15062,14 +15058,14 @@ _EOF_ else # - Uninstall | Stop services prior - [[ $1 == 'uninstall' ]] && /DietPi/dietpi/dietpi-services stop + [[ $1 == 'uninstall' && $G_SERVICE_CONTROL != 0 ]] && /DietPi/dietpi/dietpi-services stop # - Process inputs for i in $input do # - Check if input software ID exists, install state was defined - if disable_error=1 G_CHECK_VALIDINT $i 0 + if disable_error=1 G_CHECK_VALIDINT $i 0 && disable_error=1 G_CHECK_VALIDINT ${aSOFTWARE_INSTALL_STATE[$i]}; then if [[ $1 == 'uninstall' ]]; then @@ -15144,22 +15140,18 @@ _EOF_ # - Reinstall, prompt for backup if [[ $1 == 'reinstall' ]]; then - if (( $GOSTARTINSTALL )); then - - G_PROMPT_BACKUP - - fi + (( $GOSTARTINSTALL )) && G_PROMPT_BACKUP # - Uninstall | Finish up and clear non-required packages elif [[ $1 == 'uninstall' ]]; then Uninstall_Software - #Save + # - Save Write_InstallFileList # - Start services - /DietPi/dietpi/dietpi-services start + [[ $G_SERVICE_CONTROL == 0 ]] || /DietPi/dietpi/dietpi-services start fi @@ -16195,12 +16187,11 @@ When you select any software for install that requires a webserver, DietPi will fi done + [[ $G_SERVICE_CONTROL == 0 ]] || string_output+='\nNB: Software services will be temporarily controlled (stopped) by DietPi during this process. Please inform connected users, before continuing. SSH is not affected.' #Confirm Software install if G_WHIP_YESNO "DietPi is now ready to install your software choices: $string_output\n -Software details, usernames, passwords etc:\n - https://dietpi.com/software\n -NB: Software services will be temporarily controlled (stopped) by DietPi during this process. Please inform connected users, before continuing. SSH is not affected.\n -Would you like to begin?"; then +Software details, usernames, passwords etc:\n - https://dietpi.com/software\n\nWould you like to begin?"; then #exit menu system TARGETMENUID=-1 @@ -16329,14 +16320,14 @@ NB: You can use dietpi-software at a later date, to install optimized software f UNINSTALL_REQUIRED=1 done + [[ $G_SERVICE_CONTROL == 0 ]] || output_string+='\nNB: Software services will be temporarily controlled (stopped) by DietPi during this process. Please inform connected users, before continuing. SSH is not affected.' if (( $UNINSTALL_REQUIRED )); then - G_WHIP_YESNO "$output_string \n\nNB: Software services will be temporarily controlled (stopped) by DietPi during this process. Please inform connected users, before continuing. SSH is not affected.\n\nDo you wish to continue?" - if (( $? == 0 )); then + if G_WHIP_YESNO "$output_string\n\nDo you wish to continue?"; then - # - stop services - /DietPi/dietpi/dietpi-services stop + # - Stop services + [[ $G_SERVICE_CONTROL == 0 ]] || /DietPi/dietpi/dietpi-services stop # - Run uninstall for i in ${G_WHIP_RETURNED_VALUE[@]} @@ -16347,11 +16338,11 @@ NB: You can use dietpi-software at a later date, to install optimized software f done Uninstall_Software - #Save + # - Save Write_InstallFileList - # - start services - /DietPi/dietpi/dietpi-services start + # - Start services + [[ $G_SERVICE_CONTROL == 0 ]] || /DietPi/dietpi/dietpi-services start G_WHIP_MSG 'Uninstall completed.' @@ -16437,13 +16428,13 @@ NB: You can use dietpi-software at a later date, to install optimized software f #Init software arrays Software_Arrays_Init #-------------------------------------------------------------------------------------- - #load .installed file, update vars, if it exists + #Load .installed file, update vars, if it exists Read_InstallFileList #-------------------------------------------------------------------------------------- #Update GLOBAL_PW Update_Global_Pw #-------------------------------------------------------------------------------------- - # - CLi input mode + # - CLI input mode if [[ $1 ]]; then # - Run input mode @@ -16474,12 +16465,12 @@ NB: You can use dietpi-software at a later date, to install optimized software f fi # - Disable serial? - # must be enabled for the following: + # Must be enabled for the following: # XU4: https://github.com/MichaIng/DietPi/issues/2038#issuecomment-416089875 # RockPro64: Fails to boot into kernel without serial enabled # NanoPi Neo Air: Required for end users/debugging/setting up WiFi without automation - if (( $(grep -m1 '^[[:blank:]]*CONFIG_SERIAL_CONSOLE_ENABLE=' /DietPi/dietpi.txt | sed 's/^.*=//') == 1 && - $G_HW_MODEL != 11 && $G_HW_MODEL != 42 && $G_HW_MODEL != 64 )); then + if grep -q '^[[:blank:]]*CONFIG_SERIAL_CONSOLE_ENABLE=1' /DietPi/dietpi.txt && + (( $G_HW_MODEL != 11 && $G_HW_MODEL != 42 && $G_HW_MODEL != 64 )); then if G_WHIP_YESNO 'Serial console is currently enabled, would you like to disable it?\n - Disabling serial console will reduce memory consumption slightly\n - If you are unsure on what serial console is, it is safe to disable it'; then @@ -16537,9 +16528,9 @@ NB: You can use dietpi-software at a later date, to install optimized software f # Unmask systemd-logind if set in dietpi.txt / libpam-systemd was installed / Kodi if [[ $(readlink /etc/systemd/system/systemd-logind.service) == '/dev/null' ]] && - ( grep -q '^[[:blank:]]*AUTO_UNMASK_LOGIND=1' /DietPi/dietpi.txt || + { grep -q '^[[:blank:]]*AUTO_UNMASK_LOGIND=1' /DietPi/dietpi.txt || dpkg-query -s 'libpam-systemd' &> /dev/null || - (( ${aSOFTWARE_INSTALL_STATE[31]} > 0 )) ); then + (( ${aSOFTWARE_INSTALL_STATE[31]} > 0 )); }; then G_RUN_CMD systemctl unmask systemd-logind # systemd-logind is currently a static unit, but to be failsafe: @@ -16549,14 +16540,15 @@ NB: You can use dietpi-software at a later date, to install optimized software f fi # Upload DietPi-Survey Data, if opted in, prompt user choice, if no settings file exists - /DietPi/dietpi/dietpi-survey 1 + # - Skip, if G_SERVICE_CONTROL == 0, which is exported by patch_file (DietPi-Update) which sends survey already + [[ $G_SERVICE_CONTROL == 0 ]] || /DietPi/dietpi/dietpi-survey 1 G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Installation completed' if (( $DISABLE_REBOOT )); then # - Start services (restart to reload webserver configs) - /DietPi/dietpi/dietpi-services restart + [[ $G_SERVICE_CONTROL == 0 ]] || /DietPi/dietpi/dietpi-services restart else diff --git a/dietpi/patch_file b/dietpi/patch_file index 9a16f4a92d..8238011936 100644 --- a/dietpi/patch_file +++ b/dietpi/patch_file @@ -29,6 +29,9 @@ # Prevent backup prompts during patching e.g. from DietPi-Software reinstalls export G_PROMPT_BACKUP_DISABLED=1 + # Prevent initial and final service crontrol during DietPi-Software reinstalls + export G_SERVICE_CONTROL=0 + # Export subversion, required for pre-v6.14 export G_DIETPI_VERSION_SUB=$INPUT @@ -547,12 +550,12 @@ _EOF_ #Reinstalls # RPi (apply to all) LXDE missing icons under pcmanfm reinstall: https://github.com/MichaIng/DietPi/issues/1558#issuecomment-390328173 # v6.12 AirSonic - # SubSonic + # v6.23 SubSonic # Cava # CloudPrint # TightVNC/VNC4/RealVNC: https://github.com/MichaIng/DietPi/pull/1798#issuecomment-392594878 # v6.19 Xserver: https://github.com/MichaIng/DietPi/issues/1823 - (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 23 27 28 34 119 120 137 + (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 23 27 28 119 120 137 #------------------------------------------------------------------------------- #Initially allow non-root users to obtain network details as well: https://github.com/MichaIng/DietPi/commit/15c0d495c33d3091e219c87bb2d09a22f8d27e9c chmod -f 666 /{DietPi,boot}/dietpi/.network @@ -1750,6 +1753,10 @@ Further info and usage: https://dietpi.com/phpbb/viewtopic.php?f=8&t=5828' sed -i '/^ListenPort/a\PostDown = ip6tables -D FORWARD -i %i -j ACCEPT; ip6tables -t nat -D POSTROUTING -o $(sed -n 3p /DietPi/dietpi/.network) -j MASQUERADE' /etc/wireguard/wg0.conf fi + #Reinstalls + # Subsonic: https://github.com/MichaIng/DietPi/pull/2705 + [[ -L '/var/subsonic/transcode' ]] && rm /var/subsonic/transcode + /DietPi/dietpi/dietpi-software reinstall 34 fi #-------------------------------------------------------------------------------