diff --git a/.conf/dps_27/apache.tasmoadmin.conf b/.conf/dps_27/apache.tasmoadmin.conf new file mode 100644 index 0000000000..d6ce64b3e7 --- /dev/null +++ b/.conf/dps_27/apache.tasmoadmin.conf @@ -0,0 +1,5 @@ + + Require all granted + AllowOverride All + Options FollowSymLinks + diff --git a/.conf/dps_27/lighttpd.tasmoadmin.conf b/.conf/dps_27/lighttpd.tasmoadmin.conf new file mode 100644 index 0000000000..55508255bb --- /dev/null +++ b/.conf/dps_27/lighttpd.tasmoadmin.conf @@ -0,0 +1,19 @@ +$HTTP["url"] =~ "^/tasmoadmin($|/)" { + # Restrict direct access to .htaccess and data directory + $HTTP["url"] =~ "^/tasmoadmin/(\.|data)" { + url.access-deny = ("") + } + + # TasmoAdmin URL rewrite, required for sync clients + url.rewrite-if-not-file = ( + "^/tasmoadmin/doAjax$" => "/tasmoadmin/index.php?doAjax=doAjax", + "^/tasmoadmin/doAjaxAll$" => "/tasmoadmin/index.php?doAjaxAll=doAjaxAll", + "^/tasmoadmin/login$" => "/tasmoadmin/login.php", + "^/tasmoadmin/logout$" => "/tasmoadmin/login.php?logout=logout", + "^/tasmoadmin/([a-zA-Z_]+)/([a-zA-Z_]+)/([0-9_]+)$" => "/tasmoadmin/index.php?page=$1&action=$2&device_id=$3", + "^/tasmoadmin/([a-zA-Z_]+)/(force)$" => "/tasmoadmin/index.php?page=$1&force=1", + "^/tasmoadmin/([a-zA-Z_]+)/([a-zA-Z_]+)$" => "/tasmoadmin/index.php?page=$1&action=$2", + "^/tasmoadmin/([a-zA-Z_]+)/([0-9]+)$" => "/tasmoadmin/index.php?page=$1&device_id=$2", + "^/tasmoadmin/([a-zA-Z_]+)$" => "/tasmoadmin/index.php?page=$1" + ) +} diff --git a/.conf/dps_27/nginx.tasmoadmin.conf b/.conf/dps_27/nginx.tasmoadmin.conf new file mode 100644 index 0000000000..48b73431ec --- /dev/null +++ b/.conf/dps_27/nginx.tasmoadmin.conf @@ -0,0 +1,34 @@ +location ^~ /tasmoadmin { + location /tasmoadmin/firmwares { + } + + # Deny access to .htaccess and data dir + location ~ ^/tasmoadmin/(?:\.|data) { + deny all; + } + + location ~* \.php$ { + fastcgi_pass php; + fastcgi_read_timeout 900; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + location ~* \.(css|js|gif||jpe?g|png|json|cache\.json)$ { + } + + location /tasmoadmin { + rewrite ^/tasmoadmin/login$ /tasmoadmin/login.php last; + rewrite ^/tasmoadmin/logout$ /tasmoadmin/login.php?logout=logout last; + rewrite ^/tasmoadmin/doAjaxAll$ /tasmoadmin/index.php?doAjaxAll=doAjaxAll last; + rewrite ^/tasmoadmin/doAjax$ /tasmoadmin/index.php?doAjax=doAjax last; + rewrite "/tasmoadmin/([a-z]{2})/" /tasmoadmin/index.php?lang=$1 last; + rewrite ^/tasmoadmin/([a-zA-Z_]+)/([a-zA-Z_]+)/([0-9_]+)/?$ /tasmoadmin/index.php?page=$1&action=$2&device_id=$3; + rewrite ^/tasmoadmin/([a-zA-Z_]+)/(force)/?$ /tasmoadmin/index.php?page=$1&force=1; + rewrite ^/tasmoadmin/([a-zA-Z_]+)/([a-zA-Z_]+)/?$ /tasmoadmin/index.php?page=$1&action=$2; + rewrite ^/tasmoadmin/([a-zA-Z_]+)/([0-9]+)/?$ /tasmoadmin/index.php?page=$1&device_id=$2; + rewrite ^/tasmoadmin/([a-zA-Z_]+)/?$ /tasmoadmin/index.php?page=$1; + } +} diff --git a/.conf/dps_47/nginx.owncloud.conf b/.conf/dps_47/nginx.owncloud.conf index 83d14be6a8..a57a1227f6 100644 --- a/.conf/dps_47/nginx.owncloud.conf +++ b/.conf/dps_47/nginx.owncloud.conf @@ -92,4 +92,4 @@ location ^~ /owncloud { # Optional: Don't log access to other assets access_log off; } - } +} diff --git a/.meta/dietpi-imager b/.meta/dietpi-imager index 317ef7aaa6..0aab40eff0 100755 --- a/.meta/dietpi-imager +++ b/.meta/dietpi-imager @@ -6,9 +6,11 @@ #//////////////////////////////////// # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com # Updated by MichaIng / micha@dietpi.com / dietpi.com + # Clonezilla integration by sal666 # #//////////////////////////////////// # - Create new .img file from drive | or use existing .img file + # | or use Clonezilla to take an image from drive and to generate a bootable ISO file # - Minimises root partition and file system # - Hashes and 7z's the final image ready for release #//////////////////////////////////// @@ -26,8 +28,11 @@ FP_ROOT_DEV='' ROOT_PARTITION_INDEX=0 OUTPUT_IMG_NAME='' - OUTPUT_7Z_NAME='' + OUTPUT_IMG_EXT='img' GPT=0 + CLONING_TOOL='' + CLONEZILLA_REPO='https://sourceforge.net/projects/clonezilla/files/clonezilla_live_alternative' + DIETPI_REPO="https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH" Delete_Loopback(){ [[ -b $FP_SOURCE ]] && G_RUN_CMD losetup -d $FP_SOURCE; } @@ -51,29 +56,54 @@ \nNB: If you want to create a Clonezilla-based installer image, the input OS needs to be attached as physical drive, since Clonezilla currently does neither support .img files nor loop devices.' || Exit_On_Fail if [[ $G_WHIP_RETURNED_VALUE == 'Drive' ]]; then - # Detect drives and list for selection - G_WHIP_MENU_ARRAY=($(lsblk -dnpo NAME,SIZE)) - # - Visually separate dev name and space - for ((i=1;i<${#G_WHIP_MENU_ARRAY[@]};i+=2)); do G_WHIP_MENU_ARRAY[$i]=": ${G_WHIP_MENU_ARRAY[$i]}"; done - if [[ $G_WHIP_MENU_ARRAY ]]; then + G_WHIP_MENU_ARRAY=( - G_WHIP_MENU 'Please select the drive you wish to create the image from:' || Exit_On_Fail + 'dd' ': Create an image (.img) file with dd.' + 'Clonezilla' ': Create a bootable image (.iso) file with Clonezilla.' + + ) + + G_WHIP_MENU 'Please select which cloning tool to use:' || Exit_On_Fail + CLONING_TOOL=$G_WHIP_RETURNED_VALUE + + if [[ $CLONING_TOOL == 'dd' ]]; then + + # List block devices, excluding RAM disks + G_WHIP_MENU_ARRAY=$(lsblk -rnpo PKNAME,FSTYPE) else - G_DIETPI-NOTIFY 1 'No drives found, aborting...' + OUTPUT_IMG_EXT='iso' + # List block devices, excluding RAM disks and loop devices + G_WHIP_MENU_ARRAY=$(lsblk -rnpo PKNAME,FSTYPE -e 1,7) + + fi + # Detect drives with a partition table, containing a partition with ext4 file system, excluding the hosts root FS drive + local host_rootfs_dev=$(lsblk -rnpo PKNAME,MOUNTPOINT | mawk '$2=="/" {print $1;exit}') + G_WHIP_MENU_ARRAY=($(mawk -v root=$host_rootfs_dev '{if ( $1!=root && $2=="ext4" ) print $1,$2}' <<< "$G_WHIP_MENU_ARRAY" | sort -u)) + + if [[ ! $G_WHIP_MENU_ARRAY ]]; then + + G_DIETPI-NOTIFY 1 'No drive with an ext4 partition found, aborting...' + G_DIETPI-NOTIFY 2 'Hint: This is the list of available block devices' + lsblk -npo NAME,SIZE,MAJ:MIN,FSTYPE,MOUNTPOINT,MODEL Exit_On_Fail fi + + # Visually separate dev name and size and add model and serial + for ((i=1;i<${#G_WHIP_MENU_ARRAY[@]};i+=2)); do G_WHIP_MENU_ARRAY[$i]=": $(lsblk -drno SIZE,MODEL,SERIAL ${G_WHIP_MENU_ARRAY[$i-1]})"; done + G_WHIP_MENU 'Please select the drive you wish to create the image from: +\nNB: All mounted partitions of the selected drive will be unmounted.' || Exit_On_Fail FP_SOURCE=$G_WHIP_RETURNED_VALUE G_DIETPI-NOTIFY 2 'Unmounting all mounted file systems of the selected source drive...' - for i in $FP_SOURCE* + for i in $FP_SOURCE?* do - findmnt $i &> /dev/null && { umount $i || Exit_On_Fail; } + findmnt $i &> /dev/null && { umount -R $i || Exit_On_Fail; } - done + done elif [[ $G_WHIP_RETURNED_VALUE == 'Image' ]]; then @@ -102,8 +132,8 @@ # Detect partitions and list for selection G_WHIP_MENU_ARRAY=($(lsblk -npo NAME,SIZE ${FP_SOURCE}?*)) - # - Visually separate dev name and space - for ((i=1;i<${#G_WHIP_MENU_ARRAY[@]};i+=2)); do G_WHIP_MENU_ARRAY[$i]=": ${G_WHIP_MENU_ARRAY[$i]}"; done + # Visually separate dev name and size and add FS type + for ((i=1;i<${#G_WHIP_MENU_ARRAY[@]};i+=2)); do G_WHIP_MENU_ARRAY[$i]=": $(lsblk -drno SIZE,FSTYPE ${G_WHIP_MENU_ARRAY[$i-1]})"; done G_WHIP_MENU 'Please select the OS root partition:' || Exit_On_Fail FP_ROOT_DEV=$G_WHIP_RETURNED_VALUE ROOT_PARTITION_INDEX=${FP_ROOT_DEV: -1} @@ -111,20 +141,14 @@ G_WHIP_DEFAULT_ITEM='DietPi_--' G_WHIP_INPUTBOX 'Please enter the filename for the new image:\n - DietPi_--\n - EG: DietPi_RPi-ARMv6-Buster' || Exit_On_Fail OUTPUT_IMG_NAME=$G_WHIP_RETURNED_VALUE - OUTPUT_7Z_NAME="$OUTPUT_IMG_NAME.7z" - # Add version number to output file name - G_WHIP_DEFAULT_ITEM='v6.25' - G_WHIP_INPUTBOX 'Please enter the DietPi version for this image:\n - EG: v6.25' || Exit_On_Fail - OUTPUT_IMG_NAME="${OUTPUT_IMG_NAME//DietPi_/DietPi_${G_WHIP_RETURNED_VALUE}_}.img" - - # Check for existing file, in case offer backup - if [[ -f '/root/'$OUTPUT_IMG_NAME ]]; then + # Check for existing file, in case offer backup. Skip if source is image file and matches output file already. + if [[ /root/$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT != $FP_SOURCE_IMG && -f $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT ]]; then G_WHIP_BUTTON_OK_TEXT='Overwrite' G_WHIP_BUTTON_CANCEL_TEXT='Backup' - G_WHIP_YESNO "[WARNING] /root/$OUTPUT_IMG_NAME already exists\n -Do you want to overwrite or backup the existing file to $OUTPUT_IMG_NAME.bak?" || mv /root/$OUTPUT_IMG_NAME /root/$OUTPUT_IMG_NAME.bak + G_WHIP_YESNO "[WARNING] /root/$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT already exists\n +Do you want to overwrite or backup the existing file to /root/$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT.bak?" || mv $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT{,.bak} fi @@ -132,6 +156,9 @@ Do you want to overwrite or backup the existing file to $OUTPUT_IMG_NAME.bak?" | Main(){ + # Create final image + archive in /root + cd /root + Menu_Main # Install required packages @@ -146,13 +173,13 @@ Do you want to overwrite or backup the existing file to $OUTPUT_IMG_NAME.bak?" | # GPT images: # - "GPT PMBR size mismatch (4458495 != 15523839)" # - "Error: The backup GPT table is corrupt, but the primary appears OK, so that will be used." - # - gdisk write will correct this + # - gdisk will correct this elif [[ $(parted -s $FP_SOURCE print) == *'Partition Table: gpt'* ]]; then G_DIETPI-NOTIFY 2 'GPT partition table detected, applying gdisk fix...' GPT=1 G_AG_CHECK_INSTALL_PREREQ gdisk - echo -e 'w\ny\nq\n' | gdisk $FP_SOURCE + sgdisk -g $FP_SOURCE else @@ -161,7 +188,7 @@ Do you want to overwrite or backup the existing file to $OUTPUT_IMG_NAME.bak?" | fi - e2fsck -f $FP_ROOT_DEV + e2fsck -f $FP_ROOT_DEV || Exit_On_Fail # Remount image for any required edits fp_mnt='tmp_rootfs' @@ -174,8 +201,9 @@ Do you want to overwrite or backup the existing file to $OUTPUT_IMG_NAME.bak?" | partprobe $FP_SOURCE # Failsafe fi + rmdir /mnt/$fp_mnt - e2fsck -f $FP_ROOT_DEV # Failsafe + e2fsck -f $FP_ROOT_DEV || Exit_On_Fail # Failsafe # Shrink file system to minimum # - Run multiple times until no change is done any more @@ -192,13 +220,13 @@ Do you want to overwrite or backup the existing file to $OUTPUT_IMG_NAME.bak?" | FS_SIZE=$(mawk '{print $5 + 1024}' <<< $out) # 4k blocks rm resize2fs_out resize2fs $FP_ROOT_DEV $FS_SIZE - G_DIETPI-NOTIFY 2 "Reduced RootFS size to $(( $FS_SIZE / 256 + 1 )) MiB" + G_DIETPI-NOTIFY 0 "Reduced RootFS size to $(( $FS_SIZE / 256 + 1 )) MiB" FS_SIZE=$(( $FS_SIZE * 8 )) # 4k blocks => 512 byte sectors break elif out=$(grep -im1 'no such file or directory' resize2fs_out); then - G_DIETPI-NOTIFY 1 'Partition not found' + G_DIETPI-NOTIFY 1 'Partition not found, aborting...' Exit_On_Fail fi @@ -206,8 +234,8 @@ Do you want to overwrite or backup the existing file to $OUTPUT_IMG_NAME.bak?" | done # Estimate minimum end sector - PART_START=$(fdisk -l -o Device,Start $FP_SOURCE | grep "^$FP_ROOT_DEV" | mawk '{print $2}') # 512 byte sectors - PART_END_CURRENT=$(fdisk -l -o Device,End $FP_SOURCE | grep "^$FP_ROOT_DEV" | mawk '{print $2}') + PART_START=$(sfdisk -qlo Device,Start $FP_SOURCE | grep "^$FP_ROOT_DEV" | mawk '{print $2}') # 512 byte sectors + PART_END_CURRENT=$(sfdisk -qlo Device,End $FP_SOURCE | grep "^$FP_ROOT_DEV" | mawk '{print $2}') PART_END_TARGET=$(( $PART_START + $FS_SIZE )) # Only try to shrink partition when new end sector is less than current end sector @@ -226,17 +254,14 @@ Do you want to overwrite or backup the existing file to $OUTPUT_IMG_NAME.bak?" | # GPT images: # - "GPT PMBR size mismatch (4458495 != 15523839)" # - "Error: The backup GPT table is corrupt, but the primary appears OK, so that will be used." - # - gdisk write will correct this - (( $GPT )) && echo -e 'w\ny\nq\n' | gdisk $FP_SOURCE + # - gdisk will correct this + (( $GPT )) && sgdisk -g $FP_SOURCE # Finished: Derive final image size from last partition end + failsafe buffer partprobe $FP_SOURCE - IMAGE_SIZE=$(( ( $(fdisk -l -o End $FP_SOURCE | tail -1) + 1 ) * 512 )) # 512 byte sectors => Byte + IMAGE_SIZE=$(( ( $(sfdisk -qlo End $FP_SOURCE | tail -1) + 1 ) * 512 )) # 512 byte sectors => Byte IMAGE_SIZE=$(( $IMAGE_SIZE + ( 512 * 256 ) )) # 64 byte for secondary GPT + safety net - # Created final image + archive in /root - cd /root - # Image file source if [[ $FP_SOURCE_IMG ]]; then @@ -246,41 +271,180 @@ Do you want to overwrite or backup the existing file to $OUTPUT_IMG_NAME.bak?" | G_DIETPI-NOTIFY 2 "Truncating final image file to actually used size: $(( $IMAGE_SIZE / 1024 / 1024 + 1 )) MiB" truncate --size=$IMAGE_SIZE "$FP_SOURCE_IMG" - # Rename and move to /root - mv "$FP_SOURCE_IMG" $OUTPUT_IMG_NAME + # Rename and move to /root, if source image != output image already + [[ /root/$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT != $FP_SOURCE_IMG ]] && mv "$FP_SOURCE_IMG" $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT - # Drive source - else + # Check if there is enough free disk space to store the 7z file + NEEDED_FREE_SPACE=$(( $IMAGE_SIZE / 100 * 15 / 1024 / 1024 )) + G_CHECK_FREESPACE /root $(( $NEEDED_FREE_SPACE + 100 )) || Exit_On_Fail # Assure +100 MiB left partition space + + # Drive source, clone with dd + elif [[ $CLONING_TOOL == 'dd' ]]; then + + # Check if there is enough free disk space to store the image and the 7z file + NEEDED_FREE_SPACE=$(( $IMAGE_SIZE / 100 * 115 / 1024 / 1024 )) + G_CHECK_FREESPACE /root $(( $NEEDED_FREE_SPACE + 100 )) || Exit_On_Fail # Assure +100 MiB left partition space G_DIETPI-NOTIFY 2 "Creating final image with actually used size: $(( $IMAGE_SIZE / 1024 / 1024 + 1 )) MiB" - dd if=$FP_SOURCE of=$OUTPUT_IMG_NAME bs=1M status=progress count=$(( $IMAGE_SIZE / 1024 / 1024 + 1 )) + dd if=$FP_SOURCE of=$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT bs=1M status=progress count=$(( $IMAGE_SIZE / 1024 / 1024 + 1 )) + + # Drive source, clone with Clonezilla + else + + G_DIETPI-NOTIFY 2 'Creating final image with Clonezilla' + # Install required packages + G_AG_CHECK_INSTALL_PREREQ clonezilla partclone xorriso isolinux syslinux-common unzip curl || Exit_On_Fail + + # Download last version of Clonezilla Live + CLONEZILLA_VERSION=$(curl -s "$CLONEZILLA_REPO/" | grep 'class="folder "' | head -n1 | cut -d\" -f2) + if [[ -z "$CLONEZILLA_VERSION" ]]; then + G_DIETPI-NOTIFY 1 'Could not retrieve version number of last Clonezilla Live, aborting...' + Exit_On_Fail + + fi + CLONEZILLA_ZIP="clonezilla-live-${CLONEZILLA_VERSION}-amd64.zip" + CLONEZILLA_ZIP_URL="$CLONEZILLA_REPO/${CLONEZILLA_VERSION}/${CLONEZILLA_ZIP}/download" + CLONEZILLA_ZIP_SIZE=$(curl -sIL "$CLONEZILLA_ZIP_URL" | mawk '/^content-length:/{print $2}') + + # Check if there is enough free disk space to store Clonezilla, the final image and the 7z file + NEEDED_FREE_SPACE=$(( ( $CLONEZILLA_ZIP_SIZE + $IMAGE_SIZE / 100 * 23 ) * 2 / 1024 / 1024 )) + G_CHECK_FREESPACE /root $(( $NEEDED_FREE_SPACE + 100 )) || Exit_On_Fail # Assure +100 MiB left partition space + + # Download Clonezilla Live + if [[ ! -f $CLONEZILLA_ZIP || $(stat -c %s "$CLONEZILLA_ZIP") != $CLONEZILLA_ZIP_SIZE ]]; then + + G_DIETPI-NOTIFY 2 "Downloading Clonezilla Live v$CLONEZILLA_VERSION..." + wget "$CLONEZILLA_ZIP_URL" -O "$CLONEZILLA_ZIP" || Exit_On_Fail + + fi + + # Extract Clonezilla Live + unzip "$CLONEZILLA_ZIP" -d 'tmpiso' || Exit_On_Fail + rm "$CLONEZILLA_ZIP" + + # Clone disk with Clonezilla + if [[ ! -d tmpiso/home/partimag/$OUTPUT_IMG_NAME ]]; then + + mkdir -p tmpiso/home/partimag/ + G_DIETPI-NOTIFY 2 'Cloning disk with Clonezilla...' + ocs-sr -or /root/tmpiso/home/partimag --nogui -fsck -q2 -c -j2 -z1p -i 4096 -senc -sc savedisk $OUTPUT_IMG_NAME ${FP_SOURCE##*/} || Exit_On_Fail + + fi + + # For the sake of privacy, remove some non vital files that contain SNs and UUIDs + rm -f tmpiso/home/partimag/$OUTPUT_IMG_NAME/{Info*txt,*list,clonezilla-img} + + # Check image + G_DIETPI-NOTIFY 2 'Checking Clonezilla image...' + ocs-chkimg -b --nogui --ocsroot /root/tmpiso/home/partimag $OUTPUT_IMG_NAME || Exit_On_Fail + + # Prepare custom files used by the installer when booting in UEFI mode + wget "$DIETPI_REPO"/.meta/images/dietpi-background_768p.png -O tmpiso/boot/grub/dietpibg.png || Exit_On_Fail + wget "$DIETPI_REPO"/.meta/images/select_bkg_c.png -O tmpiso/boot/grub/select_bkg_c.png || Exit_On_Fail + cat << '_EOF_' > tmpiso/boot/grub/theme.txt +title-text: "" +desktop-image: "dietpibg.png" +terminal-font: "Unifont Regular 16" +terminal-width: "100%" +terminal-height: "100%" +message-color: "#ffffff" ++ boot_menu { + width = 60% + height = 80% + item_spacing = 10 + item_color = "#000000" + selected_item_color = "#ffffff" + selected_item_pixmap_style = "select_bkg_*.png" +} +_EOF_ + mv tmpiso/boot/grub/{grub,clonezilla}.cfg + sed '/menuentry /,/}/d' tmpiso/boot/grub/clonezilla.cfg | sed '/submenu /,/}/d' | grep -v '^[ ]*$' > tmpiso/boot/grub/grub.cfg + sed -n -e '/menuentry .*800x600/,/}/p' -e '/menuentry .*KMS/,/}/p' -e '/menuentry .*Safe/,/}/p' \ + -e '/menuentry .*Failsafe/,/}/p' tmpiso/boot/grub/clonezilla.cfg >> tmpiso/boot/grub/grub.cfg + sed -i -e 's|set timeout=.*|set timeout="-1"|' -e '/set pref=/ a set theme=$pref/theme.txt' \ + -e 's|"Clonezilla live |"Install DietPi |' -e 's|locales= |locales=en_GB.UTF-8 |' \ + -e 's|keyboard-layouts= |keyboard-layouts=gb |' -e 's|ocs-live-general|ocs-live-restore|' \ + -e 's|ocs_live_extra_param=""|ocs_live_extra_param="-icds -k1 -r -e2 -j2 -batch -p poweroff restoredisk ask_user ask_user"|' \ + -e 's|ocs_live_batch="no"|ocs_live_batch="yes"|' tmpiso/boot/grub/grub.cfg + cat << '_EOF_' >> tmpiso/boot/grub/grub.cfg +submenu "Clonezilla live" { + set pref=/boot/grub + configfile $pref/clonezilla.cfg +} +menuentry "Power off" { halt } +_EOF_ + + # Prepare custom files used by the installer when booting in BIOS/CSM mode + wget "$DIETPI_REPO"/.meta/images/dietpi-background_480p.png -O tmpiso/syslinux/dietpibg.png || Exit_On_Fail + cp /usr/lib/syslinux/modules/bios/poweroff.c32 tmpiso/syslinux/ + mv tmpiso/syslinux/{syslinux,clonezilla}.cfg + sed -i 's|\(MENU TITLE\) .*|\1 Clonezilla live|' tmpiso/syslinux/clonezilla.cfg + sed '/^label /,/MENU END/d' tmpiso/syslinux/clonezilla.cfg | grep -v '^[ ]*$' > tmpiso/syslinux/syslinux.cfg + sed -i 's|^\(label Clonezilla live\)$|\1 800x600|' tmpiso/syslinux/clonezilla.cfg + sed -n -e '/^label .*800x600/,/append initrd/p' tmpiso/syslinux/clonezilla.cfg >> tmpiso/syslinux/syslinux.cfg + cat << '_EOF_' >> tmpiso/syslinux/syslinux.cfg + TEXT HELP + VGA mode 800x600. OK for most of VGA cards. + ENDTEXT +_EOF_ + sed -n -e '/^label .*HiDPI/,/ENDTEXT/p' -e '/^label .*KMS/,/ENDTEXT/p' -e '/^label .*framebuffer/,/ENDTEXT/p' \ + -e '/^label .*failsafe/,/ENDTEXT/p' tmpiso/syslinux/clonezilla.cfg >> tmpiso/syslinux/syslinux.cfg + sed -i -e 's|^\(timeout\) .*|\1 0|' -e 's|\(MENU BACKGROUND\) .*|\1 dietpibg.png|' -e 's|MENU TITLE .*|MENU TABMSG|' \ + -e '/menu title/d' -e '/^say /d' -e '/MENU MARGIN/ a MENU HSHIFT 80\n MENU COLOR BORDER 0 #00000000 #00000000 none' -e 's|Clonezilla live |Install DietPi |' \ + -e 's|locales= |locales=en_GB.UTF-8 |' -e 's|keyboard-layouts= |keyboard-layouts=gb |' -e 's|ocs-live-general|ocs-live-restore|' \ + -e 's|ocs_live_extra_param=""|ocs_live_extra_param="-icds -k1 -r -e2 -j2 -batch -p poweroff restoredisk ask_user ask_user"|' \ + -e 's|ocs_live_batch="no"|ocs_live_batch="yes"|' tmpiso/syslinux/syslinux.cfg + cat << '_EOF_' >> tmpiso/syslinux/syslinux.cfg +MENU BEGIN Clonezilla live + INCLUDE clonezilla.cfg +MENU END +label Power off + MENU LABEL Power off + COM32 poweroff.c32 + TEXT HELP + Shut down the computer + ENDTEXT +MENU END +_EOF_ + cp tmpiso/syslinux/{syslinux,isolinux}.cfg + + # Generate new ISO file with Clonezilla Live + DietPi image + G_DIETPI-NOTIFY 2 "Generating $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT..." + xorriso -as mkisofs -R -r -J -joliet-long -l -iso-level 3 \ + -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -partition_offset 16 \ + -publisher 'DietPi - Lightweight justice for your SBC; https://dietpi.com;' -volid 'DIETPI_INSTALLER' \ + -A "clonezilla-live-${CLONEZILLA_VERSION}-amd64" \ + -b syslinux/isolinux.bin -c syslinux/boot.cat -no-emul-boot -boot-load-size 4 \ + -boot-info-table -eltorito-alt-boot --efi-boot boot/grub/efi.img -isohybrid-gpt-basdat \ + -isohybrid-apm-hfsplus tmpiso > $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT || Exit_On_Fail + rm -rf tmpiso fi # Generate hashes: MD5, SHA1, SHA256 G_DIETPI-NOTIFY 2 'Generating hashes to pack with image, please wait...' cat << _EOF_ > hash.txt -FILE: $OUTPUT_IMG_NAME +FILE: $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT DATE: $(date) -MD5: $(md5sum $OUTPUT_IMG_NAME | mawk '{print $1}') -SHA1: $(sha1sum $OUTPUT_IMG_NAME | mawk '{print $1}') -SHA256: $(sha256sum $OUTPUT_IMG_NAME | mawk '{print $1}') +MD5: $(md5sum $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT | mawk '{print $1}') +SHA1: $(sha1sum $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT | mawk '{print $1}') +SHA256: $(sha256sum $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT | mawk '{print $1}') _EOF_ # Download current README G_DIETPI-NOTIFY 2 'Downloading current README.md to pack with image...' - wget https://raw.githubusercontent.com/MichaIng/DietPi/master/README.md -O README.md || Exit_On_Fail + wget "$DIETPI_REPO"/README.md -O README.md || Exit_On_Fail # Generate 7z archive # NB: LZMA2 ultra compression method requires 2G RAM - [[ -f $OUTPUT_7Z_NAME ]] && rm $OUTPUT_7Z_NAME + [[ -f $OUTPUT_IMG_NAME.7z ]] && rm $OUTPUT_IMG_NAME.7z G_DIETPI-NOTIFY 2 'Creating final 7zip archive...' - if 7zr a -m0=lzma2 -mx=9 $OUTPUT_7Z_NAME $OUTPUT_IMG_NAME hash.txt README.md; then + if 7zr a -m0=lzma2 -mx=9 $OUTPUT_IMG_NAME.7z $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT hash.txt README.md; then rm hash.txt README.md G_WHIP_MSG "[ OK ] DietPi-Imager has successfully finished.\n -Final image file: /root/$OUTPUT_IMG_NAME -Final 7z archive: /root/$OUTPUT_7Z_NAME" +Final image file: /root/$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT +Final 7z archive: /root/$OUTPUT_IMG_NAME.7z" fi diff --git a/.meta/dietpi-survey_report b/.meta/dietpi-survey_report index 766fa21846..5a060b698c 100644 --- a/.meta/dietpi-survey_report +++ b/.meta/dietpi-survey_report @@ -1,7 +1,7 @@ #!/bin/bash { - # Created by Micha / micha@dietpi.com / dietpi.com + # Created by MichaIng / micha@dietpi.com / dietpi.com #----------------------------------------------------------- # Globals - benchmarks @@ -15,14 +15,14 @@ aHW_NAME[3]='Raspberry Pi 3/3+' aHW_NAME[4]='Raspberry Pi 4' aHW_NAME[10]='Odroid C1' - aHW_NAME[11]='Odroid XU3/XU4/HC1/HC2' + aHW_NAME[11]='Odroid XU3/XU4/HC1/HC2/MC1' aHW_NAME[12]='Odroid C2' aHW_NAME[13]='Odroid U3' aHW_NAME[14]='Odroid N1' aHW_NAME[15]='Odroid N2' - aHW_NAME[20]='VM x64 (VMware VirtualBox)' - aHW_NAME[21]='x86_64 native (PC)' - aHW_NAME[22]='Generic device (eg: unknown to DietPi)' + aHW_NAME[20]='x86_64 VM' + aHW_NAME[21]='x86_64 PC' + aHW_NAME[22]='Generic device' aHW_NAME[30]='OrangePi PC' aHW_NAME[31]='OrangePi One' aHW_NAME[32]='OrangePi Zero (H2+)' @@ -42,12 +42,13 @@ aHW_NAME[51]='BananaPi Pro (Lemaker)' aHW_NAME[52]='Asus Tinker Board' aHW_NAME[53]='BananaPi (sinovoip)' - aHW_NAME[60]='NanoPi Neo' + aHW_NAME[59]='ZeroPi' + aHW_NAME[60]='NanoPi NEO' aHW_NAME[61]='NanoPi M2/T2' - aHW_NAME[62]='NanoPi M3/T3/F3' + aHW_NAME[62]='NanoPi M3/T3/Fire3' aHW_NAME[63]='NanoPi M1/T1' aHW_NAME[64]='NanoPi NEO Air' - aHW_NAME[65]='NanoPi NEO 2' + aHW_NAME[65]='NanoPi NEO2' aHW_NAME[66]='NanoPi M1 Plus' aHW_NAME[67]='NanoPi K1 Plus' aHW_NAME[68]='NanoPC T4' @@ -149,10 +150,10 @@ aAUTOSTART_NAME[3]='RetroPie' aAUTOSTART_NAME[4]='OpenTyrian' aAUTOSTART_NAME[5]='DietPi-Cloudshell' - aAUTOSTART_NAME[6]='AmiBerry fast boot' + aAUTOSTART_NAME[6]='Amiberry fast boot' aAUTOSTART_NAME[7]='Console auto login' - aAUTOSTART_NAME[8]='AmiBerry standard boot' - aAUTOSTART_NAME[9]='DXX-Rebith' + aAUTOSTART_NAME[8]='Amiberry standard boot' + aAUTOSTART_NAME[9]='DXX-Rebirth' aAUTOSTART_NAME[10]='CAVA Spectrum' aAUTOSTART_NAME[11]='Chromium' aAUTOSTART_NAME[14]='Custom' @@ -189,14 +190,14 @@ aSOFTWARE_NAME[25]='XFCE' aSOFTWARE_NAME[26]='GNUStep' aSOFTWARE_NAME[27]='TightVNC Server' - aSOFTWARE_NAME[28]='VNC4 Server' + aSOFTWARE_NAME[28]='TigerVNC Server' aSOFTWARE_NAME[29]='XRDP' aSOFTWARE_NAME[30]='NoMachine' aSOFTWARE_NAME[31]='Kodi' aSOFTWARE_NAME[32]='YMPD' aSOFTWARE_NAME[33]='Airsonic' aSOFTWARE_NAME[34]='Subsonic 6' - aSOFTWARE_NAME[35]='SqueezeBox' + aSOFTWARE_NAME[35]='Logitech Media Server' aSOFTWARE_NAME[36]='SqueezeLite' aSOFTWARE_NAME[37]='Shairport Sync' aSOFTWARE_NAME[38]='FreshRSS' @@ -228,12 +229,12 @@ aSOFTWARE_NAME[64]='PhpSysInfo' aSOFTWARE_NAME[65]='NetData' aSOFTWARE_NAME[66]='RPi-Monitor' - aSOFTWARE_NAME[67]='NoIp' + aSOFTWARE_NAME[67]='No-IP' aSOFTWARE_NAME[68]='Remot3.it' aSOFTWARE_NAME[69]='RPi.GPIO' aSOFTWARE_NAME[70]='WiringPi' aSOFTWARE_NAME[71]='WebIOPi' - aSOFTWARE_NAME[72]='I2c' + aSOFTWARE_NAME[72]='I2C' aSOFTWARE_NAME[73]='Fail2Ban' aSOFTWARE_NAME[74]='InfluxDB' aSOFTWARE_NAME[75]='LASP' @@ -248,7 +249,7 @@ aSOFTWARE_NAME[84]='Lighttpd' aSOFTWARE_NAME[85]='Nginx' aSOFTWARE_NAME[86]='Roon Extension Manager' - aSOFTWARE_NAME[87]='SQlite' + aSOFTWARE_NAME[87]='SQLite' aSOFTWARE_NAME[88]='MariaDB' aSOFTWARE_NAME[89]='PHP' aSOFTWARE_NAME[90]='phpMyAdmin' @@ -259,17 +260,17 @@ aSOFTWARE_NAME[95]='vsFTPD' aSOFTWARE_NAME[96]='Samba Server' aSOFTWARE_NAME[97]='OpenVPN' - aSOFTWARE_NAME[98]='HaProxy' + aSOFTWARE_NAME[98]='HAProxy' aSOFTWARE_NAME[99]='EmonPi' aSOFTWARE_NAME[100]='PiJuice' - aSOFTWARE_NAME[101]='Log Rotate' + aSOFTWARE_NAME[101]='Logrotate' aSOFTWARE_NAME[102]='Rsyslog' aSOFTWARE_NAME[103]='DietPi-RAMlog' aSOFTWARE_NAME[104]='Dropbear' aSOFTWARE_NAME[105]='OpenSSH Server' aSOFTWARE_NAME[106]='Lidarr' aSOFTWARE_NAME[107]='rTorrent' - aSOFTWARE_NAME[108]='AmiBerry' + aSOFTWARE_NAME[108]='Amiberry' aSOFTWARE_NAME[109]='NFS Server' aSOFTWARE_NAME[110]='NFS Client' aSOFTWARE_NAME[111]='UrBackup Server' @@ -283,7 +284,7 @@ aSOFTWARE_NAME[119]='CAVA' aSOFTWARE_NAME[120]='RealVNC Server' aSOFTWARE_NAME[121]='Roon Bridge' - aSOFTWARE_NAME[122]='Node-Red' + aSOFTWARE_NAME[122]='Node-RED' aSOFTWARE_NAME[123]='Mosquitto ' aSOFTWARE_NAME[124]='NAA daemon' aSOFTWARE_NAME[125]='Tomcat8' @@ -370,7 +371,7 @@ done aSOFTWARE_NAME6_20[116]='Medusa' - aSOFTWARE_NAME6_20[170]='Unrar' + aSOFTWARE_NAME6_20[170]='UnRAR' aSOFTWARE_NAME6_20[171]='DietPi-NordVPN' aSOFTWARE_NAME6_20[172]='WireGuard' @@ -410,7 +411,19 @@ aSOFTWARE_NAME6_26[$i]=${aSOFTWARE_NAME6_25[$i]} done - aSOFTWARE_NAME6_26[27]=27 + aSOFTWARE_NAME6_26[27]=27 # TightVNC: Replaced by TigerVNC on Stretch+ + aSOFTWARE_NAME6_26[140]=140 # SDL2: Merged into Amiberry for targeted minimal install + + + # v6.27 + aSOFTWARE_NAME6_27=() + for i in ${!aSOFTWARE_NAME6_26[@]} + do + + aSOFTWARE_NAME6_27[$i]=${aSOFTWARE_NAME6_26[$i]} + + done + aSOFTWARE_NAME6_27[27]='TasmoAdmin' Main(){ @@ -983,7 +996,7 @@ _EOF_ #----------------------------------------------------------- # Main #----------------------------------------------------------- - Main #&> /var/log/dietpi-survey_report.log + Main 2>&1 | tee /var/log/dietpi-survey_report.log #----------------------------------------------------------- exit 0 #----------------------------------------------------------- diff --git a/.meta/images/dietpi-background_480p.png b/.meta/images/dietpi-background_480p.png new file mode 100644 index 0000000000..2f4d8fe595 Binary files /dev/null and b/.meta/images/dietpi-background_480p.png differ diff --git a/.meta/images/dietpi-background.png b/.meta/images/dietpi-background_768p.png similarity index 100% rename from .meta/images/dietpi-background.png rename to .meta/images/dietpi-background_768p.png diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6fbbdb6d36..26d74d2649 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,59 @@ +v6.27 +(XX/12/19) + +Changes / Improvements / Optimisations: +- FriendlyARM ZeroPi | Initial hardware identifier (ID: 59) and support for this device has been added to DietPi. Many thanks to @Stephan for creating the related DietPi image: https://github.com/MichaIng/DietPi/issues/3221 +- RPi4 | Since RPi4, bootloader and USB firmware is stored on an internal EEPROM, which is not updated/flashed by the firmware APT package installs automatically. The additional "rpi-eeprom" package comes with an EEPROM update script and boot service, which will now be installed on DietPi update and firstrun setup automatically, if RPi4 is detected. Those firmware updates include power consumption (hence heat emission) optimisations and enable additional boot methods, currently network boot and USB boot is planned as well. This was reason enough for us to implement it automatically for all RPi4 systems. Additionally you can actively install/update the EEPROM manually via dietpi-config > Advanced Options > Update RPi4 EEPROM firmware. For additional information, read the official docs: https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md Many thanks to @trueaspects for informing us about this important subject: https://github.com/MichaIng/DietPi/issues/3217 +- Virtual Machines | Intel/AMD CPU microcode update packages are not installed/purged from virtual machines. The CPU is provided by the host, hypervisors do not allow to update microcode from within the guest, reasonably, and if they did, this would be serious security and stability issue. +- DietPi-Software | The general network check against first sources.list entry has been replaced by a pure connectivity test and separate DNS resolver test via ping. This solves an issue where sources.list parsing failed when [arch=...] was specified and allows better debugging. The sources list entries themselves are checked and error-handled by G_AGUP already. Ping target IP for connection test and domain for DNS resolver test can be set via dietpi.txt, default is Cloudflare DNS IP and domain which should be very reliable and fast all over the world. Many thanks to @lwqcz for reporting the issue and providing a solution: https://github.com/MichaIng/DietPi/pull/3243 +- DietPi-Software | TasmoAdmin: The administrative website to manage ESP8266 devices flashed with Tasmota for smart home systems is now available for install. Many thanks to @svh1985 for implementing this software title: https://github.com/MichaIng/DietPi/issues/3103 +- DietPi-Software | ownCloud: Enabled install on Buster, Bullseye and ARMv6 RPi models (RPi1+Zero). ownCloud 10.3 has been release with PHP7.3 support, hence it can be used with native distro PHP7.3 and does not require Ondrej's PHP repo which does not support armv6hf. +- DietPi-Software | Syncthing: Enhanced service by security hardenings and to allow internal updates and auto updates without failing to restart. Moved binary from /etc/syncthing to /opt/syncthing to match FHS and disabled file logging, which is an unnecessary overhead, since logs can be easily viewed via "journalctl -u syncthing". Changes will be applied to all installs on v6.27 update, existing configs won't be touched by this. +- DietPi-Software | NAA daemon: Latest version is now scraped from base URL and installed automatically. Many thanks to @Heroldgray for doing this suggestion: https://github.com/MichaIng/DietPi/issues/3191 +- DietPi-Software | Home Assistant: Python3.8 will be installed for the pyenv from now on due to Python3.6 deprecation. Many thanks to @sdomotica for providing this information: https://github.com/MichaIng/DietPi/issues/3219 +- DietPi-Software | Home Assistant: When selecting for install, one will be informed about possibly long install/build times. Many thanks to @Gill-Bates for doing this suggestion to avoid users assuming their install process being stuck: https://github.com/MichaIng/DietPi/issues/2897 +- DietPi-Software | Home Assistant: Vastly reduced Home Assistant dependencies and install complexity. It does not run inside a virtualenv of pyenv anymore, since it has already its unique pyenv Python instance. pyenv is still required due to the large amount of specific module versions, required for HA and its integrations. The alternative would be a venv from a globally installed Python instance, but this requires further thoughts and discussion. The amount of development libraries and tools, installed via APT, has been updated and reduced to a minimum to build Python and Home Assistant inside the pyenv without errors and warnings. There is a slightly increased chance that certain HA components need additional development packages. To cover this, two new settings have been added to dietpi.txt: "SOFTWARE_HOMEASSISTANT_APT_DEPS" and "SOFTWARE_HOMEASSISTANT_PIP_DEPS". Add a space-separated list of APT packages and pip modules respectively, to have those installed automatically with Home Assistant. As well activating the pyenv environment from console is now easier possible via "source /home/homeassistant/pyenv-activate.sh" as user "homeassistant". Additionally "/home/homeassistant/homeassistant-update.sh" has been added, which can be called by any sudo-capable user to update Home Assistant easily. +- DietPi-Software | Node-RED: Access permissions to I2C is now enabled by default on RPi and other SBCs which ship a configured "i2c" group by default. Many thanks to @NastySpill for reporting an underlying issue: https://dietpi.com/phpbb/viewtopic.php?f=11&t=6862 +- DietPi-Software | Gitea: The latest version will now be pulled from GitHub automatically. +- DietPi-Software | Amiberry: Updated to v3.0.4, a large update from v2.25 with many improvements, see: https://github.com/midwan/amiberry/releases +- DietPi-Software | Amiberry: Since we ship a tailored SDL2 version, this has now been merged right into the Amiberry download archive and install directory, to not interfere with other system-wide installed SDL2 instances. + +Bug Fixes: +- DietPi-PREP | Resolved an issue, where in rare cases a wrong $PATH variable could break command calls. Many thanks to @dtm2001 for reporting this issue: https://github.com/MichaIng/DietPi/issues/3206 +- DietPi-Drive_Manager | Resolved an issue where, after transferring the root file system, the script itself could revert the fstab entry, since a reboot was not forced anymore since v6.22. This change has been reverted, hence a reboot cannot be skipped to avoid any fstab revert and inconsistency with cmdline. Many thanks to @DutchFlash for reporting this issue: https://dietpi.com/phpbb/viewtopic.php?f=11&t=6645 +- DietPi-Autostart | Resolved an issue where non-interactive script calls, e.g. done by dietpi-software installs, reset prior made auto login user choices. Many thanks to @zedrdave for reporting this issue: https://github.com/MichaIng/DietPi/issues/3242 +- DietPi-Config | RPi: Resolved an issue where PSU noise reduction state always shows "[Off]". HDMI output will now be toggled immediately, hence no reboot is required for changes to take effect. Many thanks to @maartenlangeveld for reporting this issue: https://github.com/MichaIng/DietPi/issues/3187 +- DietPi-Software | ownCloud/Nextcloud: An important security fix has been applied to our ownCloud/Nextcloud Nginx configs. This has been merged into our other GitHub branches as well, hence all fresh installs wont be affected. Read more about it: https://nextcloud.com/blog/urgent-security-issue-in-nginx-php-fpm/ +- DietPi-Software | WireGuard: Resolved an issue where wg0 server fails to start if network has not yet fully initialised. Many thanks to @Joulinar for reporting this issue: https://github.com/MichaIng/DietPi/issues/3175 +- DietPi-Software | Syncthing: Resolved an issue where fresh install failed to start due to missing permissions. Many thanks to @ralban, @mowestusa and @g7kse for reporting this issue: https://github.com/MichaIng/DietPi/issues/3180 +- DietPi-Software | Gitea: Resolved an issue where fresh Gitea installs failed to start due to missing permissions. Many thanks to @NZRob fore reporting this issue: https://dietpi.com/phpbb/viewtopic.php?f=11&t=6550 +- DietPi-Software | Home Assistant: Resolved on issue where fresh install failed to started to start due to missing permissions. Many thanks to @slopsjon, @tyjtyj and @pakikje for reporting this issue: https://dietpi.com/phpbb/viewtopic.php?f=11&t=6531, https://dietpi.com/phpbb/viewtopic.php?p=20408#p20408 +- DietPi-Software | Google AIY: Resolved an issue where fresh install failed to start due to missing permissions +- DietPi-Software | Grafana: Resolved an issue where install failed on RPi 1/Zero Buster systems. The fix includes an update of Grafana to the latest official version for those models. Many thanks to @TBail for reporting this issue: https://github.com/MichaIng/DietPi/issues/3213 +- DietPi-Software | Jackett: Resolved an issue where the internal updater broke the Jackett instance. Automated updates can be safely enabled again. Many thanks to @ngosang for providing the workaround: https://github.com/MichaIng/DietPi/issues/2593 +- DietPi-Software | Pi-hole: Resolved an issue where choosing to block public admin panel access on Nginx failed. Many thanks to @anubis-genix for reporting this issue: https://github.com/MichaIng/DietPi/issues/3024#issuecomment-550342684 +- DietPi-Software | Java: Resolved an issue where install on ARMv6 RPis (1/Zero) on Buster system failed, since Java 11 is not ARMv6-compatible. On these system, Java 8 is now installed instead. Many thanks to @maartenlangeveld for reporting this issue: https://github.com/MichaIng/DietPi/issues/3182 +- DietPi-Software | ruTorrent: Resolved an issue where rTorrent and the webserver didn't have sufficient permissions to read and write ruTorrent web UI settings and data. Many thanks to @notDavid for reporting this issue: https://github.com/MichaIng/DietPi/issues/3244 +- DietPi-Software | Amiberry: Resolved an issue where the binary fails to execute on Odroid XU4. Many thanks to @wasu111 for reporting this issue: https://github.com/MichaIng/DietPi/issues/3181 + +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 + +Known/Outstanding Issues: +- DietPi-Config | Enabling WiFi + Ethernet adapters, both on different subnets, breaks WiFi connection in some cases: https://github.com/MichaIng/DietPi/issues/2103 +- RPi | On TigerVNC virtual desktop, LXAppearance hangs on dbus-launch: https://github.com/MichaIng/DietPi/issues/1791 +- Odroid C2 | Some WiFi adapters do no work as hotspot: https://github.com/MichaIng/DietPi/issues/1955 +- Odroid XU4 | Kodi freezes shortly on video playback: https://github.com/MichaIng/DietPi/issues/2584 +- Rock64 | 3.5mm A/V jack is currently not functional: https://github.com/MichaIng/DietPi/issues/2522 +- DietPi-Software | Node-RED: Pre-installed modules cannot be updated via web UI: https://github.com/MichaIng/DietPi/issues/2073 +- DietPi-Software | Raspimjpeg: With Lighttpd, streaming mjpeg does not work: https://github.com/MichaIng/DietPi/issues/1747 +- DietPi-Software | MATE desktop: When logging in as root, desktop items and right-clock context menu is missing: https://github.com/MichaIng/DietPi/issues/3160 +- DietPi-Software | Sonarr/Mono: With current Mono version 6, import to a file system without UNIX permissions support (exFAT, FAT32/vfat and NTFS without "permissions" option) fails, regardless of user/umask mount options: https://github.com/MichaIng/DietPi/issues/3179 +- DietPi-Software | Transmission: On Raspbian/Debian Stretch, RAM usage raises unlimited over time: https://github.com/MichaIng/DietPi/issues/2413 + +For all additional issues that may appear after release, please see the following link for active tickets: https://github.com/MichaIng/DietPi/issues + +----------------------------------------------------------------------------------------------------------- + v6.26 (15/10/19) @@ -6,7 +62,7 @@ Changes / Improvements / Optimisations: - General | Initial support and definitions for Debian Bullseye, the new Debian testing version, have been added to DietPi code. You can now create Bullseye systems via DietPi-PREP: https://github.com/MichaIng/DietPi/issues/3009 - General | DietPi scripts, i.e. dietpi-software, will not overwrite you custom permissions in /mnt/dietpi_userdata anymore. Instead required permissions are now only applied for individual software titles that are being installed. Besides saving you time to re-apply custom permission, this as well enhances security in some cases where software installers/archives apply/contain stricter per-file/dir permissions. Many thanks to @JJGO and @johnvick for suggesting this enhancement: https://github.com/MichaIng/DietPi/issues/2641 - General | On first boot, when DietPi-Software finishes the initial setup, it is now assured that all APT packages, including firmware, are upgraded by performing an "apt-get dist-upgrade"/"apt full-upgrade". Since it includes upgrades regardless of underlying dependency and conflict changes, which in rare cases can perform unwanted removals, we do not do this on regualar DietPi-Update/Software runs. But on first boot, without additional packages installed yet, it is safe. Many thanks to @cmessin1 for doing this request: https://github.com/MichaIng/DietPi/issues/3098 -- Rochchip | Experimental GPU acceleration support for RK3399 SoCs and ASUS Tinker Board has been re-enabled. +- Rockchip | Experimental GPU acceleration support for RK3399 SoCs and ASUS Tinker Board has been re-enabled. - RPi | The haveged daemon has been replaced with rng-tools, an alternative which does not work on all devices, but has been proven to work on RPi, is default on Raspbian and uses less RAM on idle. - RPi4 | The default CPU temperature limit (temp_limit) has been raised from 65°C to 75°C, since this device runs significantly hotter then previous RPi model. Many thanks to @trueaspects and @Trunkzeh for doing this suggestion: https://github.com/MichaIng/DietPi/issues/3019, https://github.com/MichaIng/DietPi/issues/3151 - DietPi-Globals | The environment variable $G_USER_INPUTS has been renamed to $G_INTERACTIVE, which describes better what it does. When setting this to "0", DietPi scripts will run non-interactively, i.e. all whiptail dialog prompts and other tasks that require manual user input are skipped. Note that this is not required when running scripts from cron jobs or systemd units, since those have no STDIN attached which makes DietPi scripts run non-interactively automatically. Scripts will stay backwards-compatible, thus respect $G_USER_INPUTS for a while, but please adjust your scripts or docs where you make use of it. Many thanks to @AtkLordOverAll for contributing this change: https://github.com/MichaIng/DietPi/pull/3041 @@ -21,7 +77,7 @@ Changes / Improvements / Optimisations: - DietPi-Config | RPi: Re-added previously removed options to adjust initial turbo for CPU frequency on boot and to lower the idle CPU frequency. The related firmware issues have been fixed with a recent update: https://github.com/MichaIng/DietPi/issues/3147 - DietPi-Config | RPi: Removed the option to adjust CPU frequency limits. On RPi the dynamic CPU governors only jump between "arm_freq" and "arm_freq_min", hence those limits should be set via overclocking profile and the newly re-added "ARM Idle Frequency" option. - DietPi-Config | RPi1/Zero: OpenGL modes/drivers can now be successfully selected/installed from display resolution menu. -- DietPi-Software | TightVPN: Since Stretch, TightVPN has been replaced by TigerVPN, thus the install option has now been removed from code. +- DietPi-Software | TightVNC: Since Stretch, TightVNC has been replaced by TigerVNC, thus the install option has now been removed from code. - DietPi-Software | SDL2: Since we ship a tailored build for Amiberry, the general install option for SDL2 has been removed, instead it will be installed/updated along with Amiberry. If you require SDL2 for any other purpose, please install the "libsdl2-2.0.0" package from APT repository: https://packages.debian.org/libsdl2 - DietPi-Software | Pi-hole: Logging to /var/log/pihole.log is now disabled by default, since it is not required in usual cases. Query logs, shown in web UI, are stored in database. This might also resolve possible pihole-FTL crashes in combination with DietPi-RAMlog and DietPi-Logclear. Many thanks to @kuerious for reporting and @Mcat12 for providing helpful information on this topic: https://github.com/pi-hole/FTL/issues/614 - DietPi-Software | Pi-hole: Webserver configs have been added to block public access to the blocking page, optionally as well to the admin panel and generally block access to dot files/dirs (.git*) inside the admin panel directory. Parts are inspired by the official Lighttpd config, provided by Pi-hole: https://github.com/pi-hole/pi-hole/blob/master/advanced/lighttpd.conf.debian @@ -69,18 +125,6 @@ Bug Fixes: 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/3162 -Known/Outstanding Issues: -- DietPi-Config | Enabling WiFi + Ethernet adapters, both on different subnets, breaks WiFi connection in some cases: https://github.com/MichaIng/DietPi/issues/2103 -- RPi | On TigerVNC virtual desktop, LXAppearance hangs on dbus-launch: https://github.com/MichaIng/DietPi/issues/1791 -- Odroid C2 | Some WiFi adapters do no work as hotspot: https://github.com/MichaIng/DietPi/issues/1955 -- Odroid XU4 | Kodi freezes shortly on video playback: https://github.com/MichaIng/DietPi/issues/2584 -- Rock64 | 3.5mm A/V jack is currently not functional: https://github.com/MichaIng/DietPi/issues/2522 -- DietPi-Software | Node-RED: Pre-installed modules cannot be updated via web UI: https://github.com/MichaIng/DietPi/issues/2073 -- DietPi-Software | Raspimjpeg: With Lighttpd, streaming mjpeg does not work: https://github.com/MichaIng/DietPi/issues/1747 -- DietPi-Software | MATE desktop: When logging in as root, desktop items and right-clock context menu is missing: https://github.com/MichaIng/DietPi/issues/3160 - -For all additional issues that may appear after release, please see the following link for active tickets: https://github.com/MichaIng/DietPi/issues - ----------------------------------------------------------------------------------------------------------- v6.25 diff --git a/PREP_SYSTEM_FOR_DIETPI.sh b/PREP_SYSTEM_FOR_DIETPI.sh index 84f3427e0e..ce546547fa 100644 --- a/PREP_SYSTEM_FOR_DIETPI.sh +++ b/PREP_SYSTEM_FOR_DIETPI.sh @@ -1,15 +1,15 @@ #!/bin/bash { #------------------------------------------------------------------------------------------------ - # Optimize current Debian installation and prep for DietPi installation. + # Optimise current Debian install and prepare for DietPi installation #------------------------------------------------------------------------------------------------ # REQUIREMENTS - # - Currently running Debian (ideally minimal, eg: Raspbian Lite-ish =)) ) + # - Currently running Debian, ideally minimal, eg: Raspbian Lite-ish =)) # - systemd as system/init/service manager - # - Either eth0 connection or local (non-SSH) terminal access + # - Either Ethernet connection or local (non-SSH) terminal access #------------------------------------------------------------------------------------------------ # Dev notes: - # Following items must be exported or assigned to DietPi scripts, if used, until dietpi-obtain_hw_model is executed. + # Following items must be exported or assigned to DietPi scripts, if used, until dietpi-obtain_hw_model is executed: # - G_HW_MODEL # - G_HW_ARCH # - G_DISTRO @@ -29,17 +29,20 @@ G_PROGRAM_NAME='DietPi-PREP' #------------------------------------------------------------------------------------------------ - # Critical checks and pre-reqs, with exit, prior to initial run of script + # Critical checks and requirements to run this script #------------------------------------------------------------------------------------------------ # Exit path for non-root executions if (( $UID )); then - echo -e '[FAILED] Root privileges required, please run the script with "sudo"\nIn case install the "sudo" package with root privileges:\n\t# apt-get install -y sudo\n' + echo -e '[FAILED] Root privileges required, please run this script with "sudo"\nIn case install the "sudo" package with root privileges:\n\t# apt install sudo\n' exit 1 fi - # Work inside /tmp as usually ramfs to reduce disk I/O and speed up download and unpacking + # Set $PATH variable to include all expected default binary locations, since we don't know the current system setup: https://github.com/MichaIng/DietPi/issues/3206 + export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' + + # Work inside /tmp as usually tmpfs to reduce disk I/O and speed up download and unpacking # - Save full script path, beforehand: https://github.com/MichaIng/DietPi/pull/2341#discussion_r241784962 FP_PREP_SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" cd /tmp @@ -51,22 +54,10 @@ # Allow PDiffs on RPi since the "slow implementation" argument is outdated and PDiffs allow lower download size and less disk I/O [[ -f '/etc/apt/apt.conf.d/50raspi' ]] && rm /etc/apt/apt.conf.d/50raspi - # Check/install minimal APT Pre-Reqs - a_MIN_APT_PREREQS=( - - 'apt-transport-https' # Allows HTTPS sources for APT - 'wget' # Download DietPi-Globals... - 'ca-certificates' # ...via HTTPS - 'unzip' # Unzip DietPi code - 'locales' # Allow ensuring en_GB.UTF-8 - 'whiptail' # G_WHIP... - 'ncurses-bin' # ...using tput - - ) - # Removing conflicting /etc/apt/sources.list.d entries # - Meveric: https://github.com/MichaIng/DietPi/issues/1285#issuecomment-355759321 [[ -f '/etc/apt/sources.list.d/deb-multimedia.list' ]] && rm /etc/apt/sources.list.d/deb-multimedia.list + [[ -f '/etc/apt/preferences.d/deb-multimedia-pin-99' ]] && rm /etc/apt/preferences.d/deb-multimedia-pin-99 # - OMV: https://dietpi.com/phpbb/viewtopic.php?f=11&t=2772 [[ -f '/etc/apt/sources.list.d/openmediavault.list' ]] && rm /etc/apt/sources.list.d/openmediavault.list @@ -87,18 +78,31 @@ apt-get clean apt-get update - for i in "${a_MIN_APT_PREREQS[@]}" + + # Check for/Install APT packages required for this script to: + aAPT_PREREQS=( + + 'apt-transport-https' # Allows HTTPS sources for APT (not required since Buster) + 'wget' # Download DietPi-Globals... + 'ca-certificates' # ...via HTTPS + 'unzip' # Unzip DietPi code + 'locales' # Set en_GB.UTF-8 locale + 'whiptail' # G_WHIP + + ) + + for i in "${aAPT_PREREQS[@]}" do - if ! dpkg-query -s $i &> /dev/null && ! apt-get install -y $i; then + if ! dpkg-query -s $i &> /dev/null && ! apt-get -y install $i; then - echo -e "[FAILED] Unable to install $i, please try to install it manually:\n\t # apt-get install -y $i\n" + echo -e "[FAILED] Unable to install $i, please try to install it manually:\n\t # apt install $i\n" exit 1 fi done - unset a_MIN_APT_PREREQS + unset aAPT_PREREQS # Wget: Prefer IPv4 by default to avoid hanging access attempts in some cases # - NB: This needs to match the method in: /DietPi/dietpi/func/dietpi-set_hardware preferipv4 enable @@ -153,7 +157,7 @@ ) - if ! GITBRANCH=$(whiptail --title "$G_PROGRAM_NAME" --menu 'Please select the Git branch the installer should use:' --default-item 'master' --ok-button 'Ok' --cancel-button 'Exit' --backtitle "$G_PROGRAM_NAME" 12 80 3 "${aWHIP_BRANCH[@]}" 3>&1 1>&2 2>&3); then + if ! GITBRANCH=$(whiptail --title "$G_PROGRAM_NAME" --menu 'Please select the Git branch the installer should use:' --default-item 'master' --ok-button 'Ok' --cancel-button 'Exit' --backtitle "$G_PROGRAM_NAME" 12 80 3 "${aWHIP_BRANCH[@]}" 3>&1 1>&2 2>&3-); then echo -e '[ INFO ] No choice detected. Aborting...\n' exit 0 @@ -168,8 +172,8 @@ #------------------------------------------------------------------------------------------------ # DietPi-Globals #------------------------------------------------------------------------------------------------ - # - Download - # - NB: We'll have to manually handle errors, until DietPi-Globals are successfully loaded. + # NB: We have to manually handle errors, until DietPi-Globals are successfully loaded. + # Download if ! wget "https://raw.githubusercontent.com/$GITOWNER/DietPi/$GITBRANCH/dietpi/func/dietpi-globals" -O dietpi-globals; then echo -e '[FAILED] Unable to download dietpi-globals. Aborting...\n' @@ -177,7 +181,7 @@ fi - # - Load + # Load if ! . ./dietpi-globals; then echo -e '[FAILED] Unable to load dietpi-globals. Aborting...\n' @@ -186,15 +190,15 @@ fi rm dietpi-globals - # - Reset G_PROGRAM_NAME, which was set to empty string by sourcing dietpi-globals + # Reset G_PROGRAM_NAME, which was set to empty string by sourcing dietpi-globals G_PROGRAM_NAME='DietPi-PREP' G_INIT - # - Applying Git info + # Apply Git info G_GITOWNER=$GITOWNER; unset GITOWNER G_GITBRANCH=$GITBRANCH; unset GITBRANCH - # - Detect the Debian version of this operating system. + # Detect the Debian version of this operating system if grep -q 'jessie' /etc/os-release; then G_DISTRO=3 @@ -222,7 +226,7 @@ fi - # - Detect the hardware architecture of this operating system. + # Detect the hardware architecture of this operating system G_HW_ARCH_DESCRIPTION=$(uname -m) if [[ $G_HW_ARCH_DESCRIPTION == 'armv6l' ]]; then @@ -255,20 +259,19 @@ #------------------------------------------------------------------------------------------------ echo '' G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' - G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Detecting existing DietPi system:" - ((SETUP_STEP++)) + G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Detecting existing DietPi system"; ((SETUP_STEP++)) G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' #------------------------------------------------------------------------------------------------ if [[ -d '/DietPi/dietpi' || -d '/boot/dietpi' ]]; then - G_DIETPI-NOTIFY 2 'DietPi system found, removing the old files and stopping services. (pre-prep)' + G_DIETPI-NOTIFY 2 'DietPi system found, uninstalling old instance...' - # - Stop services: RAMdisk includes (Pre|Post)Boot due to dependencies + # Stop services: RAMdisk includes (Pre|Post)Boot due to dependencies [[ -f '/DietPi/dietpi/dietpi-services' ]] && /DietPi/dietpi/dietpi-services stop [[ -f '/etc/systemd/system/dietpi-ramlog.service' ]] && systemctl stop dietpi-ramlog [[ -f '/etc/systemd/system/dietpi-ramdisk.service' ]] && systemctl stop dietpi-ramdisk - # - Disable services + # Disable DietPi services for i in /etc/systemd/system/dietpi-* do @@ -278,9 +281,8 @@ done - # - Delete any previous existing data - # Failsafe - umount /DietPi + # Delete any previous existing data + umount /DietPi # Failsafe [[ -d '/DietPi' ]] && rm -R /DietPi rm -Rf /{boot,mnt,etc,var/lib,var/tmp}/dietpi* rm -f /etc/{bashrc,profile,sysctl}.d/dietpi* @@ -290,15 +292,14 @@ else - G_DIETPI-NOTIFY 2 'Non-DietPi system found, skipping pre-prep' + G_DIETPI-NOTIFY 2 'No DietPi system found, skipping old instance uninstall...' fi #------------------------------------------------------------------------------------------------ echo '' G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' - G_DIETPI-NOTIFY 0 "Step $SETUP_STEP Ask user about: Image info / Hardware / WiFi / Distro:" - ((SETUP_STEP++)) + G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Target system inputs"; ((SETUP_STEP++)) G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' #------------------------------------------------------------------------------------------------ @@ -319,7 +320,7 @@ if [[ $G_WHIP_RETURNED_VALUE ]]; then - # Disallowed: + # Disallowed? DISALLOWED_NAME=0 aDISALLOWED_NAMES=( @@ -328,7 +329,6 @@ 'daniel knight' 'dan knight' 'michaing' - 'k-plan' 'diet' ) @@ -364,22 +364,13 @@ G_DIETPI-NOTIFY 2 "Entered image creator: $IMAGE_CREATOR" # Pre-image used/name - if [[ ! $PREIMAGE_INFO ]]; then - - while : - do - - G_WHIP_INPUTBOX 'Please enter the name or URL of the pre-image you installed on this system, prior to running this script. This will be used to identify the pre-image credits.\n\nEG: Debian, Raspbian Lite, Meveric, FriendlyARM, or "forum.odroid.com/viewtopic.php?f=ABC&t=XYZ" etc.\n\nNB: An entry is required.' - if [[ $G_WHIP_RETURNED_VALUE ]]; then - - PREIMAGE_INFO=$G_WHIP_RETURNED_VALUE - break - - fi + until [[ $PREIMAGE_INFO ]] + do - done + G_WHIP_INPUTBOX 'Please enter the name or URL of the pre-image you installed on this system, prior to running this script. This will be used to identify the pre-image credits.\n\nEG: Debian, Raspbian Lite, Meveric, FriendlyARM, or "forum.odroid.com/viewtopic.php?f=ABC&t=XYZ" etc.\n\nNB: An entry is required.' + PREIMAGE_INFO=$G_WHIP_RETURNED_VALUE - fi + done G_DIETPI-NOTIFY 2 "Entered pre-image info: $PREIMAGE_INFO" @@ -394,7 +385,7 @@ '22' ': Generic device (unknown to DietPi)' '' '●─ SBC─(Core devices, with GPU support) ' '12' ': Odroid C2' - '11' ': Odroid XU3/XU4/HC1/HC2' + '11' ': Odroid XU3/XU4/HC1/HC2/MC1' '44' ': Pinebook 1080p' '0' ': Raspberry Pi (All models)' #'1' ': Raspberry Pi 1/Zero (512mb)' @@ -412,13 +403,14 @@ '71' ': Beagle Bone Black' '69' ': Firefly RK3399' '39' ': LeMaker Guitar' + '59' ': ZeroPi' '60' ': NanoPi NEO' - '65' ': NanoPi NEO 2' + '65' ': NanoPi NEO2' '64' ': NanoPi NEO Air' '63' ': NanoPi M1/T1' '66' ': NanoPi M1 Plus' '61' ': NanoPi M2/T2' - '62' ': NanoPi M3/T3/F3' + '62' ': NanoPi M3/T3/Fire3' '68' ': NanoPC T4' '67' ': NanoPi K1 Plus' '10' ': Odroid C1' @@ -458,8 +450,7 @@ fi - G_WHIP_MENU 'Please select the current device this is being installed on:\n - NB: Select "Generic device" if not listed.\n - "Core devices": Are fully supported by DietPi, offering full GPU + Kodi support.\n - "Limited support devices": No GPU support, supported limited to DietPi specific issues only (eg: excludes Kernel/GPU/VPU related items).' - if (( $? )); then + if ! G_WHIP_MENU 'Please select the current device this is being installed on:\n - NB: Select "Generic device" if not listed.\n - "Core devices": Are fully supported by DietPi, offering full GPU + Kodi support.\n - "Limited support devices": No GPU support, supported limited to DietPi specific issues only (eg: excludes Kernel/GPU/VPU related items).'; then G_DIETPI-NOTIFY 1 'No choice detected. Aborting...\n' exit 0 @@ -491,8 +482,7 @@ ) - G_WHIP_DEFAULT_ITEM=1 - (( $G_HW_MODEL == 20 )) && G_WHIP_DEFAULT_ITEM=0 + (( $G_HW_MODEL == 20 )) && G_WHIP_DEFAULT_ITEM=0 || G_WHIP_DEFAULT_ITEM=1 if G_WHIP_MENU 'Please select an option:'; then WIFI_REQUIRED=$G_WHIP_RETURNED_VALUE @@ -518,17 +508,17 @@ ) # - Enable/list available options based on criteria - # NB: Whiptail use 2 array indexs per whip displayed entry. + # NB: Whiptail uses 2 array indices per entry: value + description G_WHIP_MENU_ARRAY=() for ((i=0; i<${#DISTRO_LIST_ARRAY[@]}; i+=2)) do - # - Disable downgrades + # Disable downgrades if (( ${DISTRO_LIST_ARRAY[$i]} < $G_DISTRO )); then - G_DIETPI-NOTIFY 2 "Disabled distro downgrade to: ${DISTRO_LIST_ARRAY[$i+1]}" + G_DIETPI-NOTIFY 2 "Disabled distro downgrade to${DISTRO_LIST_ARRAY[$i+1]%% (*}" - # - Enable option + # Enable option else G_WHIP_MENU_ARRAY+=( "${DISTRO_LIST_ARRAY[$i]}" "${DISTRO_LIST_ARRAY[$i+1]}" ) @@ -540,7 +530,7 @@ if (( ! ${#G_WHIP_MENU_ARRAY[@]} )); then - G_DIETPI-NOTIFY 1 'No available distro versions for this system. Aborting...\n' + G_DIETPI-NOTIFY 1 'No available distro versions found for this system. Aborting...\n' exit 1 fi @@ -562,7 +552,7 @@ G_WHIP_DEFAULT_ITEM=${G_WHIP_MENU_ARRAY[0]} # Downgrades disabled, so first item matches current/lowest supported distro version G_WHIP_BUTTON_CANCEL_TEXT='Exit' if G_WHIP_MENU "Please select a Debian version to install on this system.\n -Currently installed: $G_DISTRO $G_DISTRO_NAME"; then +Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then DISTRO_TARGET=$G_WHIP_RETURNED_VALUE break @@ -600,8 +590,7 @@ Currently installed: $G_DISTRO $G_DISTRO_NAME"; then #------------------------------------------------------------------------------------------------ echo '' G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' - G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Downloading and installing DietPi sourcecode:" - ((SETUP_STEP++)) + G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Downloading and installing DietPi source code"; ((SETUP_STEP++)) G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' #------------------------------------------------------------------------------------------------ @@ -637,9 +626,9 @@ Currently installed: $G_DISTRO $G_DISTRO_NAME"; then G_RUN_CMD mv "DietPi-$G_GITBRANCH/CHANGELOG.txt" /boot/dietpi-CHANGELOG.txt # Reading version string for later use - G_DIETPI_VERSION_CORE=$(sed -n 1p "DietPi-$G_GITBRANCH/dietpi/server_version-6") - G_DIETPI_VERSION_SUB=$(sed -n 2p "DietPi-$G_GITBRANCH/dietpi/server_version-6") - G_DIETPI_VERSION_RC=$(sed -n 3p "DietPi-$G_GITBRANCH/dietpi/server_version-6") + G_DIETPI_VERSION_CORE=$(mawk 'NR==1' "DietPi-$G_GITBRANCH/dietpi/server_version-6") + G_DIETPI_VERSION_SUB=$(mawk 'NR==2' "DietPi-$G_GITBRANCH/dietpi/server_version-6") + G_DIETPI_VERSION_RC=$(mawk 'NR==3' "DietPi-$G_GITBRANCH/dietpi/server_version-6") # Remove server_version* / (pre-)patch_file (downloads fresh from dietpi-update) rm "DietPi-$G_GITBRANCH/dietpi/server_version"* @@ -662,8 +651,7 @@ Currently installed: $G_DISTRO $G_DISTRO_NAME"; then #------------------------------------------------------------------------------------------------ echo '' G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' - G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: APT configuration:" - ((SETUP_STEP++)) + G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: APT configuration"; ((SETUP_STEP++)) G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' #------------------------------------------------------------------------------------------------ @@ -718,7 +706,6 @@ _EOF_ # DietPi list of minimal required packages, which must be installed: aPACKAGES_REQUIRED_INSTALL=( - 'apt-transport-https' # Allows HTTPS sources for ATP 'apt-utils' # Allows "debconf" to pre-configure APT packages for non-interactive install 'bash-completion' # Auto completes a wide list of bash commands and options via 'bc' # Bash calculator, e.g. for floating point calculation @@ -751,12 +738,15 @@ _EOF_ 'usbutils' # "lsusb", used by DietPi-Software + DietPi-Bugreport 'wget' # Download tool 'whiptail' # DietPi dialogs + #'xz-utils' # (.tar).xz wrapper ) # G_DISTRO specific # - Dropbear: DietPi default SSH-Client - # On Buster-, "dropbear" fulls in "dropbear-initramfs", which we don't need + # On Buster-, "dropbear" pulls in "dropbear-initramfs", which we don't need + # - apt-transport-https: Allows HTTPS sources for ATP + # On Buster+, it is included in "apt" package if (( $G_DISTRO > 5 )); then aPACKAGES_REQUIRED_INSTALL+=('dropbear') @@ -764,6 +754,7 @@ _EOF_ else aPACKAGES_REQUIRED_INSTALL+=('dropbear-run') + (( $G_DISTRO < 5 )) && aPACKAGES_REQUIRED_INSTALL+=('apt-transport-https') fi @@ -811,7 +802,7 @@ _EOF_ local efi_packages='grub-efi-amd64' # On Buster+ enable secure boot compatibility: https://packages.debian.org/buster/grub-efi-amd64-signed - (( $DISTRO_TARGET > 4 )) && efi_packages+='grub-efi-amd64-signed shim-signed' + (( $DISTRO_TARGET > 4 )) && efi_packages+=' grub-efi-amd64-signed shim-signed' G_AGI $efi_packages # Grub BIOS @@ -886,7 +877,7 @@ _EOF_ # - Auto detect kernel package incl. ARMbian/others DTB else - AUTO_DETECT_KERN_PKG=$(dpkg --get-selections | mawk '/^linux-(image|dtb)/ {print $1}') + AUTO_DETECT_KERN_PKG=$(dpkg --get-selections | mawk '/^linux-(image|dtb)/{print $1}') if [[ $AUTO_DETECT_KERN_PKG ]]; then G_AGI $AUTO_DETECT_KERN_PKG @@ -958,14 +949,13 @@ _EOF_ #------------------------------------------------------------------------------------------------ echo '' G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' - G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: APT installations:" - ((SETUP_STEP++)) + G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: APT installations"; ((SETUP_STEP++)) G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' #------------------------------------------------------------------------------------------------ G_AGDUG - # - Distro is now target (for APT purposes and G_AGX support due to installed binary, its here, instead of after G_AGUP) + # Distro is now target (for APT purposes and G_AGX support due to installed binary, its here, instead of after G_AGUP) G_DISTRO=$DISTRO_TARGET G_DISTRO_NAME=$DISTRO_TARGET_NAME unset DISTRO_TARGET DISTRO_TARGET_NAME @@ -980,8 +970,7 @@ _EOF_ #------------------------------------------------------------------------------------------------ echo '' G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' - G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Prep system for DietPi ENV:" - ((SETUP_STEP++)) + G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Prep system for DietPi ENV"; ((SETUP_STEP++)) G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' #------------------------------------------------------------------------------------------------ @@ -1036,13 +1025,16 @@ _EOF_ # - Stop, disable and remove not required 3rd party services local aservices=( - # - ARMbian + # ARMbian 'firstrun' 'resize2fs' 'log2ram' 'armbian*' - # - Meveric + 'tinker-bluetooth' + # Meveric 'cpu_governor' + # RPi + 'sshswitch' ) @@ -1055,7 +1047,15 @@ _EOF_ [[ -e $j ]] || continue [[ -f $j ]] && systemctl disable --now ${j##*/} - rm -R $j + # Remove if not attached to any APT package, else mask + if dpkg -S $j &> /dev/null; then + + systemctl mask ${j##*/} + + else + rm -R $j + + fi done @@ -1087,8 +1087,16 @@ _EOF_ # - Meveric specific [[ -f '/usr/local/sbin/setup-odroid' ]] && rm /usr/local/sbin/setup-odroid - # - RPi specific https://github.com/MichaIng/DietPi/issues/1631#issuecomment-373965406 + # - RPi specific: https://github.com/MichaIng/DietPi/issues/1631#issuecomment-373965406 [[ -f '/etc/profile.d/wifi-country.sh' ]] && rm /etc/profile.d/wifi-country.sh + [[ -f '/etc/sudoers.d/010_pi-nopasswd' ]] && rm /etc/sudoers.d/010_pi-nopasswd + [[ -d '/etc/systemd/system/dhcpcd.service.d' ]] && rm -R /etc/systemd/system/dhcpcd.service.d # https://github.com/RPi-Distro/pi-gen/blob/master/stage3/01-tweaks/00-run.sh + # Do not ship rc.local anymore. On DietPi /var/lib/dietpi/postboot.d should be used. + # WIP: Mask rc-local.service and create symlink postboot.d/rc.local => /etc/rc.local for backwards compatibility? + [[ -f '/etc/rc.local' ]] && rm /etc/rc.local # https://github.com/RPi-Distro/pi-gen/blob/master/stage2/01-sys-tweaks/files/rc.local + # Below required if DietPi-PREP is executed from chroot/container, so RPi firstrun scripts are not executed + [[ -f '/etc/init.d/resize2fs_once' ]] && rm /etc/init.d/resize2fs_once # https://github.com/RPi-Distro/pi-gen/blob/master/stage2/01-sys-tweaks/files/resize2fs_once + [[ -f '/boot/cmdline.txt' ]] && sed -i 's| init=/usr/lib/raspi-config/init_resize\.sh||' /boot/cmdline.txt # https://github.com/RPi-Distro/pi-gen/blob/master/stage2/01-sys-tweaks/00-patches/07-resize-init.diff # - make_nas_processes_faster cron job on Rock64 + NanoPi + Pine64(?) images [[ -f '/etc/cron.d/make_nas_processes_faster' ]] && rm /etc/cron.d/make_nas_processes_faster @@ -1106,8 +1114,8 @@ _EOF_ rm -f /etc/profile.d/99-dietpi* # - Enable /etc/bashrc.d/ support for custom interactive non-login shell scripts: - sed -i '\#for i in /etc/bashrc\.d#d' /etc/bash.bashrc - G_CONFIG_INJECT '.*/etc/bashrc\.d/.*' 'for i in /etc/bashrc.d/*.sh /etc/bashrc.d/*.bash; do [ -r "$i" ] && . $i; done' /etc/bash.bashrc + sed -i '\#/etc/bashrc\.d/#d' /etc/bash.bashrc + echo 'for i in /etc/bashrc.d/*.sh /etc/bashrc.d/*.bash; do [ -r "$i" ] && . $i; done; unset i' >> /etc/bash.bashrc # - Enable bash-completion for non-login shells: # - NB: It is called twice on login shells then, but breaks directly if called already once. @@ -1547,22 +1555,6 @@ fdt set /ethernet@$identifier snps,txpbl <0x21>/;q}" /boot/boot.cmd fi - # - Odroids FFmpeg fix for Meveric images. Prefer debian.org over Meveric for backports: https://github.com/MichaIng/DietPi/issues/1273 + https://github.com/MichaIng/DietPi/issues/1556#issuecomment-369463910 - elif [[ $G_HW_MODEL == 1[0-5] ]] && ls /etc/apt/sources.list.d/meveric*.list &> /dev/null; then - - rm -f /etc/apt/preferences.d/meveric* - cat << _EOF_ > /etc/apt/preferences.d/dietpi-meveric-backports -Package: * -Pin: release a=stretch-backports -Pin: origin "fuzon.co.uk" -Pin-Priority: 99 - -Package: * -Pin: release a=stretch-backports -Pin: origin "oph.mdrjr.net" -Pin-Priority: 99 -_EOF_ - fi # - ARMbian increase console verbose @@ -1571,8 +1563,7 @@ _EOF_ #------------------------------------------------------------------------------------------------ echo '' G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' - G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Finalise system for first run of DietPi:" - ((SETUP_STEP++)) + G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Finalise system for first run of DietPi"; ((SETUP_STEP++)) G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' #------------------------------------------------------------------------------------------------ @@ -1768,7 +1759,7 @@ _EOF_ # Plug SDcard/drive into external DietPi system - # Run https://github.com/MichaIng/DietPi/blob/dev/.meta/dietpi-imager + # Run: https://github.com/MichaIng/DietPi/blob/dev/.meta/dietpi-imager } diff --git a/dietpi.txt b/dietpi.txt index 7de7260e56..af25daf41c 100644 --- a/dietpi.txt +++ b/dietpi.txt @@ -153,6 +153,11 @@ CONFIG_G_CHECK_URL_TIMEOUT=5 # Connection attempts with above timeout each, before DietPi G_CHECK_URL is giving up and prompts an error. # - Set this to "0" to disable URL checking completely, however this is not recommended to avoid harder to debug follow-up errors during APT and download attempts. CONFIG_G_CHECK_URL_ATTEMPTS=3 +# General connection and DNS testing +# - IP to ping when checking network connectivity. Default: 1.1.1.1 (Cloudflare DNS, should be very fast world-wide) +CONFIG_CHECK_CONNECTION_IP=1.1.1.1 +# - Domain to ping when checking DNS resolver. Default: one.one.one.one (Cloudflare DNS domain, see above) +CONFIG_CHECK_DNS_DOMAIN=one.one.one.one # DietPi checks for updates: Allows DietPi to check for updates on a daily basis and boot using a <1kb file download. CONFIG_CHECK_DIETPI_UPDATES=1 @@ -200,18 +205,18 @@ CONFIG_NTP_MIRROR=debian.pool.ntp.org # - Eg: SOFTWARE_EMONHUB_APIKEY=b4dfmk2o203mmxx93a SOFTWARE_EMONHUB_APIKEY= -# VNC Server options +# VNC Server SOFTWARE_VNCSERVER_WIDTH=1280 SOFTWARE_VNCSERVER_HEIGHT=720 SOFTWARE_VNCSERVER_DEPTH=16 SOFTWARE_VNCSERVER_DISPLAY_INDEX=1 SOFTWARE_VNCSERVER_SHARE_DESKTOP=0 -# Optional username for ownCloud/Nextcloud admin account, the default is 'admin'. Applied during install. +# ownCloud/Nextcloud +# - Optional username for admin account, the default is 'admin', applied during install SOFTWARE_OWNCLOUD_NEXTCLOUD_USERNAME=admin - -# Optional data directory for ownCloud/Nextcloud, default is '/mnt/dietpi_userdata/owncloud_data' respectively '/mnt/dietpi_userdata/nextcloud_data'. Applied during install. -# - This option is for advanced users. For full compatibility, please keep this options defaults, and, use dietpi-drive_manager to move the DietPi user data location. +# - Optional data directory, default is "/mnt/dietpi_userdata/owncloud_data" respectively "/mnt/dietpi_userdata/nextcloud_data", applied during install +# NB: This option is for advanced users. For full compatibility, please keep this options defaults, and, use dietpi-drive_manager to move the DietPi user data location. SOFTWARE_OWNCLOUD_DATADIR=/mnt/dietpi_userdata/owncloud_data SOFTWARE_NEXTCLOUD_DATADIR=/mnt/dietpi_userdata/nextcloud_data @@ -221,15 +226,22 @@ SOFTWARE_WIFI_HOTSPOT_SSID=DietPi-HotSpot SOFTWARE_WIFI_HOTSPOT_KEY=dietpihotspot SOFTWARE_WIFI_HOTSPOT_CHANNEL=3 -# X.org options +# X.org # - DPI 96(default) 120(+25%) 144(+50%) 168(+75%) 192(+100%) SOFTWARE_XORG_DPI=96 -# Chromium options +# Chromium SOFTWARE_CHROMIUM_RES_X=1280 SOFTWARE_CHROMIUM_RES_Y=720 SOFTWARE_CHROMIUM_AUTOSTART_URL=https://dietpi.com +# Home Assistant +# - Optional Python build dependencies and modules, possibly required for certain HA components +# Space separated list (no quotation!), will be installed together with Home Assistant automatically, if present +SOFTWARE_HOMEASSISTANT_APT_DEPS= +# Add Python modules with version string at best, e.g.: firstModule==1.2.3 secondModule==4.5.6 +SOFTWARE_HOMEASSISTANT_PIP_DEPS= + #------------------------------------------------------------------------------------------------------ # D I E T - P I # Dev settings diff --git a/dietpi/boot b/dietpi/boot index fcb1a56512..f999fd85b5 100644 --- a/dietpi/boot +++ b/dietpi/boot @@ -26,9 +26,9 @@ Wait_For_Valid_Network_Connection(){ # Wait mode, max time - local boot_wait_for_network=$(grep -m1 '^[[:blank:]]*CONFIG_BOOT_WAIT_FOR_NETWORK=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + local boot_wait_for_network=$(sed -n '/^[[:blank:]]*CONFIG_BOOT_WAIT_FOR_NETWORK=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) local max_loops=-1 - (( $boot_wait_for_network )) && max_loops=10 + (( ${boot_wait_for_network:=1} )) && max_loops=10 local loop_count=0 while (( $loop_count <= $max_loops )) @@ -36,7 +36,7 @@ G_DIETPI-NOTIFY 2 "$(date) | Waiting for valid network connection before continuing boot | Mode=$boot_wait_for_network" - if [[ $(ip r) =~ ' via ' ]]; then + if ip r s default &> /dev/null; then G_DIETPI-NOTIFY 0 "$(date) | Valid network connection found" break @@ -59,27 +59,25 @@ #---------------------------------------------------------------- # WiFi Country | Additional fallback for (older kernel?) devices that fail with wpa_supplicant.conf https://github.com/MichaIng/DietPi/issues/838 - command -v iw &> /dev/null && iw reg set "$(grep -m1 '^[[:blank:]]*CONFIG_WIFI_COUNTRY_CODE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')" & + command -v iw &> /dev/null && iw reg set "$(sed -n '/^[[:blank:]]*CONFIG_WIFI_COUNTRY_CODE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt)" & #---------------------------------------------------------------- # Network failure workarounds - # - Failsafe, bring up interfaces, if somehow not done by networking.service. If those are up already, nothing will happen. - if grep -qiE '^[[:blank:]]*(allow-hotplug|auto)[[:blank:]]+wlan' /etc/network/interfaces; then + # - Failsafe: Bring up network interfaces, since networking.service does not include "allow-hotplug". + # - ifup@.service is triggered by udev for those, but Type=simple, hence targets don't need to wait for it to finish: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=791920 + if grep -qE '^[[:blank:]]*(allow-hotplug|auto)[[:blank:]]+wlan' /etc/network/interfaces; then - local wlan_index=$(sed -n 2p /DietPi/dietpi/.network) + local wlan_index=$(mawk 'NR==2' /DietPi/dietpi/.network) disable_error=1 G_CHECK_VALIDINT "$wlan_index" 0 || wlan_index=0 - # - Workaround: WLAN currently fails to connect during boot, so, manually drop and reconnect: https://github.com/MichaIng/DietPi/issues/602#issuecomment-262806470 - # OPi Zero 2 / Neo Air + # OPi Zero 2 / Neo Air: WLAN currently fails to connect during boot, so, manually drop and reconnect: https://github.com/MichaIng/DietPi/issues/602#issuecomment-262806470 (( $G_HW_MODEL == 35 || $G_HW_MODEL == 64 )) && ifdown wlan$wlan_index 2> /dev/null - - ifup wlan$wlan_index &> /dev/null & + ifup wlan$wlan_index 2> /dev/null & fi + if grep -qE '^[[:blank:]]*(allow-hotplug|auto)[[:blank:]]+eth' /etc/network/interfaces; then - if grep -qiE '^[[:blank:]]*(allow-hotplug|auto)[[:blank:]]+eth' /etc/network/interfaces; then - - local eth_index=$(sed -n 1p /DietPi/dietpi/.network) + local eth_index=$(mawk 'NR==1' /DietPi/dietpi/.network) disable_error=1 G_CHECK_VALIDINT "$eth_index" 0 || eth_index=0 - ifup eth$eth_index &> /dev/null & + ifup eth$eth_index 2> /dev/null & fi #---------------------------------------------------------------- @@ -88,9 +86,6 @@ # Grab IP data /DietPi/dietpi/func/obtain_network_details #---------------------------------------------------------------- - # Remount all drives (eg: network shares) - mount -a - #---------------------------------------------------------------- # Lower dmesg print level (mostly for Odroid C2 where HiFi Shield prints info when starting/stopping stream on tty1) dmesg -n 1 #---------------------------------------------------------------- @@ -111,12 +106,11 @@ swap_size=$(sed -n '/^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) disable_error=1 G_CHECK_VALIDINT "$swap_size" 0 || swap_size=1 swap_location=$(sed -n '/^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) - [[ $swap_location ]] || swap_location='/var/swap' + [[ $swap_location == '/'* ]] || swap_location='/var/swap' /DietPi/dietpi/func/dietpi-set_swapfile $swap_size "$swap_location" # Run survey - [[ -f '/DietPi/dietpi/.dietpi-survey' ]] && rm /DietPi/dietpi/.dietpi-survey - /DietPi/dietpi/dietpi-survey 1 &> /dev/null & + /DietPi/dietpi/dietpi-survey 1 & # Continue with normal boot G_DIETPI_INSTALL_STAGE=2 @@ -126,7 +120,7 @@ #---------------------------------------------------------------- # Normal boot # - Run time sync - (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/func/run_ntpd 1 &> /dev/null & + (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/func/run_ntpd 1 & #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- diff --git a/dietpi/dietpi-autostart b/dietpi/dietpi-autostart index 92a23f5501..a20f25819a 100644 --- a/dietpi/dietpi-autostart +++ b/dietpi/dietpi-autostart @@ -92,11 +92,11 @@ _EOF_ systemctl enable amiberry - # - Enable systemd-logind to have a login console ready after exiting AmiBerry from fastboot + # Enable systemd-logind to have a login console ready after exiting Amiberry from fastboot systemctl unmask systemd-logind systemctl enable systemd-logind &> /dev/null - # - Apply tweaks + # Apply tweaks if (( $G_HW_MODEL < 10 )); then G_CONFIG_INJECT 'boot_delay=' 'boot_delay=0' /DietPi/config.txt @@ -109,25 +109,25 @@ _EOF_ # - Enable autologin elif (( $AUTO_START_INDEX > 0 )); then - # - Autologin user, only ask in interactive mode and skip for LightDM, which must be started as root - local user=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_AUTOSTART_LOGIN_USER=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + # Autologin user, only ask in interactive mode and skip for LightDM, which must be started as root + local user=$(sed -n '/^[[:blank:]]*AUTO_SETUP_AUTOSTART_LOGIN_USER=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) if (( $AUTO_START_INDEX == 16 )); then - # - LightDM pre-req check, but install only if xinit (a desktop) is already installed. This is re-applied by dietpi-software after install automatically. + # LightDM pre-req check, but install only if xinit (a desktop) is already installed. This is re-applied by dietpi-software after install automatically. command -v startx &> /dev/null && G_AG_CHECK_INSTALL_PREREQ lightdm user='root' elif (( $INPUT == -1 )); then - # - Only users with ID >= 1000 (+ root) and with valid login shell - G_WHIP_MENU_ARRAY=( 'root' 'UID:0' $(mawk -F: '$3 >= 1000 && $7 ~ /^\/bin\/.*sh$/ {print $1" UID:"$3}' /etc/passwd) ) + # Only users with ID >= 1000 (+ root) and with valid login shell + G_WHIP_MENU_ARRAY=('root' 'UID:0' $(mawk -F: '$3 >= 1000 && $7 ~ /^\/bin\/.*sh$/ {print $1" UID:"$3}' /etc/passwd)) G_WHIP_DEFAULT_ITEM=$user G_WHIP_MENU "Please choose a user to login with. NB: You might need to grant the user permissions to run the chosen autostart option.\n\nCurrent choice: $user" && user=$G_WHIP_RETURNED_VALUE fi - # - Sanity check + # Sanity check if ! grep -qE "^$user:[^:]*:(0|[1-9][0-9][0-9][0-9]+):.*:/bin/[^:]*sh$" /etc/passwd; then G_DIETPI-NOTIFY 1 "User \"$user\" does not exist, is a system user or does not have a valid login shell. Reverting to \"root\"." @@ -135,6 +135,10 @@ NB: You might need to grant the user permissions to run the chosen autostart opt fi + # Apply user choice to dietpi.txt + G_CONFIG_INJECT 'AUTO_SETUP_AUTOSTART_LOGIN_USER=' "AUTO_SETUP_AUTOSTART_LOGIN_USER=$user" /DietPi/dietpi.txt + + # Apply to TTY1 getty mkdir -p /etc/systemd/system/getty@tty1.service.d cat << _EOF_ > /etc/systemd/system/getty@tty1.service.d/dietpi-autologin.conf [Service] @@ -178,7 +182,7 @@ _EOF_ '6' ': Amiberry fast boot' '8' ': Amiberry standard boot' '3' ': RetroPie' - '9' ': DXX-Rebith - Descent 1/2' + '9' ': DXX-Rebirth - Descent 1/2' '4' ': OpenTyrian' '' '●─ Other ' '14' ': Custom - /var/lib/dietpi/dietpi-autostart/custom.sh' @@ -202,9 +206,9 @@ This mode allows for a < 2.5 second boot on an RPi3, into Amiberry.\n\nIf you ex # Chromium prompt for URL elif (( $AUTO_START_INDEX == 11 )); then - G_WHIP_DEFAULT_ITEM=$(grep -m1 '^[[:blank:]]*SOFTWARE_CHROMIUM_AUTOSTART_URL=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') - G_WHIP_INPUTBOX 'Please enter a homepage URL to start with Chromium:\n - eg: https://dietpi.com' - (( $? == 0 )) && G_CONFIG_INJECT 'SOFTWARE_CHROMIUM_AUTOSTART_URL=' "SOFTWARE_CHROMIUM_AUTOSTART_URL=$G_WHIP_RETURNED_VALUE" /DietPi/dietpi.txt + G_WHIP_DEFAULT_ITEM=$(sed -n '/^[[:blank:]]*SOFTWARE_CHROMIUM_AUTOSTART_URL=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + G_WHIP_INPUTBOX 'Please enter a homepage URL to start with Chromium: + - E.g.: https://dietpi.com' && G_CONFIG_INJECT 'SOFTWARE_CHROMIUM_AUTOSTART_URL=' "SOFTWARE_CHROMIUM_AUTOSTART_URL=$G_WHIP_RETURNED_VALUE" /DietPi/dietpi.txt # Custom info elif (( $AUTO_START_INDEX == 14 )); then diff --git a/dietpi/dietpi-bugreport b/dietpi/dietpi-bugreport index 45453a0e10..bb36083b1a 100644 --- a/dietpi/dietpi-bugreport +++ b/dietpi/dietpi-bugreport @@ -243,7 +243,7 @@ Would you like to send a bug report archive or remove an already uploaded one?'; elif (( $G_WHIP_RETURNED_VALUE == 3 )); then - G_WHIP_SCROLLBOX "The upload will contain the following command outputs:\n + G_WHIP_MSG "The upload will contain the following command outputs:\n $(printf "\t- %s\n" "${aCOMMAND_LIST[@]}")\n It will contain as well the following files and directories:\n $(printf "\t- %s\n" "${aFILE_LIST[@]}")" diff --git a/dietpi/dietpi-cloudshell b/dietpi/dietpi-cloudshell index f9e38a61d7..72c6d07ebd 100644 --- a/dietpi/dietpi-cloudshell +++ b/dietpi/dietpi-cloudshell @@ -12,7 +12,7 @@ # - System Stats for Cloudshell (or monitor/terminal) # # Usage: - # dietpi-cloudshell = Config Menu + # dietpi-cloudshell = Config Menu # dietpi-cloudshell 1 = Run # dietpi-cloudshell 2 = Run + Skip intro #//////////////////////////////////// @@ -26,8 +26,7 @@ # Import DietPi-Globals -------------------------------------------------------------- # Grab Input (valid interger) - INPUT=0 - disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1 + disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1 || INPUT=0 # Version DIETPI_CLOUDSHELL_VERSION=9 @@ -166,13 +165,13 @@ Init_Term_Options(){ - # - Set large font 1st (480x320+) + # Set large font 1st (480x320+) setfont /usr/share/consolefonts/Uni3-TerminusBold32x16 - # - set small font if insufficent number of lines (320x240) + # Reduce font size if less than 10 lines available now (320x240) (( $(tput lines) < 10 )) && setfont /usr/share/consolefonts/Uni3-TerminusBold24x12.psf - #Disable screen blanking on tty1 initially + # Disable screen blanking on tty1 initially Disable_Screen_Blanking } diff --git a/dietpi/dietpi-config b/dietpi/dietpi-config index 95082f1c7a..688cdf56ca 100644 --- a/dietpi/dietpi-config +++ b/dietpi/dietpi-config @@ -1316,8 +1316,25 @@ NB: You now need to run "apt update" or "G_AGUP" once after each reboot, before fi - # Hide firmware update on RPi. This is done automatically with simple apt upgrade since raspberrypi-kernel it is no meta-package. + # Hide firmware update on RPi. This is done automatically with simple apt upgrade since raspberrypi-kernel is no meta-package. (( $G_HW_MODEL > 9 )) && G_WHIP_MENU_ARRAY+=('Update firmware' ": [Linux $(uname -r)]") + # RPi4 EEPROM update: https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md + if (( $G_HW_MODEL == 4 )); then + + if dpkg -s 'rpi-eeprom' &> /dev/null; then + + rpi-eeprom-update -m version_eeprom + . ./version_eeprom + rm version_eeprom + G_WHIP_MENU_ARRAY+=('Update RPi4 EEPROM firmware' ": [Bootloader: ${BOOTLOADER_CURRENT:-N/A} | VL805: ${VL805_CURRENT:-N/A}]") + + else + + G_WHIP_MENU_ARRAY+=('Update RPi4 EEPROM firmware' ': Install rpi-eeprom APT package') + + fi + + fi # Serial/UART devices G_WHIP_MENU_ARRAY+=('Serial/UART' ': Manage available devices') @@ -1474,6 +1491,14 @@ Please choose whether your device have an active RTC or requires "fake-hwclock": # Reboot required only, if firmware got actually updated [[ $old_firmware != $(ls /lib/modules/) ]] && REBOOT_REQUIRED=1 + elif [[ $G_WHIP_RETURNED_VALUE == 'Update RPi4 EEPROM firmware' ]]; then + + G_WHIP_YESNO '[ INFO ] EEPROM firmware update +\nThis will, if required, install or upgrade the rpi-eeprom APT package and update bootloader and VL805 USB firmware on the RPi4 EEPROM. +Further information: https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md +\nDo you want to continue?' || return + /DietPi/dietpi/func/dietpi-set_hardware rpi-eeprom + elif [[ $G_WHIP_RETURNED_VALUE == 'Max USB current' ]]; then if (( $rpi_max_usb_current_enabled )); then @@ -1914,7 +1939,7 @@ Current setting: $user_frequency_min_text" && G_CONFIG_INJECT 'CONFIG_CPU_MIN_FR 'ARM Initial Turbo') MIN_VALUE=1 - MAX_VALUE=100 + MAX_VALUE=60 G_WHIP_DEFAULT_ITEM=$initial_turbo if G_WHIP_INPUTBOX "Amount of seconds on boot, where the CPU runs at highest clock, before it starts to respect the CPU governor. This reduces boot time quite much since RPi boots with powersave governor until the chosen one is applied at later boot stage. - Recommended value: 20\n - Valid range: $MIN_VALUE - $MAX_VALUE\n - Setting a value outside of range will disable this feature."; then @@ -3937,14 +3962,13 @@ Additional benchmarks: G_WHIP_MENU_ARRAY=('Soundcard' ": [$soundcard_current]") G_WHIP_MENU_ARRAY+=('DietPi-JustBoom' ': Launches EQ and MPD audio options menu') - # - RPi, low power mode (PSU noise ripple reduction): https://github.com/MichaIng/DietPi/issues/757 + # RPi, low power mode (PSU noise ripple reduction): https://github.com/MichaIng/DietPi/issues/757 if (( $G_HW_MODEL < 10 )); then local psu_noise_reduction_enabled=0 local psu_noise_reduction_text='Off' if grep -q '^[[:blank:]]*CONFIG_CPU_GOVERNOR=powersave' /DietPi/dietpi.txt && - grep -q '^[[:blank:]]*hdmi_ignore_hotplug=1' /DietPi/config.txt && - grep -q '^[[:blank:]]*hdmi_ignore_composite=1' /DietPi/config.txt; then + grep -q '^[[:blank:]]*AUTO_SETUP_HEADLESS=1' /DietPi/dietpi.txt; then psu_noise_reduction_enabled=1 psu_noise_reduction_text='On' @@ -3980,22 +4004,22 @@ Additional benchmarks: if (( ! $psu_noise_reduction_enabled )); then G_WHIP_YESNO 'PSU noise reduction:\n\nThis mode attempts to reduce power consumption on your SBC. In turn, this may reduce PSU inflicted noise, that may degrade audio output quality.\n -The following will now be applied:\n - CPU gov = Powersave\n - HDMI output = Disabled\n\nDo you want to continue?' || return +The following will now be applied:\n - CPU governor = Powersave\n - Display output = Disabled\n\nDo you want to continue?' || return G_CONFIG_INJECT 'CONFIG_CPU_GOVERNOR=' 'CONFIG_CPU_GOVERNOR=powersave' /DietPi/dietpi.txt /DietPi/dietpi/func/dietpi-set_cpu /DietPi/dietpi/func/dietpi-set_hardware headless 1 + tvservice -o else G_CONFIG_INJECT 'CONFIG_CPU_GOVERNOR=' 'CONFIG_CPU_GOVERNOR=ondemand' /DietPi/dietpi.txt /DietPi/dietpi/func/dietpi-set_cpu /DietPi/dietpi/func/dietpi-set_hardware headless 0 + tvservice -p fi - REBOOT_REQUIRED=1 - elif [[ $G_WHIP_RETURNED_VALUE == 'Soundcard' ]]; then G_WHIP_MENU_ARRAY=() @@ -4290,7 +4314,7 @@ The following will now be applied:\n - CPU gov = Powersave\n - HDMI output = Dis noip_menutext='[Offline] Enter/Setup No-IP details' # Check if No-IP is running (indicates login details are valid) - pgrep '/usr/local/bin/noip2' &> /dev/null && noip_menutext='[Online] Change No-IP details' + pgrep 'noip2' &> /dev/null && noip_menutext='[Online] Change No-IP details' fi diff --git a/dietpi/dietpi-drive_manager b/dietpi/dietpi-drive_manager index 8b8787cda3..a91ba88342 100644 --- a/dietpi/dietpi-drive_manager +++ b/dietpi/dietpi-drive_manager @@ -127,8 +127,8 @@ local var_log_size=$(sed -n '/^[[:blank:]]*AUTO_SETUP_RAMLOG_MAXSIZE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) tmpfs_mounts="tmpfs /tmp tmpfs noatime,lazytime,nodev,nosuid,mode=1777 -tmpfs /DietPi tmpfs size=10m,noatime,lazytime,nodev,nosuid,mode=1755 -tmpfs /var/log tmpfs size=${var_log_size}m,noatime,lazytime,nodev,nosuid,mode=1777" +tmpfs /DietPi tmpfs size=10M,noatime,lazytime,nodev,nosuid,mode=1755 +tmpfs /var/log tmpfs size=${var_log_size:-50}M,noatime,lazytime,nodev,nosuid,mode=1777" # Else: Grab current mounts else @@ -281,11 +281,11 @@ $swap_mounts # On RPi we need to use PARTUUID for Root/BootFS (( $G_HW_MODEL < 10 )) && dev_entry="PARTUUID=${aDRIVE_PART_UUID[$index]}" - options+=' 0 1' # dump + fsck flag + [[ ${aDRIVE_MOUNT_TARGET[$index]} == '/' ]] && options+=' 0 1' || options+=' 0 2' # dump + fsck flag else - options+=',nofail,x-systemd.automount' + options+=',nofail,noauto,x-systemd.automount' fi @@ -293,7 +293,7 @@ $swap_mounts local type=${aDRIVE_FSTYPE[$index]} (( ${aDRIVE_ISNETWORKED[$index]} )) && type='auto' - echo "$dev_entry ${aDRIVE_MOUNT_TARGET[$index]} $type noatime,lazytime$options" >> $fp_fstab_tmp + echo "$dev_entry ${aDRIVE_MOUNT_TARGET[$index]} ${type:-auto} noatime,lazytime$options" >> $fp_fstab_tmp fi @@ -332,7 +332,11 @@ $swap_mounts aDRIVE_FSTYPE[$index]=$(blkid ${aDRIVE_MOUNT_SOURCE[$index]} -s TYPE -o value) [[ ${aDRIVE_FSTYPE[$index]} ]] && aDRIVE_ISFILESYSTEM[$index]=1 - echo "#UUID=${aDRIVE_UUID[$index]} ${aDRIVE_MOUNT_TARGET[$index]} auto defaults,noatime,rw,nofail,x-systemd.automount 0 0" >> $fp_fstab_tmp + # FS type: In case of unknown network drive, use "auto", to allow remove FS changes without breaking the fstab entry + local type=${aDRIVE_FSTYPE[$index]} + (( ${aDRIVE_ISNETWORKED[$index]} )) && type='auto' + + echo "#UUID=${aDRIVE_UUID[$index]} ${aDRIVE_MOUNT_TARGET[$index]} ${type:-auto} noatime,lazytime,nofail,noauto,x-systemd.automount" >> $fp_fstab_tmp done < .blkid_out_tmp rm .blkid_out_tmp @@ -421,8 +425,8 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]} # Remove x-systemd.automount if not supported by kernel: https://github.com/MichaIng/DietPi/issues/1607#issuecomment-372030565 if ! modprobe autofs4 --dry-run &> /dev/null; then - sed -i 's/,x-systemd.automount//g' $fp_fstab_tmp - G_DIETPI-NOTIFY 2 'autofs4 module not available in kernel, x-systemd.automount has been disabled' + sed -Ei '/x-systemd\.automount/s/,(noauto|x-systemd\.automount)//g' $fp_fstab_tmp + G_DIETPI-NOTIFY 2 'autofs4 module not available in kernel, x-systemd.automount has been disabled, all drives will be mounted at boot instead' fi @@ -775,7 +779,7 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return sed -i "s#$rootfstype_current#rootfstype=${aDRIVE_FSTYPE[$MENU_DRIVE_INDEX]}#g" /boot/cmdline.txt # C2/XU4 | /DietPi/boot.ini - elif (( $G_HW_MODEL == 11 || $G_HW_MODEL == 12 )); then + elif [[ $G_HW_MODEL == 1[12] ]]; then # Find current root= to replace local rootfs_current=$(mawk '{for(i=1;i<=NF;i++) {print $i} }' /DietPi/boot.ini | grep -m1 'root=' | sed 's/\"//') @@ -786,7 +790,8 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return systemctl daemon-reload sync - G_WHIP_YESNO 'RootFS transfer completed. A reboot is required for this to take affect.\n\nWould you like to reboot the system now?' && reboot + G_WHIP_MSG 'RootFS transfer has successfully completed.\n\nA reboot is required, please press to reboot now.' + reboot } @@ -1104,7 +1109,7 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return # Swapfile # - NB: / rootfs will always be detected in this check, however, no rootFS options for umount and format... - local swapfile_size=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + local swapfile_size=$(sed -n '/^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) if (( $swapfile_size > 0 )) && { [[ $FP_SWAPFILE_CURRENT == ${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]}* && ${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]} != '/' ]] || [[ $FP_SWAPFILE_CURRENT == '/var/swap' && ${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]} == '/' ]]; }; then @@ -1229,7 +1234,7 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return elif [[ $G_WHIP_RETURNED_VALUE == 'Unmount' || $G_WHIP_RETURNED_VALUE == 'Remove' ]]; then - # - Disallow if userdata is located on this drive! + # Disallow if userdata is located on this drive! if (( $partition_contains_userdata )); then Notification 0 @@ -1387,13 +1392,15 @@ We recommend \"ext4\" as filesystem type for the RootFS." else - if G_WHIP_YESNO "This process will move RootFS data to another location. This may increase filesystem performance when using a USB drive over SD card, however, there are some limitations: -\n - The SD/EMMC card is still required for the boot process -\nNB: As this feature is still in testing, we recommend you use this feature on a fresh installation only.\n\nDo you wish to continue?"; then + if G_WHIP_YESNO 'This process will move the root filesystem data to another location. This may increase R/W performance when using a USB drive over SDcard, however, there are some limitations: +\n - The SD/eMMC card, which holds kernel and bootloader, is still required for the boot process. On RPi3, which supports full USB boot, instead it is recommended to flash the whole DietPi image to a USB drive and boot the system without SDcard. +\n - Custom software installs might use info of the old root mount/filesystem, hence we recommend to move the root file system on fresh DietPi systems only. +\n - An immediate reboot is done after the transfer has successfully finished to assure that fstab and cmdline cannot be reverted. +\nDo you wish to continue?'; then G_WHIP_MSG 'On the next screen, you will be asked to format the target partition. \nPlease see the following recommendations for RootFS target filesystem type: -\n - Odroid\nRootFS transfer supports ONLY EXT4 format\n\n - RPi\nRootFS transfer supports EXT4, BTRFS and F2FS' +\n - Odroid: RootFS transfer supports ONLY EXT4 format\n\n - RPi: RootFS transfer supports EXT4, BTRFS and F2FS' # NB: We dont enter main loop in this func TARGETMENUID=2 @@ -1605,7 +1612,7 @@ Read more about I/O scheduling: https://wiki.archlinux.org/index.php/Improving_p elif (( $FORMAT_FILESYSTEM_TYPE == 6 )); then - format_type_text='EXFAT' + format_type_text='exFAT' fi @@ -1782,11 +1789,11 @@ NTFS:\nRecommended if you plan to use this drive on a Windows system. High CPU u do G_DIETPI-NOTIFY 2 "Attempting to mount with CIFS version: $i" - if mount -t cifs -o username="$samba_clientuser",password="$samba_clientpassword",uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=$i //"$samba_clientname"/"$samba_clientshare" "$samba_fp_mount_target" &>> $fp_tmp; then + if mount -t cifs -o username="$samba_clientuser",password="$samba_clientpassword",iocharset=utf8,uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=$i //"$samba_clientname"/"$samba_clientshare" "$samba_fp_mount_target" &>> $fp_tmp; then # Apply to fstab sed -i "\#[[:space:]]$samba_fp_mount_target[[:space:]]#d" /etc/fstab - echo "//$samba_clientname/$samba_clientshare $samba_fp_mount_target cifs username=$samba_clientuser,password=$samba_clientpassword,iocharset=utf8,uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=$i,_netdev,nofail" >> /etc/fstab + echo "//$samba_clientname/$samba_clientshare $samba_fp_mount_target cifs username=$samba_clientuser,password=$samba_clientpassword,iocharset=utf8,uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=$i,_netdev,nofail,noauto,x-systemd.automount" >> /etc/fstab MENU_DRIVE_TARGET=$samba_fp_mount_target Init_Drives_and_Refresh @@ -1871,7 +1878,7 @@ NTFS:\nRecommended if you plan to use this drive on a Windows system. High CPU u # Apply to fstab sed -i "\#[[:space:]]$nfs_fp_mount_target[[:space:]]#d" /etc/fstab - echo "$nfs_server_ip:$nfs_fp_server_share $nfs_fp_mount_target nfs auto,_netdev,nofail" >> /etc/fstab + echo "$nfs_server_ip:$nfs_fp_server_share $nfs_fp_mount_target nfs _netdev,nofail,noauto,x-systemd.automount" >> /etc/fstab MENU_DRIVE_TARGET=$nfs_fp_mount_target Init_Drives_and_Refresh @@ -1897,7 +1904,7 @@ NTFS:\nRecommended if you plan to use this drive on a Windows system. High CPU u G_WHIP_MENU_ARRAY=( - 'Samba' ': Setup a connection for a Samba/CIFS/Windows compatible file share' + 'Samba' ': Setup a connection for a Samba/SMB/CIFS/Windows compatible file share' 'NFS' ': Setup a connection for a NFS compatible file share' ) diff --git a/dietpi/dietpi-login b/dietpi/dietpi-login index ed52175716..7eb6447d3c 100644 --- a/dietpi/dietpi-login +++ b/dietpi/dietpi-login @@ -33,15 +33,15 @@ # Autoboot Run_AutoStart(){ - # - Boot into specific program if we have a valid screen + # Boot into specific program if we have a valid screen if [[ ! $DISPLAY && $(tty) == '/dev/tty1' ]]; then - # - Kodi + # Kodi if (( $auto_start_index == 1 )); then /DietPi/dietpi/misc/start_kodi - # - Desktop (LXDE/MATE etc) + # Desktop (LXDE/MATE etc) elif (( $auto_start_index == 2 )); then clear @@ -55,46 +55,46 @@ fi - # - RetroPie/Emulation station + # RetroPie/Emulation station elif (( $auto_start_index == 3 )); then - # emulationstation - can no longer be run as root + # emulationstation - can no longer be run as root /opt/retropie/supplementary/emulationstation/emulationstation.sh - # - OpenTyrian + # OpenTyrian elif (( $auto_start_index == 4 )); then /usr/local/games/opentyrian/run - # - DietPi-Cloudshell + # DietPi-Cloudshell elif (( $auto_start_index == 5 )); then setterm --blank 0 --powersave off --cursor off systemctl start dietpi-cloudshell - # - Amiberry standard boot + # Amiberry standard boot elif (( $auto_start_index == 8 )); then systemctl start amiberry - # - DXX-Rebirth + # DXX-Rebirth elif (( $auto_start_index == 9 )); then $G_FP_DIETPI_USERDATA/dxx-rebirth/run.sh - # - CAVA + # CAVA elif (( $auto_start_index == 10 )); then sleep 4 # Wait for MPD fifo to start setterm --blank 0 --powersave off cava - # - Chromium + # Chromium elif (( $auto_start_index == 11 )); then /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh - # - LightDM + # LightDM elif (( $auto_start_index == 16 )); then systemctl start lightdm @@ -108,15 +108,15 @@ # First Run Setup Run_DietPi_First_Run_Setup(){ - # - Set non-interactive if automated firstrun setup has been chosen + # Set non-interactive if automated firstrun setup has been chosen grep -qi '^[[:blank:]]*AUTO_SETUP_AUTOMATED=1' /DietPi/dietpi.txt && export G_INTERACTIVE=0 - # - Prompt and wait if this script runs in other session already + # Prompt and wait if this script runs in other session already local pid_firstrunsetup [[ -f $FP_DIETPI_FIRSTRUNSETUP_PID ]] && pid_firstrunsetup=$(<$FP_DIETPI_FIRSTRUNSETUP_PID) if [[ $pid_firstrunsetup && $pid_firstrunsetup != $$ ]]; then - # - First run setup running in other session + # First run setup running in other session local additional_text='Please resume setup on the active screen.' [[ $G_INTERACTIVE == 0 ]] && additional_text='Automated setup is in progress. When completed, the system will be rebooted.' @@ -147,23 +147,20 @@ Please login again as user "root" with password "dietpi", respectively the one y # 1st run dietpi-update if (( $G_DIETPI_INSTALL_STAGE == 0 )); then - # - Check internet + # Check internet optional_cmd_inputs='--no-check-certificate' G_CHECK_URL "$(grep -m1 '^[[:blank:]]*deb[[:blank:]]' /etc/apt/sources.list | mawk '{print $2}')" # Will exit on failure here then prompt user to configure network - # - Check NTP synced + # Check NTP synced /DietPi/dietpi/func/run_ntpd - # - Start DietPi-Update + # Start DietPi-Update /DietPi/dietpi/dietpi-update 1 # Sets G_DIETPI_INSTALL_STAGE=1 # 1st run dietpi-software installs elif (( $G_DIETPI_INSTALL_STAGE == 1 )); then - # - Start DietPi-Software - export G_WHIP_SIZE_X_OVERRIDE=$(tput cols) - export G_WHIP_SIZE_Y_OVERRIDE=$(tput lines) + # Start DietPi-Software /DietPi/dietpi/dietpi-software 2>&1 | tee $FP_DIETPI_FIRSTRUNSETUP_LOG # Sets G_DIETPI_INSTALL_STAGE=2 - unset G_WHIP_SIZE_X_OVERRIDE G_WHIP_SIZE_Y_OVERRIDE fi @@ -222,8 +219,8 @@ Please login again as user "root" with password "dietpi", respectively the one y /DietPi/dietpi/func/dietpi-banner 0 - # - Force interactive mode to show G_WHIP error prompts - # NB: We need to write this to dietpi.txt as well to not have this overwritten on next loop. + # Force interactive mode to show G_WHIP error prompts + # - NB: We need to write this to dietpi.txt as well to not have this overwritten on next loop. export G_INTERACTIVE=1 G_CONFIG_INJECT 'AUTO_SETUP_AUTOMATED=' 'AUTO_SETUP_AUTOMATED=0' /DietPi/dietpi.txt @@ -233,7 +230,7 @@ First run setup will now attempt to re-apply the last step, forced as interactiv If this repeatedly fails, please collect all terminal output and the content of $FP_DIETPI_FIRSTRUNSETUP_LOG if available and report this issue to: https://github.com/MichaIng/DietPi/issues\n Would you like to restart the first run setup and installation?"; then - # - Reset and force re-run of first run + # Reset and force re-run of first run killall -qw dietpi-software dietpi-update echo 0 > /DietPi/dietpi/.install_stage diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 6350ae122a..fb73f32ea6 100644 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -131,10 +131,17 @@ _EOF_ Check_Internet_and_NTPD(){ - # Internet: Use /etc/apt/sources.list for connection test - G_CHECK_URL "$(grep -m1 '^[[:blank:]]*deb ' /etc/apt/sources.list | mawk '{print $2}')" # Will exit on failure here then prompt user to configure network + # Checking network connectivity + local timeout=$(sed -n '/^[[:blank:]]*CONFIG_G_CHECK_URL_TIMEOUT=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + local ip=$(sed -n '/^[[:blank:]]*CONFIG_CHECK_CONNECTION_IP=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + l_message='Checking network connectivity' G_RUN_CMD ping -c 1 -W ${timeout:-5} ${ip:-1.1.1.1} - # Time sync + # Checking DNS resolver + # - NB: The timeout is only valid for ping response while DNS resolver timeout is controlled by: https://manpages.debian.org/resolv.conf + local domain=$(sed -n '/^[[:blank:]]*CONFIG_CHECK_DNS_DOMAIN=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + l_message='Checking DNS resolver' G_RUN_CMD ping -c 1 -W ${timeout:-5} ${domain:-one.one.one.one} + + # Network time sync /DietPi/dietpi/func/run_ntpd } @@ -162,7 +169,7 @@ _EOF_ if [[ -f '/var/lib/dietpi/dietpi-software/.GLOBAL_PW.bin' ]]; then GLOBAL_PW=$(openssl enc -d -a -md sha256 -aes-256-cbc $pbkdf2 -salt -pass pass:'DietPiRocks!' -in /var/lib/dietpi/dietpi-software/.GLOBAL_PW.bin) - # - Allow decryption and re-encrypt with "-iter 10000" on dist-upgraded Buster systems + # - Allow decryption without "-iter 10000" and re-encrypt on dist-upgraded Buster systems if (( $? && $G_DISTRO > 4 )); then GLOBAL_PW=$(openssl enc -d -a -md sha256 -aes-256-cbc -salt -pass pass:'DietPiRocks!' -in /var/lib/dietpi/dietpi-software/.GLOBAL_PW.bin) @@ -175,7 +182,8 @@ _EOF_ G_CONFIG_INJECT 'AUTO_SETUP_GLOBAL_PASSWORD=' 'AUTO_SETUP_GLOBAL_PASSWORD=Password has been encrypted and secured on rootFS' /DietPi/dietpi.txt openssl enc -e -a -md sha256 -aes-256-cbc $pbkdf2 -salt -pass pass:'DietPiRocks!' -out /var/lib/dietpi/dietpi-software/.GLOBAL_PW.bin <<< $GLOBAL_PW - [[ $GLOBAL_PW != 'dietpi' ]] && G_WHIP_MSG '[ INFO ] For security reasons your global software password has been removed from dietpi.txt and instead ecrypted and saved to: + # Inform user if encryption is done after update of an old DietPi instance, else firstrun setup does the job + (( $G_DIETPI_INSTALL_STAGE == 2 )) && G_WHIP_MSG '[ INFO ] For security reasons your global software password has been removed from dietpi.txt and instead ecrypted and saved to: - /var/lib/dietpi/dietpi-software/.GLOBAL_PW.bin\n DietPi-Software will decrypt and use it for software installs. You can change it via: - dietpi-config > Security Options > Change Passwords' @@ -215,9 +223,8 @@ DietPi-Software will decrypt and use it for software installs. You can change it USER_LINUX_AUTOINSTALL_PROMPT_DISPLAYED=0 # PHP version specific directories, APT package-, module- and command names - # - and distro specific MariaDB service name - FP_PHP_BASE_DIR='/etc/php/7.3' PHP_NAME='php7.3' + FP_PHP_BASE_DIR='/etc/php/7.3' USBDRIVE=0 @@ -464,6 +471,8 @@ DietPi-Software will decrypt and use it for software installs. You can change it done # + ASUS TB aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,52]=1 + # + RK3399 (experimental) + (( $G_HW_CPUID == 3 )) && aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,$G_HW_MODEL]=1 # - C1 Stretch aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,10]=0 #------------------ @@ -851,7 +860,7 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_DESC[$software_id]='automatically download movies' aSOFTWARE_CATEGORY_INDEX[$software_id]=3 aSOFTWARE_TYPE[$software_id]=0 - aSOFTWARE_ONLINEDOC_URL[$software_id]='p=6747#p6747' + aSOFTWARE_ONLINEDOC_URL[$software_id]='p=7212#p7212' aSOFTWARE_REQUIRES_BUILDESSENTIAL[$software_id]=1 aSOFTWARE_REQUIRES_GIT[$software_id]=1 #------------------ @@ -886,8 +895,8 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='Jackett' aSOFTWARE_DESC[$software_id]='API support for your torrent trackers' - aSOFTWARE_CATEGORY_INDEX[$software_id]=3 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=3 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=7503#p7503' #------------------ software_id=149 @@ -919,13 +928,6 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_REQUIRES_PHP[$software_id]=1 aSOFTWARE_REQUIRES_MYSQL[$software_id]=1 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=47#p47' - # ownCloud up to 10.2 does not support PHP7.3 (Buster): https://doc.owncloud.org/server/administration_manual/installation/system_requirements.html - aSOFTWARE_AVAIL_G_DISTRO[$software_id,5]=0 - aSOFTWARE_AVAIL_G_DISTRO[$software_id,6]=0 - # ARMv6 devices have no chance to get some required PHP7.2 packages (APCu, Redis) - aSOFTWARE_AVAIL_G_HW_ARCH[$software_id,1]=0 - # Disable if PHP7.3 is already installed - command -v php7.3 &> /dev/null && aSOFTWARE_AVAIL_G_DISTRO[$software_id,$G_DISTRO]=0 #------------------ software_id=114 @@ -1009,8 +1011,8 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_CATEGORY_INDEX[$software_id]=4 aSOFTWARE_TYPE[$software_id]=0 #------------------ - software_id=161 + aSOFTWARE_NAME[$software_id]='FuguHub' aSOFTWARE_DESC[$software_id]='Lightweight WebDAV cloud (eg: dropbox) with a CMS' aSOFTWARE_CATEGORY_INDEX[$software_id]=4 @@ -1022,11 +1024,11 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='Gitea' aSOFTWARE_DESC[$software_id]='Git with a cup of tea' - aSOFTWARE_CATEGORY_INDEX[$software_id]=4 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=4 + aSOFTWARE_ONLINEDOC_URL[$software_id]='p=9863#p9863' aSOFTWARE_REQUIRES_GIT[$software_id]=1 aSOFTWARE_REQUIRES_MYSQL[$software_id]=1 - aSOFTWARE_ONLINEDOC_URL[$software_id]='p=9863#p9863' # Emulation / Gaming #-------------------------------------------------------------------------------- @@ -1348,16 +1350,17 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='Docker' aSOFTWARE_DESC[$software_id]='Build, ship, and run distributed applications' - aSOFTWARE_CATEGORY_INDEX[$software_id]=9 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=9 # - Bullseye aSOFTWARE_AVAIL_G_DISTRO[$software_id,6]=0 + # Remote Access #-------------------------------------------------------------------------------- software_id=67 - aSOFTWARE_NAME[$software_id]='NoIp' - aSOFTWARE_DESC[$software_id]='url website address for your device' + aSOFTWARE_NAME[$software_id]='No-IP' + aSOFTWARE_DESC[$software_id]='Dynamic DNS update client' aSOFTWARE_CATEGORY_INDEX[$software_id]=10 aSOFTWARE_TYPE[$software_id]=0 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=58#p58' @@ -1472,8 +1475,8 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='Mosquitto ' aSOFTWARE_DESC[$software_id]='MQTT messaging broker' - aSOFTWARE_CATEGORY_INDEX[$software_id]=11 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=11 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=4293#p4293' #------------------ software_id=131 @@ -1523,8 +1526,8 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='Mycroft AI' aSOFTWARE_DESC[$software_id]='Open Source Voice Assistant' - aSOFTWARE_CATEGORY_INDEX[$software_id]=11 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=11 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=18562#p18562' aSOFTWARE_REQUIRES_ALSA[$software_id]=1 aSOFTWARE_REQUIRES_GIT[$software_id]=1 @@ -1534,16 +1537,16 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='InfluxDB' aSOFTWARE_DESC[$software_id]='time-series database' - aSOFTWARE_CATEGORY_INDEX[$software_id]=11 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=11 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=12523#p12523' #------------------ software_id=77 aSOFTWARE_NAME[$software_id]='Grafana' aSOFTWARE_DESC[$software_id]='platform for analytics and monitoring' - aSOFTWARE_CATEGORY_INDEX[$software_id]=11 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=11 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=12524#p12524' # System security @@ -1734,15 +1737,15 @@ DietPi-Software will decrypt and use it for software installs. You can change it #------------------ software_id=96 - aSOFTWARE_NAME[$software_id]='Samba' + aSOFTWARE_NAME[$software_id]='Samba Server' aSOFTWARE_DESC[$software_id]='feature-rich file server' - aSOFTWARE_CATEGORY_INDEX[$software_id]=15 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=15 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=56#p56' #------------------ software_id=109 - aSOFTWARE_NAME[$software_id]='NFS' + aSOFTWARE_NAME[$software_id]='NFS Server' aSOFTWARE_DESC[$software_id]='network file system server' aSOFTWARE_CATEGORY_INDEX[$software_id]=15 aSOFTWARE_TYPE[$software_id]=0 @@ -1814,8 +1817,8 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='EmonPi' aSOFTWARE_DESC[$software_id]='energy usage addon board with web interface' - aSOFTWARE_CATEGORY_INDEX[$software_id]=18 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=18 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=1525#p1525' # RPi only for ((i=10; i<=$MAX_G_HW_MODEL; i++)) @@ -1829,13 +1832,19 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='Home Assistant' aSOFTWARE_DESC[$software_id]='open-source home automation platform' - aSOFTWARE_CATEGORY_INDEX[$software_id]=18 aSOFTWARE_TYPE[$software_id]=0 - aSOFTWARE_REQUIRES_GIT[$software_id]=1 - aSOFTWARE_REQUIRES_BUILDESSENTIAL[$software_id]=1 - aSOFTWARE_REQUIRES_SQLITE[$software_id]=1 - aSOFTWARE_REQUIRES_FFMPEG[$software_id]=1 + aSOFTWARE_CATEGORY_INDEX[$software_id]=18 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=70#p70' + #------------------ + software_id=27 + + aSOFTWARE_NAME[$software_id]='TasmoAdmin' + aSOFTWARE_DESC[$software_id]='Website to manage ESP8266 devices flashed with Tasmota' + aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=18 + aSOFTWARE_ONLINEDOC_URL[$software_id]='p=20584#p20584' + aSOFTWARE_REQUIRES_WEBSERVER[$software_id]=1 + aSOFTWARE_REQUIRES_PHP[$software_id]=1 # Printing #-------------------------------------------------------------------------------- @@ -1843,8 +1852,8 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_NAME[$software_id]='CloudPrint' aSOFTWARE_DESC[$software_id]='print server for google cloud print' - aSOFTWARE_CATEGORY_INDEX[$software_id]=19 aSOFTWARE_TYPE[$software_id]=0 + aSOFTWARE_CATEGORY_INDEX[$software_id]=19 aSOFTWARE_ONLINEDOC_URL[$software_id]='p=6630#p6630' aSOFTWARE_REQUIRES_RSYSLOG[$software_id]=1 # Not required, but comes in as package dep #------------------ @@ -1876,10 +1885,10 @@ DietPi-Software will decrypt and use it for software installs. You can change it software_id=1 aSOFTWARE_NAME[$software_id]='Samba Client' - aSOFTWARE_DESC[$software_id]='access network shares' + aSOFTWARE_DESC[$software_id]='access SMB/CIFS/Samba network shares' aSOFTWARE_CATEGORY_INDEX[$software_id]=1 aSOFTWARE_TYPE[$software_id]=1 - aSOFTWARE_ONLINEDOC_URL[$software_id]=' dietpi-config > Network Options: NAS/Misc' + aSOFTWARE_ONLINEDOC_URL[$software_id]=' dietpi-drive_manager > Add network drive' #------------------ software_id=110 @@ -1887,7 +1896,7 @@ DietPi-Software will decrypt and use it for software installs. You can change it aSOFTWARE_DESC[$software_id]='network file system client' aSOFTWARE_CATEGORY_INDEX[$software_id]=1 aSOFTWARE_TYPE[$software_id]=1 - aSOFTWARE_ONLINEDOC_URL[$software_id]=' dietpi-config > Network Options: NAS/Misc' + aSOFTWARE_ONLINEDOC_URL[$software_id]=' dietpi-drive_manager > Add network drive' # File managers #-------------------------------------------------------------------------------- @@ -2449,35 +2458,35 @@ Please reselect Docker from dietpi-software after next reboot.' (( ${aSOFTWARE_INSTALL_STATE[$i]} != 1 )) && continue - # WEBSERVER - Auto install via choice system + # Webserver - Auto install via choice system # - Check for existing webserver base (Apache2, Nginx, Lighttpd) installation if (( ${aSOFTWARE_REQUIRES_WEBSERVER[$i]:=0} && ${aSOFTWARE_INSTALL_STATE[83]} < 1 && ${aSOFTWARE_INSTALL_STATE[84]} < 1 && ${aSOFTWARE_INSTALL_STATE[85]} < 1 )); then - # - None found, select one for install, based on user preference + # None found, select one for install, based on user preference + # - Apache if (( $INDEX_WEBSERVER_TARGET == 0 )); then - # WEBSERVER_APACHE aSOFTWARE_INSTALL_STATE[83]=1 G_DIETPI-NOTIFY 2 'Apache2 will be installed' + # - Nginx elif (( $INDEX_WEBSERVER_TARGET == -1 )); then - # WEBSERVER_NGINX aSOFTWARE_INSTALL_STATE[85]=1 G_DIETPI-NOTIFY 2 'Nginx will be installed' + # - Lighttpd else - # WEBSERVER_LIGHTTPD aSOFTWARE_INSTALL_STATE[84]=1 G_DIETPI-NOTIFY 2 'Lighttpd will be installed' fi - # Pretent software requiring PHP, to mark it below, in case webserver ID already passed: + # Pretent software requiring PHP, to mark it below, in case webserver ID already passed aSOFTWARE_REQUIRES_PHP[$i]=1 fi @@ -2490,8 +2499,7 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # WEBSERVER_MARIADB - software_id=88 + software_id=88 # MariaDB if (( ${aSOFTWARE_REQUIRES_MYSQL[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 @@ -2499,8 +2507,7 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # WEBSERVER_SQLITE - software_id=87 + software_id=87 # SQLite if (( ${aSOFTWARE_REQUIRES_SQLITE[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 @@ -2508,7 +2515,7 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # DESKTOP + # Desktop if (( ${aSOFTWARE_REQUIRES_DESKTOP[$i]:=0} && ${aSOFTWARE_INSTALL_STATE[23]} < 1 && ${aSOFTWARE_INSTALL_STATE[24]} < 1 && @@ -2525,16 +2532,14 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # GIT - software_id=17 + software_id=17 # Git if (( ${aSOFTWARE_REQUIRES_GIT[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 G_DIETPI-NOTIFY 2 "${aSOFTWARE_NAME[$software_id]} will be installed" fi - # BUILDESSENTIAL - software_id=16 + software_id=16 # Build essentials if (( ${aSOFTWARE_REQUIRES_BUILDESSENTIAL[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 @@ -2542,16 +2547,15 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # RSYSLOG - software_id=102 + software_id=102 # Rsyslog if (( ${aSOFTWARE_REQUIRES_RSYSLOG[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 G_DIETPI-NOTIFY 2 "${aSOFTWARE_NAME[$software_id]} will be installed" fi - # FFMPEG - software_id=7 + + software_id=7 # FFmpeg if (( ${aSOFTWARE_REQUIRES_FFMPEG[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 @@ -2559,8 +2563,7 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # JAVA - software_id=8 + software_id=8 # Java if (( ${aSOFTWARE_REQUIRES_JAVA_JRE_JDK[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 @@ -2568,8 +2571,7 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # NODEJS - software_id=9 + software_id=9 # Node.js if (( ${aSOFTWARE_REQUIRES_NODEJS[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 @@ -2577,8 +2579,7 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # ALSA - software_id=5 + software_id=5 # ALSA if (( ${aSOFTWARE_REQUIRES_ALSA[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 @@ -2586,8 +2587,7 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # XSERVERXORG - software_id=6 + software_id=6 # Xserver if (( ${aSOFTWARE_REQUIRES_XSERVERXORG[$i]:=0} && aSOFTWARE_INSTALL_STATE[$software_id] != 1 )); then aSOFTWARE_INSTALL_STATE[$software_id]=1 @@ -2597,8 +2597,8 @@ Please reselect Docker from dietpi-software after next reboot.' done - # WEBSERVER - Check for stacks and flag as installing - # WEBSERVER_APACHE + # Webserver - Check for stacks and flag as installing + # - Apache if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then # SQLite: LASP @@ -2607,7 +2607,7 @@ Please reselect Docker from dietpi-software after next reboot.' # MariaDB: LAMP (( ${aSOFTWARE_INSTALL_STATE[88]} > 0 )) && aSOFTWARE_INSTALL_STATE[76]=1 - # WEBSERVER_NGINX + # - Nginx elif (( ${aSOFTWARE_INSTALL_STATE[85]} > 0 )); then # SQLite: LESP @@ -2616,7 +2616,7 @@ Please reselect Docker from dietpi-software after next reboot.' # MariaDB: LEMP (( ${aSOFTWARE_INSTALL_STATE[88]} > 0 )) && aSOFTWARE_INSTALL_STATE[79]=1 - # WEBSERVER_LIGHTTPD + # - Lighttpd elif (( ${aSOFTWARE_INSTALL_STATE[84]} > 0 )); then # SQLite: LLSP @@ -2627,29 +2627,37 @@ Please reselect Docker from dietpi-software after next reboot.' fi - # Update PHP variables after all software titles have been marked. - if (( ${aSOFTWARE_INSTALL_STATE[89]} > 0 )); then + # Update PHP variables after all software titles have been marked + # - Never install PHP7.2 if PHP7.3 is already present + if (( ${aSOFTWARE_INSTALL_STATE[89]} > 0 )) && ! command -v php7.3 &> /dev/null; then - # ownCloud (up to v10.2) does not yet support PHP7.3, so install PHP7.2 for now - if (( ${aSOFTWARE_INSTALL_STATE[47]} > 0 )) || [[ -f '/var/www/owncloud/version.php' ]]; then + # Do not upgrade PHP7.2, since we can support it for a long time + if command -v php7.2 &> /dev/null; then - FP_PHP_BASE_DIR='/etc/php/7.2' PHP_NAME='php7.2' - # - Prevent accidental PHP7.3 installs - echo -e '# ownCloud does not yet support PHP7.3 -Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/dietpi-owncloud - - fi + FP_PHP_BASE_DIR='/etc/php/7.2' - # phpBB3 (up to v3.2) as well: https://github.com/phpbb/phpbb/blob/3.2.x/phpBB/install/app.php#L23 - if (( ${aSOFTWARE_INSTALL_STATE[54]} > 0 )) || [[ -f '/var/www/phpBB3/config.php' ]]; then + # phpBB up to v3.2: https://github.com/phpbb/phpbb/blob/3.2.x/phpBB/install/app.php#L23 + elif (( ${aSOFTWARE_INSTALL_STATE[54]} > 0 )) || [[ -f '/var/www/phpBB3/config.php' ]]; then - FP_PHP_BASE_DIR='/etc/php/7.2' PHP_NAME='php7.2' - # - Prevent accidental PHP7.3 installs + FP_PHP_BASE_DIR='/etc/php/7.2' + # Prevent accidental PHP7.3 installs echo -e '# phpBB does not yet support PHP7.3 Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/dietpi-phpbb + # ownCloud up to v10.2 + elif [[ -f '/var/www/owncloud/version.php' ]]; then + + local oc_version_major=$(sed -n '/$OC_VersionString/{s/^[^0-9]*//;s/\..*$//;p;q}' /var/www/owncloud/version.php) + local oc_version_minor=$(sed -n '/$OC_VersionString/{s/^[^.]*\.//;s/\..*$//;p;q}' /var/www/owncloud/version.php) + if (( $oc_version_major < 10 || ( $oc_version_major == 10 && $oc_version_minor < 3 ) )); then + + PHP_NAME='php7.2' + FP_PHP_BASE_DIR='/etc/php/7.2' + + fi + fi fi @@ -2745,12 +2753,7 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di local output=0 local gigabit_device=1 - # - Lets hope the next RPi device is finally gigabit capable. I'll cry if it is not. - if (( $G_HW_MODEL < 4 || $G_HW_MODEL == 30 || $G_HW_MODEL == 32 || $G_HW_MODEL == 40 || $G_HW_MODEL == 60 || $G_HW_MODEL == 70 )); then - - gigabit_device=0 - - fi + (( $G_HW_MODEL < 4 || $G_HW_MODEL == 30 || $G_HW_MODEL == 32 || $G_HW_MODEL == 40 || $G_HW_MODEL == 60 || $G_HW_MODEL == 70 )) && gigabit_device=0 # Cache size (MB) 1/10th of total mem if (( $1 == 0 )); then @@ -2762,7 +2765,7 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di output=2 - # - Bump up for x86 + # Bump up for x86 (( $G_HW_ARCH == 10 )) && output=3 # Max global connections @@ -2770,17 +2773,17 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di output=20 - # - Bump up for x86 - if (( $G_HW_MODEL == 20 || $G_HW_MODEL == 21 )); then + # Bump up for x86 + if (( $G_HW_ARCH == 10 )); then output=40 - # - Gbit devices + # Gbit devices elif (( $gigabit_device )); then output=30 - # - Reduce for RPi. This is due to the USB bus ethernet in the ARM SoC, which cripples network throughput/performance/latency. + # Reduce for RPi 1-3. This is due to the USB bus Ethernet in the ARM SoC, which cripples network throughput/performance/latency. # - RPi3 elif (( $G_HW_MODEL == 3 )); then @@ -2803,17 +2806,17 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di output=3 - # - Bump up for x86 + # Bump up for x86 if (( $G_HW_ARCH == 10 )); then output=5 - # - Gbit devices + # Gbit devices elif (( $gigabit_device )); then output=4 - # - Reduce for RPi. This is due to the USB bus ethernet in the ARM SoC, which cripples network throughput/performance/latency. + # - Reduce for RPi 1-3. This is due to the USB bus Ethernet in the ARM SoC, which cripples network throughput/performance/latency. elif (( $G_HW_MODEL < 4 )); then output=2 @@ -2848,7 +2851,7 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di if disable_error=1 G_CHECK_VALIDINT "$dps_index" 0; then type='dps_index' - url="https://raw.githubusercontent.com/MichaIng/DietPi/$G_GITBRANCH/.conf/dps_$dps_index/$url" + url="https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.conf/dps_$dps_index/$url" fi @@ -2926,14 +2929,14 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di Banner_Installing - # - For desktop entries/icons hosted on dietpi.com + # For desktop entries/icons hosted on dietpi.com INSTALL_URL_ADDRESS='https://dietpi.com/downloads/conf/desktop' G_CHECK_URL "$INSTALL_URL_ADDRESS" G_AGI lxde upower policykit-1 firefox-esr #upower policykit-1. Needed for LXDE logout menu item to show shutdown/restart ... - # - RPi Stretch, revert to Debian pcmanfm install package: https://github.com/MichaIng/DietPi/issues/1558#issuecomment-390328173 + # RPi Stretch, revert to Debian pcmanfm install package: https://github.com/MichaIng/DietPi/issues/1558#issuecomment-390328173 if (( $G_HW_MODEL < 10 && $G_DISTRO == 4 )); then Download_Install 'https://dietpi.com/downloads/binaries/all/pcmanfm_1.2.5-3_armhf.deb' @@ -2948,11 +2951,11 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di Banner_Installing - # - For desktop entries/icons hosted on dietpi.com + # For desktop entries/icons hosted on dietpi.com INSTALL_URL_ADDRESS='https://dietpi.com/downloads/conf/desktop' G_CHECK_URL "$INSTALL_URL_ADDRESS" - # - Buster: No leafpad available, use featherpad instead: https://github.com/MichaIng/DietPi/issues/1918#issuecomment-489319719 + # Buster: No leafpad available, use featherpad instead: https://github.com/MichaIng/DietPi/issues/1918#issuecomment-489319719 local editor='leafpad' (( $G_DISTRO > 4 )) && editor='featherpad' @@ -2965,7 +2968,7 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di Banner_Installing - # - For desktop entries/icons hosted on dietpi.com + # For desktop entries/icons hosted on dietpi.com INSTALL_URL_ADDRESS='https://dietpi.com/downloads/conf/desktop' G_CHECK_URL "$INSTALL_URL_ADDRESS" @@ -2978,7 +2981,7 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di Banner_Installing - # - For desktop entries/icons hosted on dietpi.com + # For desktop entries/icons hosted on dietpi.com INSTALL_URL_ADDRESS='https://dietpi.com/downloads/conf/desktop' G_CHECK_URL "$INSTALL_URL_ADDRESS" @@ -2991,7 +2994,7 @@ Package: *php7.3*\nPin: release *\nPin-Priority: -1' > /etc/apt/preferences.d/di Banner_Installing - # - For desktop entries/icons hosted on dietpi.com + # For desktop entries/icons hosted on dietpi.com INSTALL_URL_ADDRESS='https://dietpi.com/downloads/conf/desktop' G_CHECK_URL "$INSTALL_URL_ADDRESS" @@ -3037,7 +3040,7 @@ _EOF_ fi - software_id=44 # BitTorrent Transmission + software_id=44 # Transmission if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -3062,7 +3065,7 @@ _EOF_ # Link disk cache to RAM: https://github.com/MichaIng/DietPi/issues/2396 # - Remove previous disk cache dir or symlink - [[ -d '/var/cache/samba' || -L '/var/cache/samba' ]] && rm -R /var/cache/samba + rm -Rf /var/cache/samba # - Pre-create RAM cache dir mkdir -p /run/samba-cache # - Link disk cache to RAM @@ -3101,7 +3104,7 @@ _EOF_ fi - software_id=85 # Nginx Webserver + software_id=85 # Nginx if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -3112,7 +3115,7 @@ _EOF_ fi - software_id=84 # Lighttpd Webserver + software_id=84 # Lighttpd if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -3121,7 +3124,7 @@ _EOF_ fi - software_id=88 # MariaDB Database + software_id=88 # MariaDB if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -3143,7 +3146,7 @@ _EOF_ else - G_RUN_CMD mkdir $G_FP_DIETPI_USERDATA/mysql + G_RUN_CMD mkdir -p $G_FP_DIETPI_USERDATA/mysql fi @@ -3169,7 +3172,7 @@ _EOF_ fi - software_id=87 # SQLite Database + software_id=87 # SQLite if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -3180,7 +3183,7 @@ _EOF_ fi - software_id=91 # Redis Database + software_id=91 # Redis if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -3511,22 +3514,22 @@ _EOF_ Download_Install 'https://dietpi.com/downloads/binaries/all/ympd_1.2.3.7z' local binary_name='ympd_' - # - armv6 + # ARMv6 if (( $G_HW_ARCH == 1 )); then binary_name+='armv6' - # - armv7 + # ARMv7 elif (( $G_HW_ARCH == 2 )); then binary_name+='armv7' - # - arm64 + # ARMv8 elif (( $G_HW_ARCH == 3 )); then binary_name+='armv8' - # - x86_64 + # x86_64 elif (( $G_HW_ARCH == 10 )); then binary_name+='amd64' @@ -3749,80 +3752,59 @@ _EOF_ Banner_Installing - # Pre-reqs - DEPS_LIST='libmpg123-0 libxml2 mpeg2dec libmpeg2-4' - - # For Stretch, SDL2 was compiled with X11 + libsndio support and dependency - if (( $G_DISTRO < 5 )); then - - DEPS_LIST+=' libsndio6.1' - - # ARMv6 - if (( $G_HW_ARCH == 1 )); then + # Libraries + DEPS_LIST='libxml2 libfreetype6 libflac8 libmpeg2-4 libmpg123-0' # libpng16-16 pulled by libfreetype6 - INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/sdl2-armv6_stretch.7z' - - # ARMv7 FKMS: ./configure --disable-video-rpi --enable-video-kmsdrm - elif (( $G_HW_ARCH == 2 )); then - - INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/sdl2-armv7_stretch.7z' - - # RPi 2/3 Enable fkms OpenGL - (( $G_HW_MODEL < 10 )) && /DietPi/dietpi/func/dietpi-set_hardware rpi-opengl vc4-fkms-v3d - - fi - - Download_Install "$INSTALL_URL_ADDRESS" sdl2 - dpkg -i sdl2/*.deb - rm -R sdl2 - - # For Buster, SDL2 was compiled with minimum dependencies: No X11 required, thus GPU drivers and some libraries need to be installed/enabled separately - else + # Platform and GPU drivers + # - RPi + if (( $G_HW_MODEL < 10 )); then - # Libraries - DEPS_LIST+=' libpng16-16 libfreetype6' + local platform='rpi1' # Include ID -1 + 0 + (( $G_HW_MODEL > 1 )) && platform="rpi$G_HW_MODEL" + (( $G_DISTRO > 4 )) && DEPS_LIST+=' libegl1' || DEPS_LIST+=' libegl1-mesa' + /DietPi/dietpi/func/dietpi-set_hardware rpi-opengl vc4-fkms-v3d - # GPU drivers - # - RPi - if (( $G_HW_MODEL < 10 )); then + # - Odroid XU4: http://fuzon.co.uk/meveric/pool/main/s/setup-odroid/ + elif (( $G_HW_MODEL == 11 )); then - DEPS_LIST+=' libegl1' - /DietPi/dietpi/func/dietpi-set_hardware rpi-opengl vc4-fkms-v3d + local platform='xu4' + DEPS_LIST+=' malit628-odroid' - # - Odroid XU4: http://fuzon.co.uk/meveric/pool/main/s/setup-odroid/ - elif (( $G_HW_MODEL == 11 )); then + # - ASUS TB: https://github.com/rockchip-linux/rk-rootfs-build/tree/master/packages/armhf + elif (( $G_HW_MODEL == 52 )); then - DEPS_LIST+=' malit628-odroid' + local platform='RK3288' + # Mali-T760 driver libraries + Download_Install 'https://dietpi.com/downloads/binaries/asus/libmali.deb' + cd /usr/lib/arm-linux-gnueabihf + ln -sf libMali.so libEGL.so.1.1.0 + ln -sf libMali.so libEGL.so + ln -sf libMali.so libEGL.so.1.0.0 + ln -sf libMali.so libEGL.so.1.4 + ln -sf libMali.so libGLESv2.so + ln -sf libMali.so libGLESv2.so.2.0 + ln -sf libMali.so libGLESv2.so.2.0.0 + ln -sf libMali.so libGLESv1_CM.so + ln -sf libMali.so libGLESv1_CM.so.1 + ln -sf libMali.so libGLESv1_CM.so.1.1 + cd /tmp/$G_PROGRAM_NAME - # - ASUS TB: https://github.com/rockchip-linux/rk-rootfs-build/tree/master/packages/armhf - elif (( $G_HW_MODEL == 52 )); then + fi - # Mali-T760 driver libraries - Download_Install 'https://dietpi.com/downloads/binaries/asus/libmali.deb' - cd /usr/lib/arm-linux-gnueabihf - ln -sf libMali.so libEGL.so.1.1.0 - ln -sf libMali.so libEGL.so - ln -sf libMali.so libEGL.so.1.0.0 - ln -sf libMali.so libEGL.so.1.4 - ln -sf libMali.so libGLESv2.so - ln -sf libMali.so libGLESv2.so.2.0 - ln -sf libMali.so libGLESv2.so.2.0.0 - ln -sf libMali.so libGLESv1_CM.so - ln -sf libMali.so libGLESv1_CM.so.1 - ln -sf libMali.so libGLESv1_CM.so.1.1 - cd /tmp/$G_PROGRAM_NAME + # Download Amiberry + Download_Install "https://dietpi.com/downloads/binaries/$G_DISTRO_NAME/amiberry_$platform.tar.bz2" - fi + # Reinstall: Backup old instance + [[ -d $G_FP_DIETPI_USERDATA/amiberry ]] && G_RUN_CMD mv $G_FP_DIETPI_USERDATA/amiberry $G_FP_DIETPI_USERDATA/amiberry_bak - # libSDL2 - Download_Install "https://dietpi.com/downloads/binaries/$G_DISTRO_NAME/libSDL2_$G_HW_ARCH_DESCRIPTION.tar.bz2" /usr/local/lib + # Reinstall: Restore old configs and data + [[ -d $G_FP_DIETPI_USERDATA/amiberry_bak ]] && G_RUN_CMD cp -a $G_FP_DIETPI_USERDATA/amiberry_bak/{conf,kickstarts,savestates,screenshots} amiberry/ - fi + # Move new instance in place + G_RUN_CMD mv amiberry $G_FP_DIETPI_USERDATA/ - # Amiberry - # - Backup existing autostart.uae for user - G_BACKUP_FP $G_FP_DIETPI_USERDATA/amiberry/conf/autostart.uae - Download_Install 'https://dietpi.com/downloads/binaries/all/amiberry_v2.25.7z' $G_FP_DIETPI_USERDATA + # Reinstall: Remove old instance + [[ -d $G_FP_DIETPI_USERDATA/amiberry_bak ]] && rm -R $G_FP_DIETPI_USERDATA/amiberry_bak fi @@ -4188,16 +4170,16 @@ _EOF_ INSTALL_URL_ADDRESS='https://api.github.com/repos/blynkkk/blynk-server/releases/latest' G_CHECK_URL "$INSTALL_URL_ADDRESS" - # On Buster use non-Java8 binary, else Java 8 - local java='java8' - (( $G_DISTRO > 4 )) && java='[^a].' # Exclude "a" von jav[a]8 but allow "8" as this can be from version string + # On Stretch and ARMv6 (RPi 1/Zero) use Java 8, else most current + local java='[^a].' # Exclude "a" from jav[a]8 but allow "8" as this can be from version string + (( $G_DISTRO < 5 || G_HW_ARCH == 1 )) && java='java8' INSTALL_URL_ADDRESS=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 "browser_download_url.*$java\.jar" | cut -d \" -f 4) # Fallback URL if [[ ! $INSTALL_URL_ADDRESS ]]; then - INSTALL_URL_ADDRESS='https://github.com/blynkkk/blynk-server/releases/download/v0.41.5/server-0.41.5-java8.jar' - (( $G_DISTRO > 4 )) && INSTALL_URL_ADDRESS='https://github.com/blynkkk/blynk-server/releases/download/v0.41.5/server-0.41.5-java8.jar' + INSTALL_URL_ADDRESS='https://github.com/blynkkk/blynk-server/releases/download/v0.41.11/server-0.41.11.jar' + (( $G_DISTRO < 5 || G_HW_ARCH == 1 )) && INSTALL_URL_ADDRESS='https://github.com/blynkkk/blynk-server/releases/download/v0.41.11/server-0.41.11-java8.jar' fi @@ -4218,49 +4200,42 @@ _EOF_ Banner_Installing - # Skip license - debconf-set-selections <<< 'networkaudiod networkaudiod/license note false' - - # Packages - local apackages=() + # Base URL + local url='https://www.signalyst.eu/bins/naa/linux' + # Arch # - ARMv6/7 - if (( $G_HW_ARCH < 3 )); then - - apackages+=('https://www.signalyst.eu/bins/naa/linux/stretch/networkaudiod_3.5.6-41_armhf.deb') + local arch='armhf' # - ARMv8 - elif (( $G_HW_ARCH == 3 )); then + if (( $G_HW_ARCH == 3 )); then - apackages+=('https://www.signalyst.eu/bins/naa/linux/stretch/networkaudiod_3.5.6-41_arm64.deb') + arch='arm64' # - x86_64 - else + elif (( $G_HW_ARCH == 10 )); then - apackages+=('https://www.signalyst.eu/bins/naa/linux/stretch/networkaudiod_3.5.6-41_amd64.deb') + arch='amd64' fi - # Check online - for i in "${apackages[@]}" - do + # Get latest version: No Bullseye packages available yet + local distro=$G_DISTRO_NAME + (( $G_DISTRO > 5 )) && distro='buster' + local package=$(curl -s "$url/$distro/" | sed -n "/networkaudiod_.*_$arch.deb/{s/^[^\"]*\"//;s/\".*$//p}" | tail -1) + # - armhf fallback: No Buster packages available at date of check + [[ $package || $distro == 'stretch' ]] || { distro='stretch'; package=$(curl -s "$url/$distro/" | sed -n "/networkaudiod_.*_$arch.deb/{s/^[^\"]*\"//;s/\".*$//p}" | tail -1); } - G_CHECK_URL "$i" + # Check final URL before applying debconf settings + G_CHECK_URL "$url/$distro/$package" - done + # Skip license + debconf-set-selections <<< 'networkaudiod networkaudiod/license note false' # Install - for i in "${apackages[@]}" - do + no_check_url=1 Download_Install "$url/$distro/$package" - no_check_url=1 Download_Install "$i" - - done - - unset apackages - - # Enable logging for NAA Daemon - #echo "NETWORKAUDIOD_LOGFILE='/var/log/naadaemon.log'" > /etc/default/networkaudiod + unset url arch distro package fi @@ -4320,7 +4295,7 @@ _EOF_ make -j $G_HW_CPU_CORES TARGET=linux2628 CPU=generic USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_LINUX_SPLICE=1 make install - mkdir /etc/haproxy + mkdir -p /etc/haproxy # Exit directory cd /tmp/$G_PROGRAM_NAME @@ -4454,25 +4429,27 @@ _EOF_ Banner_Installing - # APT repo GPG key - INSTALL_URL_ADDRESS='https://packages.grafana.com/gpg.key' - local deb_address='deb https://packages.grafana.com/oss/deb/ stable main' + # ARMv6: Install package manually since repo is not compatible: https://grafana.com/grafana/download?platform=arm if (( $G_HW_ARCH == 1 )); then - INSTALL_URL_ADDRESS='https://bintray.com/user/downloadSubjectPublicKey?username=bintray' - deb_address="deb https://dl.bintray.com/fg2it/deb-rpi-1b/ $G_DISTRO_NAME main" + Download_Install 'https://dl.grafana.com/oss/release/grafana-rpi_6.4.3_armhf.deb' - fi + # Else use official APT repo: https://grafana.com/docs/installation/debian/#apt-repository + else - G_CHECK_URL "$INSTALL_URL_ADDRESS" - curl -sSL "$INSTALL_URL_ADDRESS" | apt-key add - + # APT key + INSTALL_URL_ADDRESS='https://packages.grafana.com/gpg.key' + G_CHECK_URL "$INSTALL_URL_ADDRESS" + curl -sSL "$INSTALL_URL_ADDRESS" | apt-key add - - # APT repo source & update - echo "$deb_address" > /etc/apt/sources.list.d/grafana.list - G_AGUP + # APT list + echo 'deb https://packages.grafana.com/oss/deb/ stable main' > /etc/apt/sources.list.d/grafana.list + G_AGUP + + # APT package + G_AGI grafana - # APT package - G_AGI grafana + fi fi @@ -4653,9 +4630,6 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- # If existing install, reconfigure to rebuild WireGuard kernel module against current kernel + headers (( $existing_install )) && G_RUN_CMD dpkg-reconfigure wireguard-dkms - # On RPi, the kernel module rebuild is not triggered by kernel upgrades, thus add this task manually - (( $G_HW_MODEL > 9 )) || echo -e '#!/bin/dash\ndpkg-reconfigure wireguard-dkms' > /etc/kernel/postinst.d/dietpi-wireguard - unset kernel_packages existing_install fi @@ -5109,14 +5083,14 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- Download_Install "https://github.com/Novik/ruTorrent/archive/$version_string.tar.gz" # - Reinstall - if [[ -d /var/www/rutorrent ]]; then + if [[ -d '/var/www/rutorrent' ]]; then - # - Backup known config files + # Backup known config files G_BACKUP_FP /var/www/rutorrent/conf/config.php G_BACKUP_FP /var/www/rutorrent/conf/access.ini G_BACKUP_FP /var/www/rutorrent/conf/plugins.ini - # - Merge new install into old to preserve e.g. 3rd party plugins + # Merge new install into old to preserve e.g. 3rd party plugins cp -a ruTorrent-*/. /var/www/rutorrent/ rm -R ruTorrent-* @@ -5171,36 +5145,36 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- Banner_Installing - if [[ -d '/etc/syncthing' ]]; then + if [[ -d '/opt/syncthing' ]]; then - G_DIETPI-NOTIFY 2 "${aSOFTWARE_NAME[$software_id]} install dir \"/etc/syncthing\" already exists. Download and install steps will be skipped. - - If you want to update ${aSOFTWARE_NAME[$software_id]}, please use the internal updater from WebUI. - - if you need to reinstall (e.g. broken instance), please manually backup your config files+data, remove the install dir \"/etc/syncthing\" and rerun \"dietpi-software (re)install $software_id\"." + G_DIETPI-NOTIFY 2 "${aSOFTWARE_NAME[$software_id]} install dir \"/opt/syncthing\" already exists. Download and install steps will be skipped. + - If you want to update ${aSOFTWARE_NAME[$software_id]}, please use the internal updater from web UI. + - if you need to reinstall (e.g. broken instance), please manually backup your config files+data, remove the install dir \"/opt/syncthing\" and rerun \"dietpi-software (re)install $software_id\"." else + # Get latest version from GitHub INSTALL_URL_ADDRESS='https://api.github.com/repos/syncthing/syncthing/releases/latest' G_CHECK_URL "$INSTALL_URL_ADDRESS" - # - armv6+ - if (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then + # ARMv6/7 + local arch='arm' - local arch='arm' - - # - arm64 - elif (( $G_HW_ARCH == 3 )); then + # ARMv8 + if (( $G_HW_ARCH == 3 )); then - local arch='arm64' + arch+='64' - # - x86_64 + # x86_64 elif (( $G_HW_ARCH == 10 )); then - local arch='amd64' + arch='amd64' fi - no_check_url=1 Download_Install "$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 "browser_download_url.*linux-$arch-v[0-9.]*tar\.gz" | cut -d \" -f 4)" /etc - mv /etc/syncthing-* /etc/syncthing + local fallback_url="https://github.com/syncthing/syncthing/releases/download/v1.3.0/syncthing-linux-$arch-v1.3.0.tar.gz" + no_check_url=1 Download_Install "$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 "browser_download_url.*linux-$arch-v[0-9.]*tar\.gz" | cut -d \" -f 4)" + mv syncthing-* /opt/syncthing fi @@ -5364,7 +5338,7 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- [[ -d /etc/couchpotato ]] && rm -R /etc/couchpotato mv CouchPotato* /etc/couchpotato - pip install --upgrade pyopenssl + pip install -U pyopenssl fi @@ -5484,9 +5458,9 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- INSTALL_URL_ADDRESS='https://api.github.com/repos/Jackett/Jackett/releases/latest' G_CHECK_URL "$INSTALL_URL_ADDRESS" - # - ARMv6: Requires mono: https://github.com/Jackett/Jackett#installation-on-linux-armv6-or-below + # - ARMv6: Requires Mono: https://github.com/Jackett/Jackett#installation-on-linux-armv6-or-below INSTALL_URL_ADDRESS=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 'browser_download_url.*Jackett\.Binaries\.Mono\.tar\.gz' | cut -d \" -f 4) - fallback_url='https://github.com/Jackett/Jackett/releases/download/v0.11.295/Jackett.Binaries.Mono.tar.gz' + fallback_url='https://github.com/Jackett/Jackett/releases/download/v0.12.914/Jackett.Binaries.Mono.tar.gz' # - ARMv7 if (( $G_HW_ARCH == 2 )); then @@ -5512,15 +5486,7 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- if (( $G_HW_ARCH != 1 )); then DEPS_LIST='liblttng-ust0' - if (( $G_DISTRO > 4 )); then - - DEPS_LIST+=' libicu63' - - else - - DEPS_LIST+=' libicu57' - - fi + (( $G_DISTRO > 4 )) && DEPS_LIST+=' libicu63' || DEPS_LIST+=' libicu57' fi @@ -5747,37 +5713,32 @@ If you want to update ${aSOFTWARE_NAME[$software_id]}, please use it's internal Banner_Installing - INSTALL_URL_ADDRESS='https://dl.gitea.io/gitea/1.9.4/gitea-1.9.4-' + # Grab latest version from GitHub + INSTALL_URL_ADDRESS='https://api.github.com/repos/go-gitea/gitea/releases/latest' + G_CHECK_URL "$INSTALL_URL_ADDRESS" # wget --spider fails on binary URL - # armv6 - if (( $G_HW_ARCH == 1 )); then - - INSTALL_URL_ADDRESS+='linux-arm-6' - - # armv7 - elif (( $G_HW_ARCH == 2 )); then + # Binary + data dir + mkdir -p $G_FP_DIETPI_USERDATA/gitea/gitea-repositories - INSTALL_URL_ADDRESS+='linux-arm-6' # Workaround since ARMv7 binaries are missing/fail on v1.8.X: https://github.com/MichaIng/DietPi/issues/2959 + # ARMv6 + ARMv7 since as of v1.8 there are issues with ARMv7 binaries on Raspbian which are hence not provided anymore: https://github.com/MichaIng/DietPi/issues/2959 (Troubleshooting) + local arch='arm-6' - # armv8 - elif (( $G_HW_ARCH == 3 )); then + # ARMv8 + if (( $G_HW_ARCH == 3 )); then - INSTALL_URL_ADDRESS+='linux-arm64' + arch='arm64' # x86_64 elif (( $G_HW_ARCH == 10 )); then - INSTALL_URL_ADDRESS+='linux-amd64' + arch='amd64' fi - G_CHECK_URL "$INSTALL_URL_ADDRESS" - - # Data storage / user data - mkdir -p $G_FP_DIETPI_USERDATA/gitea/gitea-repositories - + INSTALL_URL_ADDRESS=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 "\"browser_download_url.*gitea-[0-9.]*-linux-$arch\"" | cut -d \" -f 4) + # - Fallback URL + [[ $INSTALL_URL_ADDRESS ]] || INSTALL_URL_ADDRESS="https://github.com/go-gitea/gitea/releases/download/v1.10.0/gitea-1.10.0-linux-$arch" wget "$INSTALL_URL_ADDRESS" -O $G_FP_DIETPI_USERDATA/gitea/gitea - chmod +x $G_FP_DIETPI_USERDATA/gitea/gitea fi @@ -5869,7 +5830,7 @@ If you want to update ${aSOFTWARE_NAME[$software_id]}, please use it's internal git clone -b voicekit "$INSTALL_URL_ADDRESS" $G_FP_DIETPI_USERDATA/voice-recognizer-raspi cd $G_FP_DIETPI_USERDATA/voice-recognizer-raspi - pip3 install --upgrade pip virtualenv + pip3 install -U pip virtualenv virtualenv --system-site-packages -p python3 env env/bin/pip install -r requirements.txt @@ -5962,6 +5923,77 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y fi + software_id=27 # TasmoAdmin + if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then + + Banner_Installing + + # Install required PHP modules + DEPS_LIST="$PHP_NAME-curl $PHP_NAME-zip" # https://github.com/reloxx13/TasmoAdmin#linux + + # Skip install, if already present + if [[ -d '/var/www/tasmoadmin' ]]; then + + G_DIETPI-NOTIFY 2 "${aSOFTWARE_NAME[$software_id]} install dir \"/var/www/tasmoadmin\" already exists. Download and install steps will be skipped. + - Please manually backup your config files+data, remove the install dir and rerun \"dietpi-software (re)install $software_id\" if you need to reinstall. + - If you want to update the ${aSOFTWARE_NAME[$software_id]} instance, please use the internal updater from WebUI." + G_AGI $DEPS_LIST + unset DEPS_LIST + + else + + Download_Install 'https://github.com/reloxx13/TasmoAdmin/archive/master.tar.gz' + mv TasmoAdmin-master/tasmoadmin /var/www/ + rm -R TasmoAdmin-master + chown -R www-data:www-data /var/www/tasmoadmin + + fi + + # Configure the webserver + if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then + + G_DIETPI-NOTIFY 2 'Apache webserver found, enabling TasmoAdmin specific configuration.' + a2enmod setenvif rewrite authz_core authn_core authn_file 1> /dev/null + local tasmoadmin_conf='/etc/apache2/sites-available/dietpi-tasmoadmin.conf' + if [[ -f $tasmoadmin_conf ]]; then + + tasmoadmin_conf+='.dietpi-new' + G_WHIP_MSG "Existing TasmoAdmin Apache configuration found, will preserve the old one and save the new one for review and comparison to: $tasmoadmin_conf" + + fi + dps_index=$software_id Download_Install 'apache.tasmoadmin.conf' $tasmoadmin_conf + a2ensite dietpi-tasmoadmin 1> /dev/null + + elif (( ${aSOFTWARE_INSTALL_STATE[84]} > 0 )); then + + G_DIETPI-NOTIFY 2 'Lighttpd webserver found, enabling TasmoAdmin specific configuration.' + local tasmoadmin_conf='/etc/lighttpd/conf-available/99-dietpi-tasmoadmin.conf' + if [[ -f $tasmoadmin_conf ]]; then + + tasmoadmin_conf+='.dietpi-new' + G_WHIP_MSG "Existing TasmoAdmin Lighttpd configuration found, will preserve the old one and save the new one for review and comparison to: $tasmoadmin_conf" + + fi + dps_index=$software_id Download_Install 'lighttpd.tasmoadmin.conf' $tasmoadmin_conf + # Enable required modules + our config + lighttpd-enable-mod rewrite dietpi-tasmoadmin + + elif (( ${aSOFTWARE_INSTALL_STATE[85]} > 0 )); then + + G_DIETPI-NOTIFY 2 'Nginx webserver found, enabling TasmoAdmin specific configuration.' + local tasmoadmin_conf='/etc/nginx/sites-dietpi/dietpi-tasmoadmin.conf' + if [[ -f $tasmoadmin_conf ]]; then + + owncloud_conf+='.dietpi-new' + G_WHIP_MSG "Existing TasmoAdmin Nginx configuration found, will preserve the old one and save the new one for review and comparison to: $tasmoadmin_conf" + + fi + dps_index=$software_id Download_Install 'nginx.tasmoadmin.conf' $tasmoadmin_conf + + fi + + fi + #------------------------------------------------------------------- # Reset error handler (eg: for usermsg clear set in Banner_Installing) G_ERROR_HANDLER_RESET @@ -6030,12 +6062,8 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y Banner_Installing - # Assure libegl1-mesa transitional dummy package is skipped (on Stretch via backports) to avoid conflicts with 3rd party repos: https://github.com/MichaIng/DietPi/issues/1794#issuecomment-539138684 - local libegl1='libegl1' - (( $G_DISTRO == 4 )) && libegl1+='/stretch-backports' - # Xserver + generic Mesa OpenGL libraries and utilities - G_AGI $libegl1 xserver-xorg xinit xcompmgr xterm dbus-x11 xfonts-base x11-xserver-utils x11-utils libgl1-mesa-dri mesa-utils mesa-utils-extra + G_AGI xserver-xorg xinit xcompmgr xterm dbus-x11 xfonts-base x11-xserver-utils x11-utils libgl1-mesa-dri mesa-utils mesa-utils-extra # Improve performance on all desktops and devices (eg: removes window lag in desktops) by limiting compositions dps_index=$software_id Download_Install 'xcompmgr.desktop' /etc/xdg/autostart/xcompmgr.desktop @@ -6139,7 +6167,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing - G_AGI build-essential make autoconf automake + G_AGI build-essential automake fi @@ -6263,7 +6291,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y fi - software_id=0 + software_id=0 # OpenSSH Client if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -6271,32 +6299,32 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y fi - software_id=1 + software_id=1 # Samba Client if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing # Remove Information file - rm /mnt/samba/readme.txt &> /dev/null + [[ -f '/mnt/samba/readme.txt' ]] && rm /mnt/samba/readme.txt G_AGI smbclient cifs-utils fi - software_id=110 + software_id=110 # NFS Client if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing # Remove information file - [[ -f /mnt/nfs_client/readme.txt ]] && rm /mnt/nfs_client/readme.txt + [[ -f '/mnt/nfs_client/readme.txt' ]] && rm /mnt/nfs_client/readme.txt # "netbase" is needed for mounting NFSv3: https://github.com/MichaIng/DietPi/issues/1898#issuecomment-406247814 G_AGI nfs-common netbase fi - software_id=104 + software_id=104 # Dropbear if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -6331,7 +6359,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y fi - software_id=105 + software_id=105 # OpenSSH Server if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -6368,10 +6396,9 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y Banner_Installing # Install persistent tmpfs - local tmpfs_max_size=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_RAMLOG_MAXSIZE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') - tmpfs_max_size=${tmpfs_max_size:=50} + local tmpfs_max_size=$(sed -n '/^[[:blank:]]*AUTO_SETUP_RAMLOG_MAXSIZE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) sed -i '/[[:blank:]]\/var\/log[[:blank:]]/d' /etc/fstab - echo "tmpfs /var/log tmpfs defaults,size=${tmpfs_max_size}m,noatime,nodev,nosuid,mode=1777 0 0" >> /etc/fstab + echo "tmpfs /var/log tmpfs size=${tmpfs_max_size:-50}M,noatime,lazytime,nodev,nosuid,mode=1777" >> /etc/fstab # Enable DietPi-RAMdisk systemctl enable dietpi-ramlog @@ -6384,7 +6411,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y fi - software_id=101 + software_id=101 # Logrotate if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -6392,7 +6419,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y fi - software_id=102 + software_id=102 # Rsyslog if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -6417,8 +6444,10 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y Banner_Installing - local version=8 - (( $G_DISTRO == 5 )) && version=11 + # On Stretch and ARMv6 (RPi 1/Zero) use Java 8, else most current + # Stretch does not ship Java 11 yet, ARMv6 is not Java 11 compatible, but luckily Raspbian ships Java 8 even on Bullseye: https://github.com/MichaIng/DietPi/issues/3182 + local version=11 + (( $G_DISTRO < 5 || G_HW_ARCH == 1 )) && version=8 local packages="ca-certificates-java openjdk-$version-jre-headless openjdk-$version-jdk-headless" # Workaround for ARM install issue: https://github.com/MichaIng/DietPi/issues/2524 @@ -6454,7 +6483,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y INSTALL_URL_ADDRESS='https://bootstrap.pypa.io/get-pip.py' G_CHECK_URL "$INSTALL_URL_ADDRESS" - # - Preqs + # Preqs G_AGI python python-dev wget "$INSTALL_URL_ADDRESS" -O install.py @@ -6496,52 +6525,69 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y Banner_Installing - local ha_user="homeassistant" - local ha_userroot="/home/$ha_user" - local ha_srvroot="/srv/homeassistant" - local ha_pyenv_activation="export PATH=\"$ha_userroot/.pyenv/bin:\$PATH\"; eval \"\$(pyenv init -)\"; eval \"\$(pyenv virtualenv-init -)\"" - local ha_python_version="3.6.3" + local ha_user='homeassistant' + local ha_home="/home/$ha_user" + local ha_pyenv_activation="source $ha_home/pyenv-activate.sh" + local ha_python_version='3.8.0' G_DIETPI-NOTIFY 2 "ha_user: $ha_user" - G_DIETPI-NOTIFY 2 "ha_userroot: $ha_userroot" - G_DIETPI-NOTIFY 2 "ha_srvroot: $ha_srvroot" + G_DIETPI-NOTIFY 2 "ha_home: $ha_home" G_DIETPI-NOTIFY 2 "ha_pyenv_activation: $ha_pyenv_activation" G_DIETPI-NOTIFY 2 "ha_python_version: $ha_python_version" - # Install needed libraries - G_AGI cmake daemon gcc nmap net-tools swig uuid-dev libc-ares-dev libgnutls28-dev libgnutlsxx28 libglib2.0-dev libudev-dev libusb-1.0-0 libssl-dev libffi-dev libbz2-dev zlib1g-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev libmariadbclient-dev - - # Setup the user account information - adduser --system $ha_user - addgroup $ha_user - # This allows the dietpi user to edit the files along with HA. - usermod -G dietpi,dialout -a $ha_user - mkdir $ha_srvroot - chown $ha_user:$ha_user $ha_srvroot - - # Install pyenv - su --shell /bin/bash --command "cd $ha_userroot; curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash" $ha_user - - # Install Python which is needed for HA. - su --shell /bin/bash --command "cd $ha_userroot; $ha_pyenv_activation; pyenv install $ha_python_version" $ha_user - - # Make the virtual environment. - su --shell /bin/bash --command "cd $ha_srvroot; $ha_pyenv_activation; pyenv virtualenv $ha_python_version homeassistant-$ha_python_version" $ha_user - su --shell /bin/bash --command "cd $ha_srvroot; $ha_pyenv_activation; pyenv local homeassistant-$ha_python_version" $ha_user - su --shell /bin/bash --command "cd $ha_srvroot; $ha_pyenv_activation; pyenv local" $ha_user - - # Install Home Assistant and extra modules. - su --shell /bin/bash --command "cd $ha_srvroot; $ha_pyenv_activation; pyenv activate homeassistant-$ha_python_version; pip3 install colorlog PyMySQL mysqlclient" $ha_user - su --shell /bin/bash --command "cd $ha_srvroot; $ha_pyenv_activation; pyenv activate homeassistant-$ha_python_version; pip3 install --upgrade homeassistant" $ha_user - - # Generate the scripts to launch HA using pyenv. - echo '#!/bin/bash' > $ha_srvroot/homeassistant-start.sh - echo "cd $ha_srvroot" >> $ha_srvroot/homeassistant-start.sh - echo "$ha_pyenv_activation" >> $ha_srvroot/homeassistant-start.sh - echo "pyenv activate homeassistant-$ha_python_version" >> $ha_srvroot/homeassistant-start.sh - echo "hass -c \"$ha_userroot/.homeassistant\"" >> $ha_srvroot/homeassistant-start.sh - #su --shell /bin/bash --command "/srv/homeassistant/homeassistant-start.sh" homeassistant - chmod +x /srv/homeassistant/homeassistant-start.sh + # User + local usercmd='useradd -rMU' + getent passwd $ha_user &> /dev/null && usercmd='usermod -a' + $usercmd -G dialout -d $ha_home -s $(command -v nologin) $ha_user + + # Start with fresh instance, to allow clean pyenv and Python updates and fix broken instances. All userdata and configs are preserved in: /mnt/dietpi_userdata/homeassistant + [[ -d $ha_home/.pyenv ]] && rm -R $ha_home/.pyenv + [[ -d '/srv/homeassistant' ]] && rm -R /srv/homeassistant # pre-v6-27 + + # APT dependencies + # - MariaDB support: (( $G_DISTRO < 5 )) && G_AGI libmariadbclient-dev || G_AGI libmariadb-dev + # - Read custom build dependencies + local custom_apt_deps=$(sed -n '/^[[:blank:]]*SOFTWARE_HOMEASSISTANT_APT_DEPS=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + DEPS_LIST="gcc libc6-dev make zlib1g-dev libbz2-dev libreadline-dev libssl-dev libsqlite3-dev libffi-dev $custom_apt_deps" + + # Install pyenv to $ha_home + mkdir -p $ha_home + Download_Install 'https://github.com/pyenv/pyenv/archive/master.tar.gz' + mv pyenv-master $ha_home/.pyenv + chown -R $ha_user:$ha_user $ha_home + + # Generate script to activate pyenv: This must be sourced from the originating shell, hence it does not require execute permissions. + echo "#!/bin/dash +if [ \$(whoami) != $ha_user ]; then + echo '[FAILED] This pyenv must be activated as user \"homeassistant\". Aborting...' + kill -INT \$\$ +fi +cd $ha_home +export PATH=\"$ha_home/.pyenv/bin:\$PATH\" +eval \"\$(pyenv init -)\"" > $ha_home/pyenv-activate.sh + + # Install Python with Home Assistant module into pyenv + # - Read custom Python modules + local custom_pip_deps=$(sed -n '/^[[:blank:]]*SOFTWARE_HOMEASSISTANT_PIP_DEPS=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + # - MariaDB support: pip3 install mysqlclient|PyMySQL + # - Workaround: Install home-assistant-frontend: https://github.com/home-assistant/home-assistant/issues/28361#issuecomment-550070511 + sudo -u $ha_user dash -c " +$ha_pyenv_activation +pyenv install $ha_python_version +pyenv local $ha_python_version +pip3 install -U pip +[ -z "$custom_pip_deps" ]] || pip3 install $custom_pip_deps +pip3 install homeassistant home-assistant-frontend==20191025.1" + + # Generate script to launch HA using pyenv + echo "#!/bin/dash +$ha_pyenv_activation +hass -c '$G_FP_DIETPI_USERDATA/homeassistant'" > $ha_home/homeassistant-start.sh + chmod +x $ha_home/homeassistant-start.sh + + # Generate script to update HA within pyenv + echo "#!/bin/dash +sudo -u $ha_user dash -c '$ha_pyenv_activation; pip3 install -U homeassistant'" > $ha_home/homeassistant-update.sh fi @@ -6576,7 +6622,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y # Work out which SSH server needs removing (if any) if (( $INDEX_SSHSERVER_TARGET != $INDEX_SSHSERVER_CURRENT )); then - # - No SSH server + # No SSH server if (( $INDEX_SSHSERVER_TARGET == 0 )); then # Check currently installed SSH servers via "dpkg --get-selections" to be failsafe @@ -6585,12 +6631,12 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y grep -q '^dropbear[^[:blank:]]*[[:blank:]]' <<< "$dpkg_out" && aSOFTWARE_INSTALL_STATE[104]=-1 && UNINSTALL_REQUIRED=1 grep -q '^openssh-server[[:blank:]]' <<< "$dpkg_out" && aSOFTWARE_INSTALL_STATE[105]=-1 && UNINSTALL_REQUIRED=1 - # - Dropbear + # Dropbear elif (( $INDEX_SSHSERVER_TARGET == -1 )); then aSOFTWARE_INSTALL_STATE[104]=1 - # - OpenSSH + # OpenSSH elif (( $INDEX_SSHSERVER_TARGET == -2 )); then aSOFTWARE_INSTALL_STATE[105]=1 @@ -6603,14 +6649,14 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y Apply_FileServer_Choices(){ - # Work out which File Server needs installing from IDs (if any) - # Work out which File server needs removing (if any) + # Work out which file Server needs installing from IDs (if any) + # Work out which file server needs removing (if any) if (( $INDEX_FILESERVER_TARGET != $INDEX_FILESERVER_CURRENT )); then # Run uninstall of old file servers, after install loop UNINSTALL_REQUIRED=1 - # No File server + # No file server if (( $INDEX_FILESERVER_TARGET == 0 )); then (( ${aSOFTWARE_INSTALL_STATE[94]} == 2 )) && aSOFTWARE_INSTALL_STATE[94]=-1 @@ -6630,7 +6676,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y fi - # Update Current SSHSERVER index + # Update current file server index INDEX_FILESERVER_CURRENT=$INDEX_FILESERVER_TARGET fi @@ -6667,7 +6713,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y (( ${aSOFTWARE_INSTALL_STATE[101]} == 2 )) && aSOFTWARE_INSTALL_STATE[101]=-1 (( ${aSOFTWARE_INSTALL_STATE[102]} == 2 )) && aSOFTWARE_INSTALL_STATE[102]=-1 - # Logrotate + rsyslog - logs to disk + # Logrotate + Rsyslog - logs to disk elif (( $INDEX_LOGGING_TARGET == -3 )); then aSOFTWARE_INSTALL_STATE[101]=1 @@ -6676,7 +6722,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y fi - # Update Current Logging index + # Update current logging index INDEX_LOGGING_CURRENT=$INDEX_LOGGING_TARGET fi @@ -6687,7 +6733,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y if (( $INDEX_WEBSERVER_TARGET != $INDEX_WEBSERVER_CURRENT )); then - # Update Current to Target + # Update current webserver index INDEX_WEBSERVER_CURRENT=$INDEX_WEBSERVER_TARGET fi @@ -6712,23 +6758,23 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y mkdir -p /root/.config/lxpanel/LXDE/panels mkdir -p /root/.config/pcmanfm/LXDE - # - PCmanFM configs + # PCmanFM configs G_THREAD_START wget https://raw.githubusercontent.com/MichaIng/DietPi/$G_GITBRANCH/.conf/desktop/lxde/pcmanfm.conf -O /root/.config/pcmanfm/LXDE/pcmanfm.conf G_THREAD_START wget https://raw.githubusercontent.com/MichaIng/DietPi/$G_GITBRANCH/.conf/desktop/lxde/pcmanfm-desktopitems.conf -O /root/.config/pcmanfm/LXDE/desktop-items-0.conf - # - Panel config + # Panel config G_THREAD_START wget https://raw.githubusercontent.com/MichaIng/DietPi/$G_GITBRANCH/.conf/desktop/lxde/panel -O /root/.config/lxpanel/LXDE/panels/panel - # - Openbox config + # Openbox config G_THREAD_START wget https://raw.githubusercontent.com/MichaIng/DietPi/$G_GITBRANCH/.conf/desktop/lxde/lxde-rc.xml -O /root/.config/openbox/lxde-rc.xml - # - Remove Lxrandr Menu item (monitor configuration tool as we set res in dietpi-config) + # Remove Lxrandr Menu item (monitor configuration tool as we set res in dietpi-config) [[ -f '/usr/share/applications/lxrandr.desktop' ]] && rm /usr/share/applications/lxrandr.desktop - # - Disable Trash + # Disable Trash G_CONFIG_INJECT 'use_trash=' 'use_trash=0' /etc/xdg/libfm/libfm.conf - # - Firefox optimizations + # Firefox optimizations # ??? These keep adding new entries, ignore existing entry??? #G_CONFIG_INJECT 'extensions.update.enabled' 'pref("extensions.update.enabled", false);' /etc/firefox-esr/firefox-esr.js #G_CONFIG_INJECT 'datareporting.healthreport.uploadEnabled' 'pref("datareporting.healthreport.uploadEnabled", false);' /etc/firefox-esr/firefox-esr.js @@ -6739,7 +6785,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y Create_Desktop_Shared_Items - # - file manager desktop icon + # File manager desktop icon ln -sf /usr/share/applications/pcmanfm.desktop /root/Desktop/pcmanfm.desktop fi @@ -6755,11 +6801,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y ln -sf /usr/share/applications/caja.desktop /root/Desktop/caja.desktop # Odroid C2, define default pulseaudio sink: https://github.com/MichaIng/DietPi/issues/415 - if (( $G_HW_MODEL == 12 )); then - - G_CONFIG_INJECT 'set-default-sink[[:blank:]]' 'set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo' /etc/pulse/default.pa - - fi + (( $G_HW_MODEL == 12 )) && G_CONFIG_INJECT 'set-default-sink[[:blank:]]' 'set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo' /etc/pulse/default.pa fi @@ -6794,7 +6836,7 @@ Mycroft AI requires at least 2 GiB memory on first start. We will now increase y fi - software_id=83 # Apache Webserver + software_id=83 # Apache if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Configuration @@ -6855,7 +6897,7 @@ _EOF_ fi - software_id=85 # Nginx Webserver + software_id=85 # Nginx if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Configuration @@ -6880,7 +6922,7 @@ _EOF_ fi - software_id=84 # Lighttpd Webserver + software_id=84 # Lighttpd if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Configuration @@ -7018,7 +7060,7 @@ _EOF_ fi - software_id=88 # MariaDB Database + software_id=88 # MariaDB if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Configuration @@ -7075,7 +7117,7 @@ _EOF_ fi - software_id=91 # Redis Database + software_id=91 # Redis if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Configuration @@ -7215,12 +7257,18 @@ _EOF_ Banner_Configuration G_DIETPI-NOTIFY 2 'Enabling needed PHP modules.' # https://doc.owncloud.org/server/administration_manual/installation/manual_installation.html#php-extensions - phpenmod curl gd intl json pdo_mysql opcache apcu redis ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif + phpenmod ctype curl dom gd iconv intl json mbstring pdo_mysql posix simplexml xmlreader xmlwriter zip fileinfo opcache apcu redis exif G_DIETPI-NOTIFY 2 'Enabling APCu memory cache for PHP command line usage (CLI) as well, including ownCloud occ command and cron jobs.' echo -e '; ownCloud PHP settngs\n; priority=99\napc.enable_cli=1' > $FP_PHP_BASE_DIR/mods-available/dietpi-owncloud.ini phpenmod dietpi-owncloud + # Get version string + local oc_version_major=$(sed -n '/$OC_VersionString/{s/^[^0-9]*//;s/\..*$//;p;q}' /var/www/owncloud/version.php) + [[ $oc_version_major ]] || oc_version_major=10 + local oc_version_minor=$(sed -n '/$OC_VersionString/{s/^[^.]*\.//;s/\..*$//;p;q}' /var/www/owncloud/version.php) + [[ $oc_version_minor ]] || oc_version_minor=3 + if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then G_DIETPI-NOTIFY 2 'Apache webserver found, enabling ownCloud specific configuration.' # https://doc.owncloud.org/server/administration_manual/installation/manual_installation.html#configure-apache-web-server @@ -7235,7 +7283,7 @@ _EOF_ dps_index=$software_id Download_Install 'apache.owncloud.conf' $owncloud_conf a2ensite dietpi-owncloud 1> /dev/null # Cal/CardDAV redirects to ownCloud DAV endpoint - if [[ ! -f /etc/apache2/conf-available/dietpi-dav_redirect.conf ]]; then + if [[ ! -f '/etc/apache2/conf-available/dietpi-dav_redirect.conf' ]]; then echo '# Redirect Cal/CardDAV requests to ownCloud endpoint: Redirect permanent /.well-known/carddav /owncloud/remote.php/dav @@ -7265,7 +7313,7 @@ Redirect permanent /.well-known/caldav /owncloud/remote.php/dav' > /etc/apache2/ lighttpd-enable-mod dietpi-owncloud # Cal/CardDAV redirects to ownCloud DAV endpoint - if [[ ! -f /etc/lighttpd/conf-enabled/99-dietpi-dav_redirect.conf ]]; then + if [[ ! -f '/etc/lighttpd/conf-enabled/99-dietpi-dav_redirect.conf' ]]; then echo '# Redirect Cal/CardDAV requests to ownCloud endpoint: url.redirect += ( @@ -7286,23 +7334,18 @@ url.redirect += ( G_WHIP_MSG "Existing ownCloud Nginx configuration found, will preserve the old one and save the new one for review and comparison to: $owncloud_conf" fi - dps_index=$software_id Download_Install 'nginx.owncloud.conf' $owncloud_conf # Uncomment HSTS header, if chosen via dietpi-letsencrypt and HTTPS connection test succeeds (incl. self-singed cert => exit code 5) - if [[ -f /DietPi/dietpi/.dietpi-letsencrypt && $(sed -n 4p /DietPi/dietpi/.dietpi-letsencrypt) == 1 ]]; then + if [[ -f '/DietPi/dietpi/.dietpi-letsencrypt' && $(mawk 'NR==4' /DietPi/dietpi/.dietpi-letsencrypt) == 1 ]]; then wget -q --spider --timeout=10 --tries=2 https://localhost &> /dev/null - (( $? == 0 || $? == 5)) && sed -i 's/#add_header Strict-Transport-Security/add_header Strict-Transport-Security/g' $owncloud_conf + [[ $? == [05] ]] && sed -i 's/#add_header Strict-Transport-Security/add_header Strict-Transport-Security/g' $owncloud_conf fi - # Disable pretty URLs (front controller), if ownCloud version is lower than 10: - if (( $(grep '$OC_VersionString' /var/www/owncloud/version.php | sed "s/^.*= '//" | sed "s/\..*$//") < 10 )); then - - sed -i 's/^[[:blank:]]*fastcgi_param front_controller_active true;/\t\t#fastcgi_param front_controller_active true;/g' $owncloud_conf - - fi + # Disable pretty URLs (front controller) for ownCloud versions lower than 10: + (( $oc_version_major < 10 )) && sed -i 's/^[[:blank:]]*fastcgi_param front_controller_active true;/\t\t#fastcgi_param front_controller_active true;/g' $owncloud_conf # Cal/CardDAV redirects to ownCloud DAV endpoint if [[ ! -f '/etc/nginx/sites-dietpi/dietpi-dav_redirect.conf' ]]; then @@ -7386,8 +7429,8 @@ location = /.well-known/caldav { # If "1 => '" does not exist, the config.php is not copied e.g. from older instance, so we add entries. if ! grep -q "1 => '" $config_php; then - sed -i "/0 => 'localhost'/a 1 => '$(sed -n 4p /DietPi/dietpi/.network)'," $config_php - sed -i "/1 => '/a 2 => '$(cat /etc/hostname)'," $config_php + sed -i "/0 => 'localhost'/a 1 => '$(mawk 'NR==4' /DietPi/dietpi/.network)'," $config_php + sed -i "/1 => '/a 2 => '$( true," $config_php "'memcache.local'" GCI_PRESERVE=1 GCI_NEWLINE=1 G_CONFIG_INJECT "'memcache.locking'" "'memcache.locking' => '\\\\OC\\\\Memcache\\\\Redis',\n'redis' => array ('host' => '$redis_sock', 'port' => 0,)," $config_php "'filelocking.enabled'" # Enable ownCloud background cron job: - crontab -u www-data -l 2>/dev/null | grep -q '/var/www/owncloud/cron.php' || ( crontab -u www-data -l 2>/dev/null ; echo "*/15 * * * * php /var/www/owncloud/cron.php" ) | crontab -u www-data - + # - v10.3 comes with new occ system:cron command: https://doc.owncloud.org/server/10.3/admin_manual/release_notes.html#changes-to-background-job-execution + local occ_command='occ system:cron' + (( $oc_version_major < 10 || ( $oc_version_major == 10 && $oc_version_minor < 3 ) )) && occ_command='cron.php' + crontab -u www-data -l 2>/dev/null | grep -q '/var/www/owncloud/.*cron' || ( crontab -u www-data -l 2>/dev/null ; echo "*/15 * * * * php /var/www/owncloud/$occ_command" ) | crontab -u www-data - occ background:cron # Enable maintenance mode to allow handling by dietpi-services: @@ -7445,7 +7491,7 @@ location = /.well-known/caldav { Banner_Configuration G_DIETPI-NOTIFY 2 'Enabling required PHP modules.' # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation - phpenmod curl gd intl json pdo_mysql opcache apcu redis ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif + phpenmod ctype curl dom gd iconv intl json mbstring pdo_mysql posix simplexml xmlreader xmlwriter zip fileinfo opcache apcu redis exif G_DIETPI-NOTIFY 2 'Optimising APCu and OPcache modules for Nextcloud.' # https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/server_tuning.html#enable-php-opcache echo -e '; Nextcloud PHP settngs\n; priority=99\napc.enable_cli=1\nopcache.enable=1\nopcache.interned_strings_buffer=8 @@ -7466,7 +7512,7 @@ opcache.max_accelerated_files=10000\nopcache.memory_consumption=128\nopcache.sav dps_index=$software_id Download_Install 'apache.nextcloud.conf' $nextcloud_conf a2ensite dietpi-nextcloud 1> /dev/null # Cal/CardDAV redirects to Nextcloud DAV endpoint - if [[ ! -f /etc/apache2/conf-available/dietpi-dav_redirect.conf ]]; then + if [[ ! -f '/etc/apache2/conf-available/dietpi-dav_redirect.conf' ]]; then echo '# Redirect Cal/CardDAV requests to Nextcloud endpoint: Redirect permanent /.well-known/carddav /nextcloud/remote.php/dav @@ -7496,7 +7542,7 @@ Redirect permanent /.well-known/caldav /nextcloud/remote.php/dav' > /etc/apache2 lighttpd-enable-mod dietpi-nextcloud # Cal/CardDAV redirects to Nextcloud DAV endpoint - if [[ ! -f /etc/lighttpd/conf-enabled/99-dietpi-dav_redirect.conf ]]; then + if [[ ! -f '/etc/lighttpd/conf-enabled/99-dietpi-dav_redirect.conf' ]]; then echo '# Redirect Cal/CardDAV requests to Nextcloud endpoint: url.redirect += ( @@ -7520,15 +7566,15 @@ url.redirect += ( dps_index=$software_id Download_Install 'nginx.nextcloud.conf' $nextcloud_conf # Uncomment HSTS header, if chosen via dietpi-letsencrypt and HTTPS connection test succeeds (incl. self-singed cert => exit code 5) - if [[ -f /DietPi/dietpi/.dietpi-letsencrypt && $(sed -n 4p /DietPi/dietpi/.dietpi-letsencrypt) == 1 ]]; then + if [[ -f '/DietPi/dietpi/.dietpi-letsencrypt' && $(mawk 'NR==4' /DietPi/dietpi/.dietpi-letsencrypt) == 1 ]]; then wget -q --spider --timeout=10 --tries=2 https://localhost &> /dev/null - (( $? == 0 || $? == 5)) && sed -i 's/#add_header Strict-Transport-Security/add_header Strict-Transport-Security/g' $nextcloud_conf + [[ $? == [05] ]] && sed -i 's/#add_header Strict-Transport-Security/add_header Strict-Transport-Security/g' $nextcloud_conf fi # Disable pretty URLs (front controller), if Nextcloud version is lower than 13 - if (( $(grep '$OC_VersionString' /var/www/nextcloud/version.php | sed "s/^.*= '//" | sed "s/\..*$//") < 13 )); then + if (( $(sed -n '/$OC_VersionString/{s/^[^0-9]*//;s/\..*$//;p;q}' /var/www/nextcloud/version.php) < 13 )); then sed -i 's/^[[:blank:]]*fastcgi_param front_controller_active true;/\t\t#fastcgi_param front_controller_active true;/g' $nextcloud_conf @@ -7644,11 +7690,7 @@ The install script will now exit. After applying one of the the above, rerun die G_CONFIG_INJECT "'mysql.utf8mb4'" "'mysql.utf8mb4' => true," $config_php "'dbpassword'" # Disable trusted_domains. - if ! grep -q "1 => '*'" $config_php; then - - sed -i "/0 => 'localhost'/a 1 => '*'," $config_php - - fi + grep -q "1 => '*'" $config_php || sed -i "/0 => 'localhost'/a 1 => '*'," $config_php # Set CLI URL to Nextcloud sub directory: sed -i "s|'http://localhost'|'http://localhost/nextcloud'|g" $config_php @@ -7683,14 +7725,14 @@ The install script will now exit. After applying one of the the above, rerun die fi local redis_sock=$(grep -m1 '^[[:blank:]]*unixsocket[[:blank:]]' $redis_conf | mawk '{print $2}') - usermod -a -G redis www-data + usermod -aG redis www-data G_RUN_CMD systemctl restart redis-server # - Enable Nextloud to use Redis socket: G_CONFIG_INJECT "'filelocking.enabled'" "'filelocking.enabled' => true," $config_php "'memcache.local'" GCI_PRESERVE=1 GCI_NEWLINE=1 G_CONFIG_INJECT "'memcache.locking'" "'memcache.locking' => '\\\\OC\\\\Memcache\\\\Redis',\n'redis' => array ('host' => '$redis_sock', 'port' => 0,)," $config_php "'filelocking.enabled'" - # Enable Nextcloud background cron job: - crontab -u www-data -l 2>/dev/null | grep -q '/var/www/nextcloud/cron.php' || ( crontab -u www-data -l 2>/dev/null ; echo "*/15 * * * * php /var/www/nextcloud/cron.php" ) | crontab -u www-data - + # Enable Nextcloud background cron job: https://docs.nextcloud.com/server/17/admin_manual/configuration_server/background_jobs_configuration.html#cron + crontab -u www-data -l 2>/dev/null | grep -q '/var/www/nextcloud/cron.php' || ( crontab -u www-data -l 2>/dev/null ; echo '*/5 * * * * php /var/www/nextcloud/cron.php' ) | crontab -u www-data - ncc background:cron # Convert filecache tables to bigint, which is not done anymore automatically by Nextcloud since v15 @@ -7710,21 +7752,21 @@ The install script will now exit. After applying one of the the above, rerun die # Buster: systemd unit if [[ -f '/lib/systemd/system/coturn.service' ]]; then - # - Remove sysvinit service traces + # Remove sysvinit service traces [[ -f '/etc/init.d/coturn' ]] && rm /etc/init.d/coturn update-rc.d -f coturn remove [[ -f '/etc/default/coturn' ]] && rm /etc/default/coturn - # - Disable coturn logging by default, this can be overridden via /etc/turnserver.conf + # Disable coturn logging by default, this can be overridden via /etc/turnserver.conf mkdir -p /etc/systemd/system/coturn.service.d echo -e "[Service]\nExecStart=\n$(grep -m1 "^[[:blank:]]*ExecStart=" /lib/systemd/system/coturn.service) -l stdout --no-stdout-log --simple-log" > /etc/systemd/system/coturn.service.d/dietpi-logging.conf # Stretch: sysvinit service else - # - Enable init.d service + # Enable init.d service G_CONFIG_INJECT 'TURNSERVER_ENABLED=' 'TURNSERVER_ENABLED=1' /etc/default/coturn - # - Disable coturn logging by default, this can be overridden via /etc/turnserver.conf + # Disable coturn logging by default, this can be overridden via /etc/turnserver.conf G_CONFIG_INJECT 'DAEMON_ARGS=' "DAEMON_ARGS='-c /etc/turnserver.conf -o -l stdout --no-stdout-log --simple-log'" /etc/default/coturn fi @@ -7737,7 +7779,7 @@ The install script will now exit. After applying one of the the above, rerun die G_WHIP_DEFAULT_ITEM=$domain G_WHIP_INPUTBOX "${invalid_text}Please enter your servers external domain to allow Nextcloud Talk access your TURN server:" - if (( $? == 0 )) && [[ $G_WHIP_RETURNED_VALUE ]]; then + if [[ $? == 0 && $G_WHIP_RETURNED_VALUE ]]; then domain=${G_WHIP_RETURNED_VALUE#http*://} break @@ -7928,7 +7970,7 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal # MPD service/confs [[ -f '/etc/default/mpd' ]] && rm /etc/default/mpd - # - Upsteam systemd unit: https://github.com/MusicPlayerDaemon/MPD/blob/master/systemd/system/mpd.service.in + # - Upstream systemd unit: https://github.com/MusicPlayerDaemon/MPD/blob/master/systemd/system/mpd.service.in # - Debian package systemd unit: https://deb.debian.org/debian/pool/main/m/mpd/ cat << _EOF_ > /lib/systemd/system/mpd.service [Unit] @@ -7969,19 +8011,19 @@ _EOF_ # JustBoom specials if grep -qi '^[[:blank:]]*CONFIG_SOUNDCARD=justboom' /DietPi/dietpi.txt; then - # - Name displayed in YMPD sound button + # Name displayed in YMPD sound button local justboom_soundcard_desc='JustBoom DietPi' G_CONFIG_INJECT 'name "' "name \"$justboom_soundcard_desc\"" /etc/mpd.conf G_CONFIG_INJECT 'zeroconf_name "' "zeroconf_name \"$justboom_soundcard_desc\"" /etc/mpd.conf - # - Output (192khz 32bit) + # Output (192khz 32bit) local target_bitdepth=32 local target_rate=192000 G_CONFIG_INJECT 'format "' "format \"$target_rate:$target_bitdepth:2\"" /etc/mpd.conf G_CONFIG_INJECT 'audio_output_format "' "audio_output_format \"$target_rate:$target_bitdepth:2\"" /etc/mpd.conf - # - Set SOXR quality - # All RPi's can handle SOXR VH @ 192khz 32bit: https://github.com/MichaIng/DietPi/issues/581#issuecomment-256643079 + # Set SOXR quality + # - All RPi's can handle SOXR VH @ 192khz 32bit: https://github.com/MichaIng/DietPi/issues/581#issuecomment-256643079 G_CONFIG_INJECT 'samplerate_converter "' 'samplerate_converter "soxr very high"' /etc/mpd.conf #highest fi @@ -8001,7 +8043,7 @@ _EOF_ Banner_Configuration - G_CONFIG_INJECT 'root' '#root' /etc/ftpusers + sed -i 's/^[[:blank:]]*root/#root/' /etc/ftpusers G_BACKUP_FP /etc/proftpd/proftpd.conf dps_index=$software_id Download_Install 'conf' /etc/proftpd/proftpd.conf @@ -8028,7 +8070,7 @@ _EOF_ Banner_Configuration - G_CONFIG_INJECT 'root' '#root' /etc/ftpusers + sed -i 's/^[[:blank:]]*root/#root/' /etc/ftpusers local fp_conf='/etc/vsftpd.conf' G_BACKUP_FP $fp_conf @@ -8042,10 +8084,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Configuration - - cat << _EOF_ > /etc/exports -$G_FP_DIETPI_USERDATA *(rw,async,no_root_squash,fsid=0,crossmnt,no_subtree_check) -_EOF_ + echo "$G_FP_DIETPI_USERDATA *(rw,async,no_root_squash,fsid=0,crossmnt,no_subtree_check)" > /etc/exports fi @@ -8058,7 +8097,7 @@ _EOF_ getent passwd ympd &> /dev/null && usercmd='usermod -a' $usercmd -G dietpi,audio -s $(command -v nologin) ympd # - Add to new "render" group on Buster - (( $G_DISTRO > 4 )) && usermod -a -G render ympd + (( $G_DISTRO > 4 )) && usermod -aG render ympd # Service cat << _EOF_ > /etc/systemd/system/ympd.service @@ -8133,8 +8172,10 @@ _EOF_ getent passwd nodered &> /dev/null && usercmd='usermod' $usercmd -d $G_FP_DIETPI_USERDATA/node-red -s $(command -v nologin) nodered - # - Only add user to "gpio" group, if it does exist (most SBCs), otherwise user creation fails: https://github.com/MichaIng/DietPi/issues/2975#issuecomment-513917360 + # - Add user to "gpio" and "i2c" groups, if present + # NB: This must be an own command, since useradd/usermod would fail in case group(s) do(es) not exist, e.g. on non-RPi/SBC devices: https://github.com/MichaIng/DietPi/issues/2975#issuecomment-513917360 getent group gpio &> /dev/null && usermod -aG gpio nodered + getent group i2c &> /dev/null && usermod -aG i2c nodered # - Allow sudo calls echo 'nodered ALL=NOPASSWD: ALL' > /etc/sudoers.d/nodered @@ -8162,9 +8203,9 @@ _EOF_ Banner_Configuration - local java=8 - (( $G_DISTRO > 4 )) && java=11 - G_CONFIG_INJECT 'JAVA_HOME=' "JAVA_HOME=$(find /usr/lib/jvm/ -name java-$java-openjdk*)" /etc/default/tomcat8 + local version=11 + (( $G_DISTRO < 5 || G_HW_MODEL == 1 )) && version=8 + G_CONFIG_INJECT 'JAVA_HOME=' "JAVA_HOME=$(find /usr/lib/jvm/ -name java-$version-openjdk*)" /etc/default/tomcat8 fi @@ -8173,16 +8214,16 @@ _EOF_ Banner_Configuration - # - Cava conf + # Cava conf mkdir -p /root/.config/cava G_BACKUP_FP /root/.config/cava/config cp /var/lib/dietpi/dietpi-software/conf/cava.conf /root/.config/cava/config - # - lower MPD buffer size to reduce latency of spectrum: + # Lower MPD buffer size to reduce latency of spectrum: sed -i '/audio_buffer_size /c\audio_buffer_size "384"' /etc/mpd.conf - # - fifo stream for mpd + # fifo stream for mpd if ! grep -q '/tmp/mpd.fifo' /etc/mpd.conf; then cat << _EOF_ >> /etc/mpd.conf @@ -8329,15 +8370,15 @@ _EOF_ # noip2 service file cat << _EOF_ > /etc/systemd/system/noip2.service [Unit] -Description=noip2 (DietPi) -After=network.target network-online.target rsyslog.service +Description=No-IP update client (DietPi) +Wants=network-online.target +After=network-online.target rsyslog.service ConditionPathExists=/usr/local/etc/no-ip2.conf [Service] Type=forking -RemainAfterExit=yes ExecStart=/usr/local/bin/noip2 -ExecStop=/usr/bin/killall -w noip2 +ExecStop=$(command -v killall) -w noip2 [Install] WantedBy=multi-user.target @@ -8350,96 +8391,23 @@ _EOF_ Banner_Configuration - local amiberry_filename - local capsimg_filename='capsimg-rpi.so' - - # ASUS TB - if (( $G_HW_MODEL == 52 )); then - - amiberry_filename='amiberry-tinker' - capsimg_filename='capsimg-tinker.so' - - # XU4 - elif (( $G_HW_MODEL == 11 )); then - - amiberry_filename='amiberry-xu4' - capsimg_filename='capsimg-xu4.so' - - # RPi4 - elif (( $G_HW_MODEL == 4 )); then - - amiberry_filename='amiberry-rpi4-sdl2-dispmanx' - - # RPi3 - elif (( $G_HW_MODEL == 3 )); then - - amiberry_filename='amiberry-rpi3-sdl2-dispmanx' - - # RPi2 - elif (( $G_HW_MODEL == 2 )); then - - amiberry_filename='amiberry-rpi2-sdl2-dispmanx' - - # Assume RPi1 (ARMv6) - else - - amiberry_filename='amiberry-rpi1-sdl2-dispmanx' - - fi - - # Update executable and capsimg.so - mv "$G_FP_DIETPI_USERDATA/amiberry/$amiberry_filename" $G_FP_DIETPI_USERDATA/amiberry/amiberry - mv "$G_FP_DIETPI_USERDATA/amiberry/$capsimg_filename" $G_FP_DIETPI_USERDATA/amiberry/capsimg.so - rm $G_FP_DIETPI_USERDATA/amiberry/{amiberry,capsimg}-* - - # Create additional user media directories - mkdir -p $G_FP_DIETPI_USERDATA/amiberry/{floppy_images,hdf,cd} - - # Remove obsolete and old config file to allow Amiberry recreating it: https://github.com/midwan/amiberry/releases/tag/v2.25 + # Reinstall: Remove obsolete and old config file to allow Amiberry recreating it: https://github.com/midwan/amiberry/releases/tag/v2.25 [[ -f $G_FP_DIETPI_USERDATA/amiberry/conf/adfdir.conf ]] && rm $G_FP_DIETPI_USERDATA/amiberry/conf/adfdir.conf [[ -f $G_FP_DIETPI_USERDATA/amiberry/conf/amiberry.conf ]] && rm $G_FP_DIETPI_USERDATA/amiberry/conf/amiberry.conf - # Uae4arm does not support browsing symlinks: https://github.com/MichaIng/DietPi/issues/474#issuecomment-242973839 - # - So we need to change config file default paths to actual userdata location - if [[ -L $G_FP_DIETPI_USERDATA ]]; then - - local fp_userdata_actual=$(readlink -f $G_FP_DIETPI_USERDATA) - sed -i "s:$G_FP_DIETPI_USERDATA:$fp_userdata_actual:g" $G_FP_DIETPI_USERDATA/amiberry/conf/autostart.uae - - fi - - # Service - # - On Stretch Asus TB we need to start it as X11 session - local xinit_start='' - (( $G_HW_MODEL == 52 && $G_DISTRO < 5 )) && xinit_start="$(command -v xinit) " - cat << _EOF_ > /etc/systemd/system/amiberry.service [Unit] Description=Amiberry Amiga Emulator (DietPi) [Service] -#StandardOutput=tty -#StandardInput=tty -#TTYPath=/dev/tty1 -#TTYReset=yes -#TTYVHangup=yes WorkingDirectory=$G_FP_DIETPI_USERDATA/amiberry -ExecStart=$xinit_start$G_FP_DIETPI_USERDATA/amiberry/amiberry -f $G_FP_DIETPI_USERDATA/amiberry/conf/autostart.uae +Environment=LD_LIBRARY_PATH=$G_FP_DIETPI_USERDATA/amiberry/lib +ExecStart=$G_FP_DIETPI_USERDATA/amiberry/amiberry [Install] WantedBy=local-fs.target _EOF_ - # Start script - cat << _EOF_ > $G_FP_DIETPI_USERDATA/amiberry/run.sh -#!/bin/dash -cd $G_FP_DIETPI_USERDATA/amiberry -./amiberry -f conf/autostart.uae -_EOF_ - - # Execute permissions - chmod +x $G_FP_DIETPI_USERDATA/amiberry/{amiberry,run.sh} - fi software_id=112 # DDX-Rebirth @@ -8489,16 +8457,16 @@ _EOF_ Banner_Configuration - # - raspimjpeg conf + # raspimjpeg conf chmod +x /etc/raspimjpeg ln -s /etc/raspimjpeg /var/www/rpicam/raspimjpeg - # - Motion conf + # Motion conf chgrp www-data /etc/motion/motion.conf chmod 777 /etc/motion/motion.conf usermod -a -G video www-data - # - raspimjpeg/php schedule startup and control script + # raspimjpeg/php schedule startup and control script dps_index=$software_id Download_Install 'raspimjpeg.sh' /var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh chmod +x /var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh cat << _EOF_ > /etc/systemd/system/raspimjpeg.service @@ -8514,7 +8482,7 @@ ExecStop=/var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh stop WantedBy=multi-user.target _EOF_ - # - Replace confs with /var/www to /var/www/rpicam, once + # Replace confs with /var/www to /var/www/rpicam, once if ! grep -q '/rpicam' /etc/raspimjpeg; then sed -i 's#/var/www#/var/www/rpicam#g' /etc/raspimjpeg @@ -8522,13 +8490,13 @@ _EOF_ fi - # - Setup Data directory + # Setup Data directory mkdir -p $G_FP_DIETPI_USERDATA/rpicam rm -R /var/www/rpicam/media ln -s $G_FP_DIETPI_USERDATA/rpicam /var/www/rpicam/media chown -R www-data:www-data $G_FP_DIETPI_USERDATA/rpicam - # - Enable RPi camera + # Enable RPi camera /DietPi/dietpi/func/dietpi-set_hardware rpi-camera enable fi @@ -8684,8 +8652,8 @@ _EOF_ # Optional config to block public access to admin panel dps_index=$software_id Download_Install 'nginx.block_public_admin.conf' /etc/nginx/sites-dietpi/dietpi-pihole-block_public_admin.off - local enable_cmd='cd /etc/nginx/sites-dietpi; mv dietpi-pihole-block_public_admin.off dietpi-pihole-block_public_admin.on' - local disable_cmd='cd /etc/nginx/sites-dietpi; mv dietpi-pihole-block_public_admin.on dietpi-pihole-block_public_admin.off' + local enable_cmd='mv /etc/nginx/sites-dietpi/dietpi-pihole-block_public_admin.{off,on}' + local disable_cmd='mv /etc/nginx/sites-dietpi/dietpi-pihole-block_public_admin.{on,off}' fi @@ -8696,7 +8664,7 @@ _EOF_ You can always enable/disable this at a later point using the commands: - $enable_cmd - $disable_cmd\n -Do you want to block public access to the admin panel now?" && $enable_cmd +Do you want to block public access to the admin panel now?" && eval "$enable_cmd" # Create symlinks to align Pi-hole admin and blocking page relative to webroot cd /var/www @@ -8960,9 +8928,9 @@ _EOF_ [[ -f '/etc/default/logitechmediaserver' ]] && rm /etc/default/logitechmediaserver # Grant user access to audio devices and DietPi media files - usermod -a -G audio,dietpi squeezeboxserver + usermod -aG audio,dietpi squeezeboxserver # - Add to new "render" group on Buster - (( $G_DISTRO > 4 )) && usermod -a -G render squeezeboxserver + (( $G_DISTRO > 4 )) && usermod -aG render squeezeboxserver # systemd service cat << _EOF_ > /etc/systemd/system/logitechmediaserver.service @@ -9005,10 +8973,10 @@ _EOF_ # Apache configuration if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then - # - Required modules + # Required modules a2enmod headers expires rewrite - # - Better compatibility with mobile clients + # Better compatibility with mobile clients echo 'AllowEncodedSlashes On' > /etc/apache2/conf-available/dietpi-freshrss.conf a2enconf dietpi-freshrss @@ -9217,25 +9185,33 @@ _EOF_ Banner_Configuration - # Move DB/plugins to userdata location, if not already existent + # Remove obsolete sysvinit service + [[ -f '/etc/init.d/grafana-server' ]] && rm /etc/init.d/grafana-server + update-rc.d -f grafana-server remove + + # Link DB/plugins to userdata location if [[ -d $G_FP_DIETPI_USERDATA/grafana ]]; then G_DIETPI-NOTIFY 2 "Existing database/plugin directory $G_FP_DIETPI_USERDATA/grafana found. Will not overwrite..." - rm -Rf /var/lib/grafana - else + elif [[ -d '/var/lib/grafana' ]]; then mv /var/lib/grafana $G_FP_DIETPI_USERDATA/ - fi - ln -sf $G_FP_DIETPI_USERDATA/grafana /var/lib/grafana + else - # Permissions - chown -R grafana:grafana $G_FP_DIETPI_USERDATA/grafana + mkdir -p $G_FP_DIETPI_USERDATA/grafana + chown -R grafana:grafana $G_FP_DIETPI_USERDATA/grafana + + fi + rm -Rf /var/lib/grafana + ln -s $G_FP_DIETPI_USERDATA/grafana /var/lib/grafana - # Set password, wrap into trippled double quotes in case of ; or # being contained, according to docs: http://docs.grafana.org/installation/configuration/#password - GCI_PASSWORD=1 GCI_PRESERVE=1 G_CONFIG_INJECT 'admin_password[[:blank:]]*=' "admin_password = \"\"\"$GLOBAL_PW\"\"\"" /etc/grafana/grafana.ini - G_CONFIG_INJECT 'http_port = ' 'http_port = 3001' /etc/grafana/grafana.ini + # Config: Apply our defaults only if nothing was set before + # - Set password, wrap into trippled double quotes in case of ; or # being contained, according to docs: http://docs.grafana.org/installation/configuration/#password + GCI_PRESERVE=1 GCI_PASSWORD=1 G_CONFIG_INJECT 'admin_password[[:blank:]]*=' "admin_password = \"\"\"$GLOBAL_PW\"\"\"" /etc/grafana/grafana.ini + # - Set port to 3001 (away from default 3000) to avoid conflict with Gogs and Gitea + GCI_PRESERVE=1 G_CONFIG_INJECT 'http_port[[:blank:]]*=' 'http_port = 3001' /etc/grafana/grafana.ini fi @@ -9489,7 +9465,7 @@ _EOF_ # Server choice if [[ $G_WHIP_RETURNED_VALUE == 'Server' ]]; then - # - Public IP/domain and desired WireGuard server port + # Public IP/domain and desired WireGuard server port local invalid_text='' local domain=$(hostname -f) while : @@ -9530,19 +9506,19 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal done - # - Create everything inside WireGuard config dir + # Create everything inside WireGuard config dir cd /etc/wireguard - # - For securiy reasons set umask to 077 + # For security reasons set umask to 077 umask 077 - # - Create server and client keys + # Create server and client keys [[ -f 'server_private.key' ]] || wg genkey > server_private.key [[ -f 'server_public.key' ]] || wg pubkey < server_private.key > server_public.key [[ -f 'client_private.key' ]] || wg genkey > client_private.key [[ -f 'client_public.key' ]] || wg pubkey < client_private.key > client_public.key - # - Server config + # Server config [[ -f 'wg0.conf' ]] || cat << _EOF_ > wg0.conf [Interface] Address = 10.9.0.1/24 @@ -9568,16 +9544,16 @@ AllowedIPs = 10.9.0.2/32 #AllowedIPs = 10.9.0.3/32 _EOF_ - # - Server local network IP + # Server local network IP local server_ip=$(sed -n 4p /DietPi/dietpi/.network) - # - Server DNS nameserver + # Server DNS nameserver local server_dns=$(mawk '/nameserver/ {print $2;exit}' /etc/resolv.conf) - # Replace "127.0.0.1"/"localhost" loopback entries by server wg0 IP: https://github.com/MichaIng/DietPi/issues/2482 + # - Replace "127.0.0.1"/"localhost" loopback entries by server wg0 IP: https://github.com/MichaIng/DietPi/issues/2482 server_dns=${server_dns//127.0.0.1/10.9.0.1} server_dns=${server_dns//localhost/10.9.0.1} - # - Client config + # Client config [[ -f 'wg0-client.conf' ]] || cat << _EOF_ > wg0-client.conf [Interface] Address = 10.9.0.2/24 @@ -9605,18 +9581,21 @@ Endpoint = $domain:$port # Uncomment the following, if you're behind a NAT and want the connection to be kept alive. #PersistentKeepalive = 25 _EOF_ - - # - Start WireGuard interface via systemd unit - (( $module_active )) && systemctl start wg-quick@wg0 - # persistent - systemctl enable wg-quick@wg0 - - # - Set umask back to default 022 + # Set umask back to default 022 umask 022 - # - Navigate back to DietPi-Software working dir + # Navigate back to DietPi-Software working dir cd /tmp/$G_PROGRAM_NAME + # Use wg-quick@.service to start VPN on boot + # - Assure DietPi-Boot has finished first: https://github.com/MichaIng/DietPi/issues/3175#issuecomment-544607657 + mkdir -p /etc/systemd/system/wg-quick@wg0.service.d + echo -e '[Unit]\nAfter=dietpi-boot.service' > /etc/systemd/system/wg-quick@wg0.service.d/dietpi.conf + systemctl daemon-reload + systemctl enable wg-quick@wg0 + # - Start now if module is active already + (( $module_active )) && systemctl start wg-quick@wg0 + # Client choice elif [[ $G_WHIP_RETURNED_VALUE == 'Client' ]]; then @@ -9646,8 +9625,8 @@ If no WireGuard (auto)start is included, but you require it, please do the follo Banner_Configuration - local eth_index=$(mawk 'NR==1 {print}' /DietPi/dietpi/.network) - local wifi_index=$(mawk 'NR==2 {print}' /DietPi/dietpi/.network) + local eth_index=$(mawk 'NR==1' /DietPi/dietpi/.network) + local wifi_index=$(mawk 'NR==2' /DietPi/dietpi/.network) # DHCPD Config G_BACKUP_FP /etc/dhcp/dhcpd.conf @@ -9827,29 +9806,29 @@ _EOF_ # - Apache2 if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then - # - Enable Apache2 rewrite engine + # Enable Apache2 rewrite engine a2enmod rewrite - # - Move Pydio Apache2 config in place + # Move Pydio Apache2 config in place dps_index=$software_id Download_Install 'apache.pydio.conf' /etc/apache2/sites-available/dietpi-pydio.conf a2ensite dietpi-pydio # - Lighttpd elif (( ${aSOFTWARE_INSTALL_STATE[84]} > 0 )); then - # - Enable Lighttpd setenv, access and rewrite modules + # Enable Lighttpd setenv, access and rewrite modules G_CONFIG_INJECT '"mod_access",' ' "mod_access",' /etc/lighttpd/lighttpd.conf '"mod_.+",' G_CONFIG_INJECT '"mod_setenv",' ' "mod_setenv",' /etc/lighttpd/lighttpd.conf '"mod_.+",' lighttpd-enable-mod rewrite - # - Move Pydio Lighttpd config in place + # Move Pydio Lighttpd config in place dps_index=$software_id Download_Install 'lighttpd.pydio.conf' /etc/lighttpd/conf-available/99-dietpi-pydio.conf lighttpd-enable-mod dietpi-pydio # - Nginx elif (( ${aSOFTWARE_INSTALL_STATE[85]} > 0 )); then - # - Move Pydio Nginx config in place + # Move Pydio Nginx config in place dps_index=$software_id Download_Install 'nginx.pydio.conf' /etc/nginx/sites-dietpi/dietpi-pydio.conf fi @@ -9911,7 +9890,7 @@ _EOF_ # Disable onboard Bluetooth, if present, to recover ttyAMA0 # RPi4: Test required - if (( $(sed -n 10p /DietPi/dietpi/.hw_model) )); then + if (( $(mawk 'NR==10' /DietPi/dietpi/.hw_model) )); then /DietPi/dietpi/func/dietpi-set_hardware bluetooth disable @@ -9936,10 +9915,10 @@ _EOF_ Banner_Configuration - # - Update apt package stats + # Update apt package stats /usr/share/rpimonitor/scripts/updatePackagesStatus.pl - # - USBdrive stats implimentation by Rich + # USBdrive stats implimentation by Rich if (( $USBDRIVE )); then sed -i '\/include=\/etc\/rpimonitor\/template\/sdcard.conf/a include=\/etc\/rpimonitor\/template\/usb_hdd.conf' /etc/rpimonitor/data.conf @@ -10100,9 +10079,9 @@ location = /.well-known/caldav { Download_Test_Media # Permissions - usermod -a -G dietpi emby + usermod -aG dietpi emby # - Add to new "render" group on Buster - (( $G_DISTRO > 4 )) && usermod -a -G render emby + (( $G_DISTRO > 4 )) && usermod -aG render emby fi @@ -10113,9 +10092,9 @@ location = /.well-known/caldav { Download_Test_Media # Permissions - usermod -a -G dietpi plex + usermod -aG dietpi plex # - Add to new "render" group on Buster - (( $G_DISTRO > 4 )) && usermod -a -G render plex + (( $G_DISTRO > 4 )) && usermod -aG render plex # Run service as "dietpi" group: https://github.com/MichaIng/DietPi/issues/350#issuecomment-423763518 mkdir -p /etc/systemd/system/plexmediaserver.service.d @@ -10367,15 +10346,15 @@ _EOF_ Banner_Configuration - # Create username/password for rutorrent based on webserver type. + # Create username/password for rutorrent based on webserver type # - Apache2 if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then - # - Install SCGI module + # Install SCGI module G_AGI libapache2-mod-scgi a2enmod rewrite scgi - # - Enable password protection + # Enable password protection htpasswd -cb /etc/.rutorrent-htaccess root "$GLOBAL_PW" cat << _EOF_ > /var/www/rutorrent/.htaccess AuthUserFile /etc/.rutorrent-htaccess @@ -10384,7 +10363,7 @@ AuthType Basic require user root _EOF_ - # - Allow overrides/.htaccess and enable SCGI + authentication + # Allow overrides/.htaccess and enable SCGI + authentication cat << _EOF_ > /etc/apache2/sites-available/dietpi-rutorrent.conf AllowOverride All @@ -10406,7 +10385,7 @@ _EOF_ echo "root:rtorrent:$(echo -n 'root:rtorrent:dietpi' | md5sum | cut -b -32)" > /etc/.rutorrent-htaccess - # - Add to /etc/lighttpd/lighttpd.conf + # Add to /etc/lighttpd/lighttpd.conf if ! grep -qi '^#RUTORRENT_DIETPI' /etc/lighttpd/lighttpd.conf; then cat << _EOF_ >> /etc/lighttpd/lighttpd.conf @@ -10457,13 +10436,13 @@ _EOF_ fi - # - Define curl location in config.php (for Lighttpd and Nginx) + # Define curl location in config.php (for Lighttpd and Nginx) G_CONFIG_INJECT '"curl"[[:blank:]]' ' "curl" => "/usr/bin/curl",' /var/www/rutorrent/conf/config.php chown www-data:www-data /etc/.rutorrent-htaccess chmod 400 /etc/.rutorrent-htaccess - # - Session folder + # Session folder mkdir -p $G_FP_DIETPI_USERDATA/$FOLDER_DOWNLOADS/.session # Create rTorrent run user @@ -10471,7 +10450,7 @@ _EOF_ getent passwd rtorrent &> /dev/null && usercmd='usermod -a' $usercmd -G dietpi -d $G_FP_DIETPI_USERDATA/rtorrent -s $(command -v nologin) rtorrent - # - Service using screen | '/usr/bin/rtorrent &> /var/log/rtorrent.log &' doesnt work, hangs program after 5 seconds + # Service using screen | '/usr/bin/rtorrent &> /var/log/rtorrent.log &' doesnt work, hangs program after 5 seconds cat << _EOF_ > /etc/systemd/system/rtorrent.service [Unit] Description=rTorrent (DietPi) @@ -10489,7 +10468,7 @@ ExecStop=$(command -v screen) -S rtorrent -X quit [Install] WantedBy=multi-user.target _EOF_ - # - On Buster we use new daemon mode + # On Buster we use new daemon mode if (( $G_DISTRO > 4 )); then sed -Ei '/^(Type|KillMode|ExecStop)=/d' /etc/systemd/system/rtorrent.service @@ -10497,11 +10476,11 @@ _EOF_ fi - # - Default conf, do not overwrite if existent - # Example: https://github.com/rakshasa/rtorrent/blob/master/doc/rtorrent.rc - # Deprecated commands: - # - https://github.com/rakshasa/rtorrent/wiki/rTorrent-0.9-Comprehensive-Command-list-(WIP) - # - https://github.com/rakshasa/rtorrent/blob/master/doc/scripts/update_commands_0.9.sed + # Default conf, do not overwrite if existent + # - Example: https://github.com/rakshasa/rtorrent/blob/master/doc/rtorrent.rc + # - Deprecated commands: + # https://github.com/rakshasa/rtorrent/wiki/rTorrent-0.9-Comprehensive-Command-list-(WIP) + # https://github.com/rakshasa/rtorrent/blob/master/doc/scripts/update_commands_0.9.sed mkdir -p $G_FP_DIETPI_USERDATA/rtorrent [[ -f $G_FP_DIETPI_USERDATA/rtorrent/.rtorrent.rc ]] || cat << _EOF_ > $G_FP_DIETPI_USERDATA/rtorrent/.rtorrent.rc # Attempt to reduce disk throttling/abuse @@ -10633,6 +10612,10 @@ _EOF_ (( $G_DISTRO > 4 )) && G_CONFIG_INJECT 'system.daemon.set[[:blank:]=]' 'system.daemon.set = true' $G_FP_DIETPI_USERDATA/rtorrent/.rtorrent.rc chown -R rtorrent:rtorrent $G_FP_DIETPI_USERDATA/rtorrent $G_FP_DIETPI_USERDATA/downloads/.session + # ruTorrent access permissions: https://github.com/Novik/ruTorrent/wiki/Config + chown -R www-data:rtorrent /var/www/rutorrent/share + chown root:root /var/www/rutorrent/share/.htaccess + fi software_id=132 # Aria2 @@ -10736,35 +10719,27 @@ _EOF_ Banner_Configuration - # Generate dirs - mkdir -p $G_FP_DIETPI_USERDATA/syncthing - mkdir -p $G_FP_DIETPI_USERDATA/syncthing_data - - # - Logs/Binary - mkdir -p /var/log/syncthing - >> /var/log/syncthing/syncthing.log - chown -R dietpi:dietpi /var/log/syncthing - chown -R dietpi:dietpi /etc/syncthing - - # Run Syncthing to create cert/config and exit - /etc/syncthing/syncthing -generate=$G_FP_DIETPI_USERDATA/syncthing + # Permissions + chown -R dietpi:dietpi /opt/syncthing - # Disable automatic upgrades - sed -i '/<\/autoUpgradeIntervalH>/c\ 0<\/autoUpgradeIntervalH>' $G_FP_DIETPI_USERDATA/syncthing/config.xml + # Pre-create and edit default config only on fresh installs + if [[ ! -f $G_FP_DIETPI_USERDATA/syncthing/config.xml ]]; then - # Allow external access (LAN). - sed -i '/:8384<\/address>/c\
0.0.0.0:8384<\/address>' $G_FP_DIETPI_USERDATA/syncthing/config.xml + # Run Syncthing to pre-create config dir and exit + sudo -u dietpi /opt/syncthing/syncthing -generate=$G_FP_DIETPI_USERDATA/syncthing - # Set default folder - sed -i '/label=\"Default Folder/c\ ' $G_FP_DIETPI_USERDATA/syncthing/config.xml + # Allow remote access: https://docs.syncthing.net/users/faq.html#how-do-i-access-the-web-gui-from-another-computer + sed -i '\|:8384
|c\
0.0.0.0:8384
' $G_FP_DIETPI_USERDATA/syncthing/config.xml - # Disable browser starting - sed -i '/<\/startBrowser>/c\ false<\/startBrowser>' $G_FP_DIETPI_USERDATA/syncthing/config.xml + # Set default folder + mkdir -p $G_FP_DIETPI_USERDATA/syncthing_data + chown -R dietpi:dietpi $G_FP_DIETPI_USERDATA/syncthing_data + sed -i '\| /etc/systemd/system/syncthing.service [Unit] Description=Syncthing (DietPi) @@ -10772,13 +10747,22 @@ After=network.target [Service] User=dietpi -ExecStart=/etc/syncthing/syncthing -logfile=/var/log/syncthing/syncthing.log -logflags=3 -home=$G_FP_DIETPI_USERDATA/syncthing +ExecStart=/opt/syncthing/syncthing -no-browser -no-restart -logflags=0 -home=$G_FP_DIETPI_USERDATA/syncthing +Restart=on-failure +SuccessExitStatus=3 4 +RestartForceExitStatus=3 4 + +# Hardening +ProtectSystem=full +PrivateTmp=true +SystemCallArchitectures=native +MemoryDenyWriteExecute=true +NoNewPrivileges=true [Install] WantedBy=multi-user.target _EOF_ - - # - Increase open file limit: + # Increase fs watcher limit: https://docs.syncthing.net/users/faq.html#how-do-i-increase-the-inotify-limit-to-get-my-filesystem-watcher-to-work echo 'fs.inotify.max_user_watches=204800' > /etc/sysctl.d/dietpi-syncthing.conf fi @@ -10885,7 +10869,7 @@ _EOF_ # RPi if (( $G_HW_MODEL < 10 )); then - # - OpenGL + # OpenGL #if (( $G_HW_MODEL >= 2 )); then # Hangs xinit: https://github.com/MichaIng/DietPi/issues/834 @@ -11070,15 +11054,23 @@ _EOF_ Banner_Configuration + # Remove obsolete sysvinit service [[ -f '/etc/init.d/mosquitto' ]] && rm /etc/init.d/mosquitto update-rc.d -f mosquitto remove - cat << _EOF_ > /etc/systemd/system/mosquitto.service + # Add systemd unit on Stretch, since Buster it is part of the APT package: https://github.com/eclipse/mosquitto/tree/master/service/systemd + (( $G_DISTRO > 4 )) || cat << _EOF_ > /etc/systemd/system/mosquitto.service [Unit] -Description=Mosquitto (DietPi) -After=network.target +Description=Mosquitto MQTT v3.1/v3.1.1 Broker (DietPi) +Documentation=man:mosquitto.conf(5) man:mosquitto(8) +After=network-online.target +Wants=network-online.target [Service] -ExecStart=$(command -v mosquitto) -c /etc/mosquitto/mosquitto.conf +Type=notify +NotifyAccess=main +ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure [Install] WantedBy=multi-user.target @@ -11135,11 +11127,7 @@ _EOF_ Banner_Configuration # Enable RPi cam - if (( $G_HW_MODEL < 10 )); then - - /DietPi/dietpi/func/dietpi-set_hardware rpi-camera enable - - fi + (( $G_HW_MODEL < 10 )) && /DietPi/dietpi/func/dietpi-set_hardware rpi-camera enable mkdir -p /etc/motioneye G_BACKUP_FP /etc/motioneye/motioneye.conf @@ -11161,7 +11149,7 @@ _EOF_ # Enable web admin G_RUN_CMD systemctl start cups cupsctl --remote-admin - usermod -a -G lpadmin root + usermod -aG lpadmin root systemctl stop cups fi @@ -11515,20 +11503,24 @@ _EOF_ chown -R jackett:jackett /opt/jackett # Service: https://github.com/Jackett/Jackett/wiki/systemd-service + # - Wrap execution into shell to work around: https://github.com/Jackett/Jackett/issues/5208 cat << _EOF_ > /etc/systemd/system/jackett.service [Unit] -Description=Jackett Daemon (DietPi) -After=network.target +Description=Jackett (DietPi) +Wants=network-online.target +After=network-online.target [Service] +SyslogIdentifier=jackett User=jackett +WorkingDirectory=/opt/jackett Environment=XDG_CONFIG_HOME=/opt/jackett -ExecStart=$(command -v mono) -O=-aot /opt/jackett/JackettConsole.exe --NoRestart +ExecStart=/bin/dash -c '/opt/jackett/jackett --NoRestart; while pgrep -u jackett JackettUpdater; do sleep 1; done' Restart=always RestartSec=5 TimeoutStopSec=20 -# These lines optionally isolate (sandbox) Jackett from the rest of the system. +# Hardening ProtectSystem=strict ProtectHome=true PrivateDevices=true @@ -11538,8 +11530,8 @@ ReadWritePaths=/opt/jackett [Install] WantedBy=multi-user.target _EOF_ - # - Non-ARMv6 devices run the standalone version: https://github.com/Jackett/Jackett#install-on-linux-amdx64 - (( $G_HW_ARCH != 1 )) && G_CONFIG_INJECT 'ExecStart=' 'ExecStart=/opt/jackett/jackett --NoRestart' /etc/systemd/system/jackett.service + # - ARMv6 devices use Mono + (( $G_HW_ARCH == 1 )) && G_CONFIG_INJECT 'ExecStart=' "ExecStart=$(command -v mono) -O=-aot /opt/jackett/JackettConsole.exe --NoRestart" /etc/systemd/system/jackett.service fi @@ -11556,23 +11548,23 @@ _EOF_ sed -i "/MainDir=/c\MainDir=$G_FP_DIETPI_USERDATA/$FOLDER_DOWNLOADS" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf sed -i "/DestDir=/c\DestDir=$G_FP_DIETPI_USERDATA/$FOLDER_DOWNLOADS/complete" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf - sed -i "/LogFile=/c\LogFile=/var/log/nzbget.log" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf + sed -i '/LogFile=/c\LogFile=/var/log/nzbget.log' $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf - sed -i "/ControlUsername=/c\ControlUsername=admin" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf + sed -i '/ControlUsername=/c\ControlUsername=admin' $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf sed -i "/ControlPassword=/c\ControlPassword=$GLOBAL_PW" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf # - Umask: https://github.com/MichaIng/DietPi/issues/1999 - sed -i "/UMask=/c\UMask=0002" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf + sed -i '/UMask=/c\UMask=0002' $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf # - Optimizations - sed -i "/Server1.Cipher=/c\Server1.Cipher=RC4-MD5" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf - sed -i "/CrcCheck=/c\CrcCheck=no" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf - sed -i "/ParScan=/c\ParScan=limited" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf + sed -i '/Server1.Cipher=/c\Server1.Cipher=RC4-MD5' $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf + sed -i '/CrcCheck=/c\CrcCheck=no' $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf + sed -i '/ParScan=/c\ParScan=limited' $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf sed -i "/ParThreads=/c\ParThreads=$G_HW_CPU_CORES" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf - sed -i "/DebugTarget=/c\DebugTarget=none" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf - sed -i "/CrashTrace=/c\CrashTrace=no" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf - sed -i "/DetailTarget=/c\DetailTarget=none" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf + sed -i '/DebugTarget=/c\DebugTarget=none' $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf + sed -i '/CrashTrace=/c\CrashTrace=no' $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf + sed -i '/DetailTarget=/c\DetailTarget=none' $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf sed -i "/ParBuffer=/c\ParBuffer=$(Optimise_BitTorrent 0)" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf sed -i "/ArticleCache=/c\ArticleCache=$(Optimise_BitTorrent 0)" $G_FP_DIETPI_USERDATA/nzbget/nzbget.conf @@ -11609,7 +11601,7 @@ Description=HTPC Manager (DietPi) After=network.target [Service] -ExecStart=/usr/bin/python $G_FP_DIETPI_USERDATA/htpc-manager/Htpc.py +ExecStart=$(command -v python) $G_FP_DIETPI_USERDATA/htpc-manager/Htpc.py [Install] WantedBy=multi-user.target @@ -11676,25 +11668,33 @@ _EOF_ Banner_Configuration - cat << _EOF_ > /etc/systemd/system/home-assistant.service + cat << _EOF_ > /etc/systemd/system/home-assistant.service [Unit] Description=Home Assistant (DietPi) -After=network.target +Wants=network-online.target +After=network-online.target mariadb.service [Service] User=homeassistant -ExecStart=/srv/homeassistant/homeassistant-start.sh +ExecStart=/home/homeassistant/homeassistant-start.sh [Install] WantedBy=multi-user.target - _EOF_ # Link to the default ha location for the homeassistant user, this makes # the configuration avaliable for the user to edit. Configuration generated # when service is started at /home/homeassistant/.homeassistant - mkdir $G_FP_DIETPI_USERDATA/homeassistant - ln -sf $G_FP_DIETPI_USERDATA/homeassistant /home/homeassistant/.homeassistant + # - Move default home location to userdata, if not existing yet + if [[ ! -d $G_FP_DIETPI_USERDATA/homeassistant ]]; then + + [[ -d '/home/homeassistant/.homeassistant' ]] && mv /home/homeassistant/.homeassistant $G_FP_DIETPI_USERDATA/homeassistant + mkdir -p $G_FP_DIETPI_USERDATA/homeassistant + chown -R homeassistant:homeassistant $G_FP_DIETPI_USERDATA/homeassistant + + fi + rm -Rf /home/homeassistant/.homeassistant + ln -s $G_FP_DIETPI_USERDATA/homeassistant /home/homeassistant/.homeassistant fi @@ -11708,15 +11708,15 @@ _EOF_ # Default file path MINIO_VOLUMES="$G_FP_DIETPI_USERDATA/minio-data" # Use if you want to run Minio on a custom port. -# MINIO_OPTS="--address :9199" +#MINIO_OPTS="--address :9199" # Access Key of the server. -# MINIO_ACCESS_KEY=Server-Access-Key +#MINIO_ACCESS_KEY=Server-Access-Key # Secret key of the server. -# MINIO_SECRET_KEY=Server-Secret-Key +#MINIO_SECRET_KEY=Server-Secret-Key _EOF_ # Enable startup on boot by default - systemctl enable minio.service + systemctl enable minio fi @@ -11754,7 +11754,7 @@ _EOF_ if [[ ! -d $G_FP_DIETPI_USERDATA/fuguhub-data/ ]]; then # Move installed filestore to dietpi userdata - mkdir $G_FP_DIETPI_USERDATA/fuguhub-data + mkdir -p $G_FP_DIETPI_USERDATA/fuguhub-data mv /home/bd/disk/* $G_FP_DIETPI_USERDATA/fuguhub-data/ # Set permissions chown -R bd:bd $G_FP_DIETPI_USERDATA/fuguhub-data/ @@ -11776,7 +11776,7 @@ _EOF_ # Conig file to autostart -- english default wget -O /usr/local/bin/nukkit/nukkit.yml https://github.com/Nukkit/Languages/raw/master/eng/nukkit.yml - # create systemd file + # Service cat << _EOF_ > /etc/systemd/system/nukkit.service [Unit] Description=nukkit (DietPi) @@ -11796,6 +11796,16 @@ _EOF_ Banner_Configuration + # Logs + mkdir -p /var/log/gitea + + # Permissions + chown -R dietpi:dietpi /var/log/gitea $G_FP_DIETPI_USERDATA/gitea + chmod +x $G_FP_DIETPI_USERDATA/gitea/gitea + + # Database + /DietPi/dietpi/func/create_mysql_db gitea gitea "$GLOBAL_PW" + # Service cat << _EOF_ > /etc/systemd/system/gitea.service @@ -11805,20 +11815,13 @@ Description=Gitea (DietPi) [Service] User=dietpi WorkingDirectory=$G_FP_DIETPI_USERDATA/gitea/gitea-repositories -ExecStart=$G_FP_DIETPI_USERDATA/gitea/gitea web Environment=USER=dietpi HOME=$G_FP_DIETPI_USERDATA/gitea +ExecStart=$G_FP_DIETPI_USERDATA/gitea/gitea web [Install] WantedBy=multi-user.target _EOF_ - # Logs - mkdir -p /var/log/gitea - chown -R dietpi:dietpi /var/log/gitea - - # Database - /DietPi/dietpi/func/create_mysql_db gitea gitea "$GLOBAL_PW" - fi software_id=159 # Allo: 160 for quick reinstall/update @@ -12022,6 +12025,9 @@ _EOF_ # Setup soundcard /DietPi/dietpi/func/dietpi-set_hardware soundcard googlevoicehat-soundcard + # Permissions + chown -R dietpi:dietpi $G_FP_DIETPI_USERDATA/voice-recognizer-raspi + fi software_id=176 # Mycroft AI @@ -12143,7 +12149,7 @@ _EOF_ # RPi: Define minimal memory split based on installed software local gpu_memory=0 local hw_memory_size=0 - (( $G_HW_MODEL < 10 )) && hw_memory_size=$(grep -m1 'HW_MEMORY_SIZE=' /DietPi/dietpi/.hw_model | sed 's/^[^=]*=//') + (( $G_HW_MODEL < 10 )) && hw_memory_size=$(sed -n '/HW_MEMORY_SIZE=/{s/^[^=]*=//p;q}' /DietPi/dietpi/.hw_model) # - Kodi if (( ${aSOFTWARE_INSTALL_STATE[31]} == 1 )); then @@ -12324,7 +12330,7 @@ _EOF_ Banner_Uninstalling # Remove background cron job - crontab -u www-data -l | grep -v '/var/www/owncloud/cron.php' | crontab -u www-data - + crontab -u www-data -l | grep -v '/var/www/owncloud/.*cron' | crontab -u www-data - # Disable and remove PHP modules phpdismod dietpi-owncloud &> /dev/null rm -f /etc/php/*/mods-available/dietpi-owncloud.ini @@ -12363,8 +12369,6 @@ _EOF_ fi grep -q 'owncloud' /etc/nginx/sites-dietpi/dietpi-dav_redirect.conf &> /dev/null && rm /etc/nginx/sites-dietpi/dietpi-dav_redirect.conf - # PHP7.3 block removal - [[ -f '/etc/apt/preferences.d/dietpi-owncloud' ]] && rm /etc/apt/preferences.d/dietpi-owncloud fi @@ -12431,6 +12435,29 @@ _EOF_ fi + software_id=63 # LinuxDash + if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then + + Banner_Uninstalling + [[ -d '/var/www/linuxdash' ]] && rm -R /var/www/linuxdash + + fi + + software_id=27 # TasmoAdmin + if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then + + Banner_Uninstalling + [[ -d '/var/www/tasmoadmin' ]] && rm -R /var/www/tasmoadmin + + # Remove webserver configs + command -v a2dissite &> /dev/null && a2dissite dietpi-tasmoadmin + [[ -f '/etc/apache2/conf-available/dietpi-tasmoadmin.conf' ]] && rm /etc/apache2/conf-available/dietpi-tasmoadmin.conf + [[ -f '/etc/nginx/sites-dietpi/dietpi-tasmoadmin.conf' ]] && rm /etc/nginx/sites-dietpi/dietpi-tasmoadmin.conf + command -v lighttpd-disable-mod &> /dev/null && lighttpd-disable-mod dietpi-tasmoadmin + [[ -f '/etc/lighttpd/conf-available/99-dietpi-tasmoadmin.conf' ]] && rm /etc/lighttpd/conf-available/99-dietpi-tasmoadmin.conf + + fi + software_id=83 if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then @@ -12590,15 +12617,15 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling - npm r -g node-red - getent passwd nodered &> /dev/null && userdel -rf nodered - [[ -f '/etc/sudoers.d/nodered' ]] && rm /etc/sudoers.d/nodered if [[ -f '/etc/systemd/system/node-red.service' ]]; then - systemctl disable node-red - rm /etc/systemd/system/node-red.service + systemctl disable --now node-red + rm -R /etc/systemd/system/node-red.service* fi + npm r -g node-red + getent passwd nodered &> /dev/null && userdel -rf nodered + [[ -f '/etc/sudoers.d/nodered' ]] && rm /etc/sudoers.d/nodered [[ -d $G_FP_DIETPI_USERDATA/node-red ]] && rm -R $G_FP_DIETPI_USERDATA/node-red [[ -f '/usr/local/bin/node-red' ]] && rm /usr/local/bin/node-red [[ -f '/usr/local/bin/node-red-pi' ]] && rm /usr/local/bin/node-red-pi @@ -12610,14 +12637,13 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling - G_AGP mosquitto - if [[ -f '/etc/systemd/system/mosquitto.service' ]]; then - systemctl disable mosquitto - rm /etc/systemd/system/mosquitto.service + systemctl disable --now mosquitto + rm -R /etc/systemd/system/mosquitto.service* fi + G_AGP mosquitto fi @@ -12625,7 +12651,6 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling - #apt-mark auto gcc-6-base libstdc++6 &> /dev/null G_AGP networkaudiod fi @@ -12638,7 +12663,7 @@ _EOF_ fi - software_id=126 + software_id=126 # LibSSL1.0.0 if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling @@ -12677,8 +12702,8 @@ _EOF_ Banner_Uninstalling if [[ -f '/etc/systemd/system/blynkserver.service' ]]; then - systemctl disable blynkserver - rm /etc/systemd/system/blynkserver.service + systemctl disable --now blynkserver + rm -R /etc/systemd/system/blynkserver.service* fi getent passwd blynk &> /dev/null && userdel -rf blynk @@ -12695,7 +12720,7 @@ _EOF_ if [[ -f '/etc/systemd/system/aria2.service' ]]; then systemctl disable --now aria2 - rm /etc/systemd/system/aria2.service + rm -R /etc/systemd/system/aria2.service* fi G_AGP aria2 @@ -12706,16 +12731,21 @@ _EOF_ fi - software_id=133 + software_id=133 # YaCy if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling - rm /etc/systemd/system/yacy.service + if [[ '/etc/systemd/system/yacy.service' ]]; then + + systemctl disable --now yacy + rm -R /etc/systemd/system/yacy.service* + + fi rm -R /etc/yacy fi - software_id=2 + software_id=2 # Folding@Home if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling @@ -12736,7 +12766,7 @@ _EOF_ if [[ -f '/etc/systemd/system/tonido.service' ]]; then systemctl disable --now tonido - rm /etc/systemd/system/tonido.service + rm -R /etc/systemd/system/tonido.service* fi getent passwd tonido &> /dev/null && userdel -rf tonido @@ -12749,8 +12779,13 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling + if [[ '/etc/systemd/system/darkice.service' ]]; then + + systemctl disable --now darkice + rm -R /etc/systemd/system/darkice.service* + + fi G_AGP darkice icecast2 - rm /etc/systemd/system/darkice.service fi @@ -12910,7 +12945,7 @@ _EOF_ [[ -d '/opt/jackett' ]] && rm -R /opt/jackett if [[ -f '/etc/systemd/system/jackett.service' ]]; then - systemctl disable jackett + systemctl disable --now jackett rm /etc/systemd/system/jackett.service fi @@ -13117,6 +13152,7 @@ _EOF_ G_AGP samba samba-common-bin [[ -f '/etc/tmpfiles.d/dietpi-samba_cache.conf' ]] && rm /etc/tmpfiles.d/dietpi-samba_cache.conf [[ -d '/run/samba-cache' ]] && rm -R /run/samba-cache + rm -Rf /var/cache/samba # Symlink fi @@ -13140,17 +13176,14 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling - [[ -f '/usr/local/bin/noip2' ]] && rm /usr/local/bin/noip2 - [[ -f '/usr/local/etc/no-ip2.conf' ]] && rm /usr/local/etc/no-ip2.conf - [[ -f '/etc/systemd/system/noip2.service' ]] && rm /etc/systemd/system/noip2.service + if [[ -f '/etc/systemd/system/noip2.service' ]]; then - fi - - software_id=63 - if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then + systemctl disable --now noip2 + rm -R /etc/systemd/system/noip2.service* - Banner_Uninstalling - [[ -d '/var/www/linuxdash' ]] && rm -R /var/www/linuxdash + fi + [[ -f '/usr/local/bin/noip2' ]] && rm /usr/local/bin/noip2 + [[ -f '/usr/local/etc/no-ip2.conf' ]] && rm /usr/local/etc/no-ip2.conf fi @@ -13256,7 +13289,7 @@ _EOF_ # - For old version of dietpi-cloudshell, without service. killall -w dietpi-cloudshell - #Disable auto login, revert boot index to console + # Disable auto login, revert boot index to console /DietPi/dietpi/dietpi-autostart 0 fi @@ -13408,9 +13441,9 @@ _EOF_ Banner_Uninstalling G_AGP wireguard* [[ -d '/etc/wireguard' ]] && rm -R /etc/wireguard + [[ -d '/etc/systemd/system/wg-quick@wg0.service.d' ]] && rm -R /etc/systemd/system/wg-quick@wg0.service.d [[ -f '/etc/apt/sources.list.d/dietpi-wireguard.list' ]] && rm /etc/apt/sources.list.d/dietpi-wireguard.list [[ -f '/etc/apt/preferences.d/dietpi-wireguard' ]] && rm /etc/apt/preferences.d/dietpi-wireguard - [[ -f '/etc/kernel/postinst.d/dietpi-wireguard' ]] && rm /etc/kernel/postinst.d/dietpi-wireguard fi @@ -13418,8 +13451,15 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling - rm -R /etc/openvpn/ovpn_tcp/*nordvpn* /etc/openvpn/ovpn_udp/*nordvpn* - rm -R /var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn /lib/systemd/system/dietpi-nordvpn.service &> /dev/null + if [[ -f '/etc/systemd/system/dietpi-nordvpn.service' ]]; then + + systemctl disable --now dietpi-nordvpn + rm /etc/systemd/system/dietpi-nordvpn.service + + fi + rm -Rf /etc/openvpn/ovpn_{tcp,udp}/*nordvpn* + rmdir --ignore-fail-on-non-empty /etc/openvpn/ovpn_{tcp,udp} + [[ -d '/var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn' ]] && rm -R /var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn fi @@ -13489,7 +13529,7 @@ _EOF_ [[ -f '/etc/sysctl.d/dietpi-wifihotspot.conf' ]] && rm /etc/sysctl.d/dietpi-wifihotspot.conf # Set WiFi interface back to inactive and ready for use with dietpi-config. - local wifi_index=$(mawk 'NR==2 {print}' /DietPi/dietpi/.network) + local wifi_index=$(mawk 'NR==2' /DietPi/dietpi/.network) # - Remove all entries below wlan, so we can recreate them sed -i '/allow-hotplug wlan/q0' /etc/network/interfaces # - Disable @@ -13726,22 +13766,20 @@ _EOF_ fi - software_id=50 + software_id=50 # Syncthing if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling if [[ -f '/etc/systemd/system/syncthing.service' ]]; then - systemctl disable syncthing - rm /etc/systemd/system/syncthing.service + systemctl disable --now syncthing + rm -R /etc/systemd/system/syncthing.service* fi + [[ -d '/opt/syncthing' ]] && rm -R /opt/syncthing [[ -d $G_FP_DIETPI_USERDATA/syncthing ]] && rm -R $G_FP_DIETPI_USERDATA/syncthing - [[ -f '/etc/sysctl.d/dietpi-syncthing.conf' ]] && rm /etc/sysctl.d/dietpi-syncthing.conf # DietPi post-v6.18 - - [[ -f '/usr/bin/syncthing' ]] && rm /usr/bin/syncthing # DietPi pre-v158 - [[ -d '/etc/syncthing' ]] && rm -R /etc/syncthing + [[ -f '/etc/sysctl.d/dietpi-syncthing.conf' ]] && rm /etc/sysctl.d/dietpi-syncthing.conf fi @@ -13751,8 +13789,8 @@ _EOF_ Banner_Uninstalling if [[ -f '/etc/systemd/system/medusa.service' ]]; then - systemctl disable medusa - rm /etc/systemd/system/medusa.service + systemctl disable --now medusa + rm -R /etc/systemd/system/medusa.service* fi [[ -d $G_FP_DIETPI_USERDATA/medusa ]] && rm -R $G_FP_DIETPI_USERDATA/medusa @@ -13770,8 +13808,8 @@ _EOF_ [[ -d $G_FP_DIETPI_USERDATA/rtorrent ]] && rm -R $G_FP_DIETPI_USERDATA/rtorrent if [[ -f '/etc/systemd/system/rtorrent.service' ]]; then - systemctl disable rtorrent - rm /etc/systemd/system/rtorrent.service + systemctl disable --now rtorrent + rm -R /etc/systemd/system/rtorrent.service* fi @@ -13796,15 +13834,13 @@ _EOF_ if [[ -f '/etc/systemd/system/amiberry.service' ]]; then systemctl disable --now amiberry - rm /etc/systemd/system/amiberry.service + rm -R /etc/systemd/system/amiberry.service* fi # Files [[ -d $G_FP_DIETPI_USERDATA/amiberry ]] && rm -R $G_FP_DIETPI_USERDATA/amiberry # Autostart index: If currently Amiberry, revert to console login [[ -f '/DietPi/dietpi/.dietpi-autostart_index' && $( /dev/null && userdel -rf homeassistant getent group homeassistant &> /dev/null && groupdel homeassistant + [[ -d '/srv/homeassistant' ]] && rm -R /srv/homeassistant # pre-v6-27 - # Remove the service. - [[ -f '/etc/systemd/system/home-assistant.service' ]] && rm /etc/systemd/system/home-assistant.service + G_DIETPI-NOTIFY 2 'Home Assistant data and settings are not removed: /mnt/dietpi_userdata/homeassistant + - You might want to do this manually: rm -R /mnt/dietpi_userdata/homeassistant' fi @@ -13862,7 +13905,12 @@ _EOF_ Banner_Uninstalling # Remove systemd unit - [[ -f '/etc/systemd/system/gitea.service' ]] && rm /etc/systemd/system/gitea.service + if [[ -f '/etc/systemd/system/gitea.service' ]]; then + + systemctl disable --now gitea + rm -R /etc/systemd/system/gitea.service* + + fi # Delete data [[ -d $G_FP_DIETPI_USERDATA/gitea ]] && rm -R $G_FP_DIETPI_USERDATA/gitea @@ -13983,7 +14031,7 @@ _EOF_ fi - software_id=162 + software_id=162 # Docker if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then Banner_Uninstalling @@ -14087,9 +14135,8 @@ _EOF_ G_AGP grafana [[ -f '/etc/apt/sources.list.d/grafana.list' ]] && rm /etc/apt/sources.list.d/grafana.list - - [[ -e '/var/lib/grafana' ]] && rm -R /var/lib/grafana - [[ -d $G_FP_DIETPI_USERDATA/grafana ]] && rm -R $G_FP_DIETPI_USERDATA/grafana + getent passwd grafana &> /dev/null && userdel -rf grafana + rm -Rf {$G_FP_DIETPI_USERDATA,/var/lib,/var/log,/etc}/grafana fi @@ -14125,7 +14172,7 @@ _EOF_ fi #---------------------------------------------------------------------- - #LINUX SOFTWARE + # LINUX SOFTWARE software_id=15 if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then @@ -14515,13 +14562,7 @@ _EOF_ #------------------------------------------------------------ # Update & upgrade APT Banner_Apt_Update - # - Update APT lists G_AGUP - # - Simulated APT installation to check for failures related to apt-cache. - G_DIETPI-NOTIFY 2 'Running apt simulation to check for errors, please wait...' - local package_to_test='bash-doc' - G_AGI $package_to_test -s - # - Upgrade APT packages G_AGUG # - Full upgrade on first run installs: https://github.com/MichaIng/DietPi/issues/3098 (( $G_DIETPI_INSTALL_STAGE == 1 )) && G_AGDUG @@ -14544,6 +14585,9 @@ _EOF_ # Update required software that needs to be installed Install_Flag_Prereq_Software + # Read GLOBAL_PW + Update_Global_Pw + # Install Linux Software Install_Linux_Software @@ -14564,10 +14608,10 @@ _EOF_ [[ -f '/DietPi/dietpi/.dietpi-autostart_index' ]] && autostart_current=$( /dev/null && G_AGP fake-hwclock - # x86_64 microcode installation - if (( $G_HW_ARCH == 10 )); then + # x86_64 microcode updates, skip on VM + if (( $G_HW_ARCH == 10 && $G_HW_MODEL != 20 )); then grep -qi 'vendor_id.*intel' /proc/cpuinfo && G_AGI intel-microcode grep -qi 'vendor_id.*amd' /proc/cpuinfo && G_AGI amd64-microcode + # RPi4 EEPROM update: https://github.com/MichaIng/DietPi/issues/3217 + elif (( $G_HW_MODEL == 4 )); then + + /DietPi/dietpi/func/dietpi-set_hardware rpi-eeprom + fi # Custom 1st run Script (Local file) - local run_custom_script=0 if [[ -f '/boot/Automation_Custom_Script.sh' ]]; then cp /boot/Automation_Custom_Script.sh /root/AUTO_CustomScript.sh - run_custom_script=1 # Custom 1st run Script (Online file) - elif [[ ${AUTOINSTALL_CUSTOMSCRIPTURL:-0} != '0' ]]; then + elif [[ $AUTOINSTALL_CUSTOMSCRIPTURL != '0' ]]; then - INSTALL_URL_ADDRESS=$AUTOINSTALL_CUSTOMSCRIPTURL - G_CHECK_URL "$INSTALL_URL_ADDRESS" - - # Get script and execute - wget "$INSTALL_URL_ADDRESS" -O /root/AUTO_CustomScript.sh - run_custom_script=1 + G_CHECK_URL "$AUTOINSTALL_CUSTOMSCRIPTURL" + wget "$AUTOINSTALL_CUSTOMSCRIPTURL" -O /root/AUTO_CustomScript.sh fi - if (( $run_custom_script )); then + if [[ -f '/root/AUTO_CustomScript.sh' ]]; then - local fp_dietpiautomation_custom_script_log='/var/tmp/dietpi/logs/dietpi-automation_custom_script.log' + local fp_log='/var/tmp/dietpi/logs/dietpi-automation_custom_script.log' G_DIETPI-NOTIFY 2 'Running custom script, please wait...' chmod +x /root/AUTO_CustomScript.sh - if /root/AUTO_CustomScript.sh | tee $fp_dietpiautomation_custom_script_log; then + /root/AUTO_CustomScript.sh 2>&1 | tee $fp_log + if (( ${PIPESTATUS[0]} )); then - G_DIETPI-NOTIFY 0 'Custom script' + G_DIETPI-NOTIFY 0 "Custom script: $fp_log" else - G_DIETPI-NOTIFY 1 "Custom script: Please see the log file for more information $fp_dietpiautomation_custom_script_log" + G_DIETPI-NOTIFY 1 "Custom script: $fp_log" fi @@ -14667,6 +14711,7 @@ _EOF_ [[ $AUTOINSTALL_FILESERVERINDEX ]] || AUTOINSTALL_FILESERVERINDEX=0 [[ $AUTOINSTALL_LOGGINGINDEX ]] || AUTOINSTALL_LOGGINGINDEX=0 [[ $AUTOINSTALL_WEBSERVERINDEX ]] || AUTOINSTALL_WEBSERVERINDEX=0 + [[ $AUTOINSTALL_CUSTOMSCRIPTURL ]] || AUTOINSTALL_CUSTOMSCRIPTURL=0 [[ $AUTOINSTALL_TIMESYNCMODE ]] || AUTOINSTALL_TIMESYNCMODE=2 } @@ -14724,17 +14769,17 @@ _EOF_ G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" "Automated $1" - # - Make sure we have at least one entry + # Make sure we have at least one entry if [[ -z $input ]]; then G_DIETPI-NOTIFY 1 'Please enter at least one software index ID or choice system INDEX_*_TARGET=-?' else - # - Uninstall | Stop services prior + # Uninstall | Stop services prior [[ $1 == 'uninstall' && $G_SERVICE_CONTROL != 0 ]] && /DietPi/dietpi/dietpi-services stop - # - Process inputs + # Process inputs for i in $input do @@ -14758,7 +14803,13 @@ _EOF_ elif [[ $1 == 'reinstall' ]]; then - if (( ! ${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$G_HW_ARCH]:=1} )); then + if (( ${aSOFTWARE_INSTALL_STATE[$i]} != 2 )); then + + G_DIETPI-NOTIFY 2 "$i: ${aSOFTWARE_NAME[$i]} is not currently installed" + G_DIETPI-NOTIFY 2 "Use \"dietpi-software install $i\" to install ${aSOFTWARE_NAME[$i]}." + G_DIETPI-NOTIFY 0 "No changes applied for: ${aSOFTWARE_NAME[$i]}" + + elif (( ! ${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$G_HW_ARCH]:=1} )); then G_DIETPI-NOTIFY 1 "Software title (${aSOFTWARE_NAME[$i]}) is not supported on $G_HW_ARCH_DESCRIPTION systems." @@ -14770,19 +14821,11 @@ _EOF_ G_DIETPI-NOTIFY 1 "Software title (${aSOFTWARE_NAME[$i]}) is not supported on Debian ${G_DISTRO_NAME^}." - elif (( ${aSOFTWARE_INSTALL_STATE[$i]} == 2 )); then + else aSOFTWARE_INSTALL_STATE[$i]=1 GOSTARTINSTALL=1 # Set install start flag - G_DIETPI-NOTIFY 0 "Reinstalling ${aSOFTWARE_NAME[$i]}: ${aSOFTWARE_DESC[$i]}" - sleep 0.5 - - else - - G_DIETPI-NOTIFY 2 "$i: ${aSOFTWARE_NAME[$i]} is not currently installed" - G_DIETPI-NOTIFY 2 'The program must be installed, before reinstall can be used' - G_DIETPI-NOTIFY 0 "No changes applied for: ${aSOFTWARE_NAME[$i]}" fi @@ -14804,14 +14847,12 @@ _EOF_ aSOFTWARE_INSTALL_STATE[$i]=1 GOSTARTINSTALL=1 # Set install start flag - G_DIETPI-NOTIFY 0 "Installing ${aSOFTWARE_NAME[$i]}: ${aSOFTWARE_DESC[$i]}" - sleep 0.5 else G_DIETPI-NOTIFY 2 "$i: ${aSOFTWARE_NAME[$i]} is already installed" - G_DIETPI-NOTIFY 2 "Use \"dietpi-software reinstall $i\", to force rerun of installation and configuration scripts for ${aSOFTWARE_NAME[$i]}." + G_DIETPI-NOTIFY 2 "Use \"dietpi-software reinstall $i\" to force rerun of installation and configuration steps for ${aSOFTWARE_NAME[$i]}." G_DIETPI-NOTIFY 0 "No changes applied for: ${aSOFTWARE_NAME[$i]}" fi @@ -14822,12 +14863,12 @@ _EOF_ done - # - Reinstall, prompt for backup + # Reinstall, prompt for backup if [[ $1 == 'reinstall' ]]; then (( $GOSTARTINSTALL )) && G_PROMPT_BACKUP - # - Uninstall | Finish up and clear non-required packages + # Uninstall | Finish up and clear non-required packages elif [[ $1 == 'uninstall' ]]; then Uninstall_Software @@ -15181,7 +15222,7 @@ Once completed, select "Apply Save Changes", then exit DietPi-Config to resume s local criteria_passed=1 local output_string='The following criteria must be met, for the installation of WiFi Hotspot to succeed:' - if ip r | grep -qi "eth$(sed -n 1p /DietPi/dietpi/.network)"; then + if ip r | grep -qi "eth$(mawk 'NR==1' /DietPi/dietpi/.network)"; then output_string+='\n\n - Ethernet online: PASSED' @@ -15192,7 +15233,7 @@ Once completed, select "Apply Save Changes", then exit DietPi-Config to resume s fi - if [[ -d /sys/class/net/wlan$(sed -n 2p /DietPi/dietpi/.network) ]]; then + if [[ -d /sys/class/net/wlan$(mawk 'NR==2' /DietPi/dietpi/.network) ]]; then output_string+='\n\n - Wifi adapter detected: PASSED' @@ -15275,6 +15316,16 @@ phpMyAdmin will be deselected!' fi + # Home Assistant: Inform about long install/build time: https://github.com/MichaIng/DietPi/issues/2897 + if (( ${aSOFTWARE_INSTALL_STATE[157]} == 1 )); then + + G_WHIP_MSG '[ INFO ] Home Assistant: Grab yourself a coffee +\nThe install process of Home Assistant within the virtual environment, especially the Python build, can take more than one hour, especially on slower SBCs like RPi Zero and similar. +\nPlease be patient. Meanwhile you might want to participate the discussion about reducing (re)install times, by skipping Python rebuild or installing everything outside of the pyenv environment: + - https://github.com/MichaIng/DietPi/issues/2374' + + fi + # Boot Choices if (( ${aSOFTWARE_INSTALL_STATE[23]} == 1 || ${aSOFTWARE_INSTALL_STATE[24]} == 1 || @@ -15798,7 +15849,7 @@ List of installed software and their URL links for online docs: done G_WHIP_SIZE_X_MAX=70 - G_WHIP_SCROLLBOX "$string" + G_WHIP_MSG "$string" unset string ;; @@ -16057,9 +16108,6 @@ Do you wish to continue with DietPi as a pure minimal image?'; then # Load .installed file, update vars, if it exists Read_InstallFileList #-------------------------------------------------------------------------------------- - # Update GLOBAL_PW - Update_Global_Pw - #-------------------------------------------------------------------------------------- # CLI input mode if [[ $1 ]]; then @@ -16080,13 +16128,14 @@ Do you wish to continue with DietPi as a pure minimal image?'; then # - Automation, apply as per dietpi.txt if (( $AUTOINSTALL_ENABLED )); then + Update_Global_Pw + # Set again to apply for UNIX users as well /DietPi/dietpi/func/dietpi-set_software passwords "$GLOBAL_PW" # - Prompt change global password and login passwords for root and dietpi users else /DietPi/dietpi/func/dietpi-set_software passwords - Update_Global_Pw fi @@ -16187,12 +16236,12 @@ Do you wish to continue with DietPi as a pure minimal image?'; then if (( $DISABLE_REBOOT )); then - # - Start services (restart to reload configs of possible running services) + # Start services (restart to reload configs of possible running services) [[ $G_SERVICE_CONTROL == 0 ]] || /DietPi/dietpi/dietpi-services restart else - # - Reboot + # Reboot sync Banner_Reboot reboot diff --git a/dietpi/dietpi-update b/dietpi/dietpi-update index 25e1f6e6be..8e864e6343 100644 --- a/dietpi/dietpi-update +++ b/dietpi/dietpi-update @@ -1,5 +1,5 @@ #!/bin/bash -# Load the whole script into memory. +# Load the whole script into memory { #//////////////////////////////////// # DietPi Update @@ -36,6 +36,9 @@ # Grab input disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1 || INPUT=0 + # Prefix G_DIETPI-NOTIFY 3 header text with "Phase" instead of "Mode" when not checking for available updates only + [[ $INPUT == 2 ]] || G_NOTIFY_3_MODE='Phase' + #///////////////////////////////////////////////////////////////////////////////////// # UPDATE Vars #///////////////////////////////////////////////////////////////////////////////////// @@ -152,7 +155,7 @@ If this error persists, please report at: https://github.com/MichaIng/DietPi/iss } - Apply_1st_Run_Update_Success(){ (( $G_DIETPI_INSTALL_STAGE < 2 )) && echo 1 > /DietPi/dietpi/.install_stage; } + Apply_1st_Run_Update_Success(){ [[ $G_DIETPI_INSTALL_STAGE == [12] ]] || echo 1 > /DietPi/dietpi/.install_stage; } Check_Update_Available(){ @@ -199,13 +202,20 @@ Please download the latest DietPi image from: https://dietpi.com/#download' #///////////////////////////////////////////////////////////////////////////////////// Run_Update(){ + # RC-only update: Reapply last subversion patches + if (( $G_DIETPI_VERSION_SUB == $SUBVERSION_SERVER )); then + + G_DIETPI_VERSION_SUB=$(( $G_DIETPI_VERSION_SUB - 1 )) + G_DIETPI_VERSION_RC=0 + INFO_VERSIONS_UPDATE + G_DIETPI-NOTIFY 2 "RC update: Subversion intentionally reduced to \e[33m\"$G_DIETPI_VERSION_SUB\"\e[90m to reapply the last update" + + fi + G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Applying pre-patches' G_RUN_CMD wget "${aURL_MIRROR_PREPATCH[$URL_MIRROR_INDEX]}" -O pre-patch_file chmod +x pre-patch_file - # Rerun last subversion pre-patch for RC-only updates - local subversion=$G_DIETPI_VERSION_SUB - (( $G_DIETPI_VERSION_SUB == $SUBVERSION_SERVER )) && subversion=$(( $G_DIETPI_VERSION_SUB - 1 )) - if ! ./pre-patch_file $subversion; then + if ! ./pre-patch_file $G_DIETPI_VERSION_SUB; then G_DIETPI-NOTIFY 1 "An error occured during pre-patch $?. Please check the above log or $FP_LOG for errors, and rerun \"dietpi-update\" after the cause has been solved." exit 1 @@ -234,7 +244,7 @@ Please download the latest DietPi image from: https://dietpi.com/#download' l_message='Installing new DietPi system files to disk' G_RUN_CMD cp -Rf DietPi-"$GITBRANCH_TARGET"/rootfs/. / l_message='Setting execute permissions for DietPi scripts' G_RUN_CMD chmod -R +x /DietPi/dietpi /var/lib/dietpi/services /etc/cron.*/dietpi - # Update Git owner/branch now, to download from matching branch during dietpi.txt verification and incremental patches, e.g. on reinstalls + # Save version + Git info now for sub scripts to pull from correct branch G_GITOWNER=$GITOWNER_TARGET G_GITBRANCH=$GITBRANCH_TARGET G_VERSIONDB_SAVE @@ -254,29 +264,19 @@ Please download the latest DietPi image from: https://dietpi.com/#download' while (( $G_DIETPI_VERSION_SUB < $SUBVERSION_SERVER )); do G_DIETPI-NOTIFY 2 "Patching $G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB to $COREVERSION_SERVER.$(( $G_DIETPI_VERSION_SUB + 1 ))" - /DietPi/dietpi/patch_file $G_DIETPI_VERSION_SUB || exit 1 + /DietPi/dietpi/patch_file || exit 1 G_DIETPI_VERSION_SUB=$(( $G_DIETPI_VERSION_SUB + 1 )) - G_DIETPI_VERSION_RC=$RCVERSION_SERVER # Subversion patches include latest RC update + # Save reached version info, use RC version "0" before last patch has completed + (( $G_DIETPI_VERSION_SUB == $SUBVERSION_SERVER )) && G_DIETPI_VERSION_RC=$RCVERSION_SERVER || G_DIETPI_VERSION_RC=0 + G_VERSIONDB_SAVE done - # RC-only update, rerun last subversion patch - if (( $G_DIETPI_VERSION_RC < $RCVERSION_SERVER )); then - - G_DIETPI-NOTIFY 2 "Patching $G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC to $COREVERSION_SERVER.$SUBVERSION_SERVER.$RCVERSION_SERVER" - /DietPi/dietpi/patch_file $(( $G_DIETPI_VERSION_SUB - 1 )) || exit 1 - G_DIETPI_VERSION_RC=$RCVERSION_SERVER - - fi - G_DIETPI-NOTIFY 0 "Incremental patching to v$COREVERSION_SERVER.$SUBVERSION_SERVER.$RCVERSION_SERVER completed" # Remove patch_file rm /DietPi/dietpi/patch_file - # Save current version and Git owner/branch - G_VERSIONDB_SAVE - # Update info strings INFO_VERSIONS_UPDATE @@ -378,10 +378,10 @@ Do you wish to continue and update DietPi to v$COREVERSION_SERVER.$SUBVERSION_SE elif [[ $G_WHIP_RETURNED_VALUE == 'Automatic Updates' ]]; then (( $auto_updates_enabled == 0 )) && auto_updates_enabled=1 || auto_updates_enabled=0 - (( $auto_updates_enabled )) && G_WHIP_MSG '[ INFO ] Automatic DietPi updates have been enabled.\n -Updates will be checked and applied (if update is available) daily via cron job.\n -We highly recommend you create a system backup with "DietPi-Backup" if using this feature, as automated updates will not prompt user if a failure occurs.\n -When DietPi applies updates, all system services will be temporarily stopped. Do NOT power off the unit during updates as this could render the system in a unrecoverable state.' + (( $auto_updates_enabled )) && G_WHIP_MSG '[ INFO ] Automatic DietPi updates have been enabled. +\nUpdates will be checked and applied (if update is available) daily via cron job. +\nWe highly recommend you create a system backup with "DietPi-Backup" if using this feature, as automated updates will not prompt user if a failure occurs. +\nWhen DietPi applies updates, all system services will be temporarily stopped. Do NOT power off the unit during updates as this could render the system in a unrecoverable state.' G_CONFIG_INJECT 'CONFIG_AUTO_DIETPI_UPDATES=' "CONFIG_AUTO_DIETPI_UPDATES=$auto_updates_enabled" /DietPi/dietpi.txt @@ -409,7 +409,7 @@ When DietPi applies updates, all system services will be temporarily stopped. Do # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #---------------------------------------------------------------- - G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Checking for DietPi updates' + G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Checking for available DietPi update' #---------------------------------------------------------------- # Select mirror and download server version info Get_Server_Version @@ -418,7 +418,9 @@ When DietPi applies updates, all system services will be temporarily stopped. Do if (( $INPUT == -1 )); then G_DIETPI_VERSION_SUB=$(( $G_DIETPI_VERSION_SUB - 1 )) - G_DIETPI-NOTIFY 0 "Repatch was requested: Subversion internally reduced to \"$G_DIETPI_VERSION_SUB\" to reapply the last update" + G_DIETPI_VERSION_RC=0 + INFO_VERSIONS_UPDATE + G_DIETPI-NOTIFY 2 "Repatch was requested: Subversion reduced to \e[33m\"$G_DIETPI_VERSION_SUB\"\e[90m to reapply the last update" INPUT=1 fi @@ -429,6 +431,8 @@ When DietPi applies updates, all system services will be temporarily stopped. Do # Update available and no check-only chosen if (( $UPDATE_AVAILABLE && $INPUT != 2 )); then + G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Checking for update pre-requirements' + # Verify userdata location G_CHECK_USERDATA @@ -442,8 +446,6 @@ When DietPi applies updates, all system services will be temporarily stopped. Do # Run Update if (( $RUN_UPDATE )); then - G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Applying DietPi update' - # Disable powersaving on main screen setterm -blank 0 -powersave off 2> /dev/null @@ -451,12 +453,8 @@ When DietPi applies updates, all system services will be temporarily stopped. Do /DietPi/dietpi/dietpi-services stop # Run_Update: https://github.com/MichaIng/DietPi/issues/1877#issuecomment-403866204 - # - Pre-estimate and override terminal size variables, since they cannot be estimated, if STOUT and STERR are redirected: https://github.com/MichaIng/DietPi/issues/2105 - export G_WHIP_SIZE_X_OVERRIDE=$(tput cols) - export G_WHIP_SIZE_Y_OVERRIDE=$(tput lines) # - Log to file by redirecting to subshell instead of piping, else G_ERROR_HANDLER cannot exit the script via "kill -INT $$": https://github.com/MichaIng/DietPi/issues/3127 Run_Update &> >(tee $FP_LOG_TMP); wait $! - unset G_WHIP_SIZE_X_OVERRIDE G_WHIP_SIZE_Y_OVERRIDE # Mark 1st run update as completed Apply_1st_Run_Update_Success diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index eab92f7218..77d7120757 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -54,8 +54,8 @@ # DietPi version and Git branch G_DIETPI_VERSION_CORE=${G_DIETPI_VERSION_CORE:-6} - G_DIETPI_VERSION_SUB=${G_DIETPI_VERSION_SUB:-26} - G_DIETPI_VERSION_RC=${G_DIETPI_VERSION_RC:-3} + G_DIETPI_VERSION_SUB=${G_DIETPI_VERSION_SUB:-27} + G_DIETPI_VERSION_RC=${G_DIETPI_VERSION_RC:-0} G_GITBRANCH=${G_GITBRANCH:-master} G_GITOWNER=${G_GITOWNER:-MichaIng} [[ -f '/DietPi/dietpi/.version' && $( = Max time to wait for concurrent execution to exit before user prompt (default: 5) G_INIT(){ - # Set G_PROGRAM_NAME to originating command if it was not set by originating script - [[ $G_PROGRAM_NAME ]] || G_PROGRAM_NAME=$0 - - [[ $G_DEBUG == 1 ]] && G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Running G_INIT()' + # Set G_PROGRAM_NAME to originating script file (or shell executable) name if it was not set by originating script + [[ $G_PROGRAM_NAME ]] || G_PROGRAM_NAME=${0##*/} # Check for concurrent execution if [[ $G_INIT_ALLOW_CONCURRENT != 1 ]]; then @@ -179,52 +175,32 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then # Declare exit trap, that runs on EXIT signal, which includes INT (interruption) and TERM (kill) G_EXIT(){ - # - Navigate to /tmp, if we are inside working dir, which is about to be removed - if cd /tmp; then - - [[ $G_DEBUG == 1 ]] && G_DIETPI-NOTIFY 2 'Navigated to /tmp' - - else - - [[ $G_DEBUG == 1 ]] && G_DIETPI-NOTIFY 2 'Failed to navigate to /tmp' - - fi + # Navigate to /tmp, if we are inside working dir, which is about to be removed + cd /tmp || G_DIETPI-NOTIFY 1 'Failed to navigate to /tmp' - # - Purge working directory, if existent and no concurrency allowed + # Purge working directory, if existent and no concurrency allowed if [[ $G_INIT_ALLOW_CONCURRENT != 1 && -d /tmp/$G_PROGRAM_NAME ]]; then - if rm -R /tmp/$G_PROGRAM_NAME; then - - [[ $G_DEBUG == 1 ]] && G_DIETPI-NOTIFY 2 "Removed scripts working directory: /tmp/$G_PROGRAM_NAME" - - else - - [[ $G_DEBUG == 1 ]] && G_DIETPI-NOTIFY 2 "Failed to remove scripts working directory: /tmp/$G_PROGRAM_NAME" - - fi + rm -R "/tmp/$G_PROGRAM_NAME" || G_DIETPI-NOTIFY 1 "Failed to remove scripts working directory: /tmp/$G_PROGRAM_NAME" fi - # - Execute custom exit function, if existent + # Execute custom exit function, if existent declare -F G_EXIT_CUSTOM &> /dev/null && G_EXIT_CUSTOM } trap 'G_EXIT' EXIT # Ensure we are in script working dir or users home dir, if available: https://github.com/MichaIng/DietPi/issues/905#issuecomment-298223705 - if [[ $G_PROGRAM_NAME ]] && mkdir -p /tmp/$G_PROGRAM_NAME && cd /tmp/$G_PROGRAM_NAME; then - - [[ $G_DEBUG == 1 ]] && G_DIETPI-NOTIFY 2 "Entered scripts working directory: /tmp/$G_PROGRAM_NAME" + mkdir -p "/tmp/$G_PROGRAM_NAME" && cd "/tmp/$G_PROGRAM_NAME" && return + G_DIETPI-NOTIFY 1 "Failed to create or enter scripts working directory: /tmp/$G_PROGRAM_NAME" + if [[ $HOME && -d $HOME ]]; then - elif [[ -d $HOME ]] && cd $HOME; then - - [[ $G_DEBUG == 1 ]] && G_DIETPI-NOTIFY 2 "Entered users home directory: $HOME" - - else - - [[ $G_DEBUG == 1 ]] && G_DIETPI-NOTIFY 2 "Failed to enter scripts working dir or users home dir. Will use current: $PWD" + cd "$HOME" && { G_DIETPI-NOTIFY 2 "Entered users home directory: $HOME"; return; } + G_DIETPI-NOTIFY 1 "Failed to enter users home directory: $HOME" fi + G_DIETPI-NOTIFY 2 "Will stay in current directory: $PWD" } @@ -242,11 +218,11 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then # - $2 = text # 3=DietPi banner style # - $2 = txt program name - # - $3 = txt mode + # - $3 = txt mode, prefixed with "${G_NOTIFY_3_MODE}: ", defaults to "Mode: " G_DIETPI-NOTIFY(){ local ainput_string=("$@") - local output_string='' + local output_string local bracket_l='\e[0m\e[90m[\e[0m' local bracket_r='\e[0m\e[90m]\e[0m' @@ -283,7 +259,7 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then Print_Output_String(){ [[ $1 == 1 && $G_PROGRAM_NAME ]] && output_string+="\e[90m$G_PROGRAM_NAME | \e[0m" - local i=0 + local i for ((i=$1; i<${#ainput_string[@]}; i++)) do @@ -321,7 +297,7 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then # $@ = txt desc elif (( $1 == -2 )); then - output_string="\r$bracket_l\e[33m .... $bracket_r " + output_string="\r\e[J$bracket_l\e[33m .... $bracket_r " Print_Output_String 1 if [[ -t 0 ]]; then @@ -346,7 +322,7 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then "$bright_dot$dimmed_dot " ) - local i=0 + local i for (( i=0; i<=${#aprocess_string[@]}; i++ )); do (( i == ${#aprocess_string[@]} )) && i=0 @@ -359,8 +335,8 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then # Calculate the amount of output lines and in case move cursor up for correct animation and to allow cleaning the whole output. local input_string=$(mawk '{gsub("\\\e[[0-9][;0-9]*m","");print}' <<< "${G_PROGRAM_NAME+$G_PROGRAM_NAME | }$*") # Remove colour codes - local screen_width=${G_WHIP_SIZE_X_OVERRIDE:-$(tput cols)} # Use override value in case STDOUT + STDERR are redirected - local output_lines=$(( ( ${#input_string} + 5 ) / $screen_width )) # +5 = [ .... ] - $1 + local screen_width=$(stty size) + local output_lines=$(( ( ${#input_string} + 5 ) / ${screen_width#* } )) # +5 = [ .... ] - $1 (( $output_lines )) && echo -ne "\e[${output_lines}A" # If redirect to existent PID file fails due to noclobber, don't start processing animation. # - This method prevents a tiny condition race from checking file existance until creating it, when doing: [[ ! -e file ]] && > file @@ -427,7 +403,7 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then output_string+=" \e[38;5;154m$2\e[0m \e[90m───────────────────────────────────────────────────── - Mode: \e[0m" + ${G_NOTIFY_3_MODE:-Mode}: \e[0m" ainput_string+=('\n\n') fi @@ -543,7 +519,6 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then # Input: # - G_WHIP_DEFAULT_ITEM | Optional, to set the default selected/menu item or input box entry # - G_WHIP_SIZE_X_MAX=50 | Optional, limits X to value, if below available screen X limits - # - G_WHIP_SIZE_[XY]_OVERRIDE | Optional, X/Y sizes to override auto detection (e.g. no tput due to STDOUT+STDERR redirection), must be exported and unset after use. # - G_WHIP_BUTTON_OK_TEXT | Optional, change as needed, defaults to "Ok" # - G_WHIP_BUTTON_CANCEL_TEXT | Optional, change as needed, defaults to "Cancel" # - G_WHIP_MENU_ARRAY | Required for G_WHIP_MENU to set available menu entries, 2 array indices per line: ('item' 'description') @@ -554,8 +529,6 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then # G_WHIP_DESTROY | Clear vars after run of whiptail G_WHIP_DESTROY(){ - unset WHIP_SIZE_X WHIP_SIZE_Y WHIP_SIZE_Z - unset WHIP_BACKTITLE unset G_WHIP_DEFAULT_ITEM G_WHIP_SIZE_X_MAX unset G_WHIP_BUTTON_OK_TEXT G_WHIP_BUTTON_CANCEL_TEXT unset G_WHIP_MENU_ARRAY G_WHIP_CHECKLIST_ARRAY @@ -565,231 +538,203 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then G_WHIP_DESTROY # G_WHIP_INIT - # - update target whiptail size, based on current screen dimensions. - # - Used by G_WHIP_ automatically, doesn't need to be a global function, however, bash does not support local functions. - # - $1 = input mode 0=no-Z 1=yes-Z (G_WHIP_MENU_ARRAY) 2=yes-Z (G_WHIP_CHECKLIST_ARRAY) 3=Force full size of Y + # - Update target whiptail size, based on current screen dimensions + # - $1 = input mode | 2: Z=G_WHIP_MENU_ARRAY 3: Z=G_WHIP_CHECKLIST_ARRAY G_WHIP_INIT(){ - # Set default button text, if not defined - G_WHIP_BUTTON_OK_TEXT=${G_WHIP_BUTTON_OK_TEXT:-Ok} - G_WHIP_BUTTON_CANCEL_TEXT=${G_WHIP_BUTTON_CANCEL_TEXT:-Cancel} - - # Update backtitle - WHIP_BACKTITLE="$G_PROGRAM_NAME | $G_HW_MODEL_DESCRIPTION" - [[ -r '/DietPi/dietpi/.network' ]] && WHIP_BACKTITLE+=" | IP: $(mawk 'NR==4 {print}' /DietPi/dietpi/.network)" - - # Automaticaly set size of whiptail box and contents + # Automagically set size of whiptail box and contents according to screen size and whiptail type local input_mode=$1 - # - Whip margins - local whip_x_internal_margin=4 - local whip_y_internal_margin=6 + # Update backtitle + WHIP_BACKTITLE=$G_HW_MODEL_DESCRIPTION + [[ -r '/DietPi/dietpi/.network' ]] && WHIP_BACKTITLE+=" | IP: $(mawk 'NR==4' /DietPi/dietpi/.network)" - # - Text message lines required - local lines_required_whip_y=0 - local lines_required_whip_z=0 + # Set default button text, if not defined + G_WHIP_BUTTON_OK_TEXT=${G_WHIP_BUTTON_OK_TEXT:-Ok} + G_WHIP_BUTTON_CANCEL_TEXT=${G_WHIP_BUTTON_CANCEL_TEXT:-Cancel} - # Set current screen dimensions ( - outside margin) - # - G_WHIP_SIZE_X_OVERRIDE allows to estimate and export terminal sizes outside of script/function - # This is required in case both, STOUT and STERR are redirected ( e.g. 2>&1 | tee file.log ) - # Until ncurses-bin v6.0 (current on Stretch repo), tput can not estimate terminal dimensions then. - # With ncurses-bin v6.1 (current on Buster repo) this issue is resolved. - WHIP_SIZE_X=$(( ${G_WHIP_SIZE_X_OVERRIDE:-$(tput cols)} - 6 )) - if disable_error=1 G_CHECK_VALIDINT "$G_WHIP_SIZE_X_MAX" 1 $WHIP_SIZE_X; then + # Get current screen dimensions + read -r WHIP_SIZE_Y WHIP_SIZE_X < <(stty size) + # - Limit and reset non-valid integer values to 120 characters per line + (( $WHIP_SIZE_X <= 120 )) || WHIP_SIZE_X=120 + # - If width is below 9 characters, the text field starts to cover the internal margin, regardless of content or button text, hence 9 is the absolute minimum. + (( $WHIP_SIZE_X >= 9 )) || WHIP_SIZE_X=9 + # - G_WHIP_SIZE_X_MAX allows to further reduce width, e.g. to keep X/Y ratio in beautiful range. + disable_error=1 G_CHECK_VALIDINT "$G_WHIP_SIZE_X_MAX" 0 $WHIP_SIZE_X && WHIP_SIZE_X=$G_WHIP_SIZE_X_MAX + # - If height is below 7 lines, not a single line of text can be shown, hence 7 is the reasonable minimum. + (( $WHIP_SIZE_Y >= 7 )) || WHIP_SIZE_Y=7 - WHIP_SIZE_X=$G_WHIP_SIZE_X_MAX + # Calculate lines required to show all text content + local whip_lines_text=6 # Due to internal margins, the available height is 6 lines smaller + local whip_chars_text=$(( $WHIP_SIZE_X - 4 )) # Due to internal margins, the available width is 4 characters smaller + WHIP_SCROLLTEXT= # Add "--scrolltext" automatically if text height exceeds max available - elif (( $WHIP_SIZE_X > 120 )); then + Process_Line(){ - WHIP_SIZE_X=120 + local split line=$1 - fi - - WHIP_SIZE_Y=$(( ${G_WHIP_SIZE_Y_OVERRIDE:-$(tput lines)} - 4 )) - (( $WHIP_SIZE_Y > 40 )) && WHIP_SIZE_Y=40 + # Split line by "\n" newline escape sequences, the only one which is interpreted by whiptail, in a strict way: "\\n" still creates a newline, hence the sequence cannot be escaped! + while [[ $line == *'\n'* ]] + do - WHIP_SIZE_Z=2 + # Grab first line + split=${line%%\\n*} + # Add required line + additional lines due to automated line breaks, if text exceeds internal box + (( whip_lines_text += 1 + ( ${#split} - 1 ) / $whip_chars_text )) + # Stop counting if required size exceeds screen already + (( $whip_lines_text > $WHIP_SIZE_Y )) && return 1 + # Cut away handled line from string + line=${line#*\\n} - # Force full size of Y? - if (( $input_mode == 3 )); then + done - lines_required_whip_y=$WHIP_SIZE_Y + # Process remaining line + (( whip_lines_text += 1 + ( ${#line} - 1 ) / $whip_chars_text )) + # Stop counting if required size exceeds screen already + (( $whip_lines_text <= $WHIP_SIZE_Y )) || return 1 - # Calulate lines required for WHIP_MESSAGE, as displayed inside the whiptail box - # - This can then be used to increase/decrease size of WHIP_SIZE_Z automatically. - else + } - # - Calculate lines required, including addition lines, if the text is longer than X - [[ $WHIP_MESSAGE ]] && while read -r line - do + # - WHIP_MESSAGE + if [[ $WHIP_ERROR$WHIP_MESSAGE ]]; then - (( lines_required_whip_y += 1 + ${#line} / ( $WHIP_SIZE_X - $whip_x_internal_margin) )) + while read -r line; do Process_Line "$line" || break; done <<< "$WHIP_ERROR$WHIP_MESSAGE" - done <<< "$(echo -e "$WHIP_MESSAGE")" + # - WHIP_TEXTFILE + elif [[ $WHIP_TEXTFILE ]]; then - # Process final whiptail size - # Add internal whiptail margins to end line total - (( lines_required_whip_y += $whip_y_internal_margin )) + while read -r line; do Process_Line "$line" || break; done < "$WHIP_TEXTFILE" fi - # Calculate Z - # - G_WHIP_MENU_ARRAY - if (( $input_mode == 1 )); then + unset Process_Line + + # Process menu and checklist + # - G_WHIP_MENU + if [[ $input_mode == 2 ]]; then - # - ( ${#array} + 1 ) to round up on uneven array entries - lines_required_whip_z=$(( ( ${#G_WHIP_MENU_ARRAY[@]} + 1 ) / 2 )) + # Requires 1 additional line for text + ((whip_lines_text++)) - # - Requires additional line on Y - ((lines_required_whip_y++)) + # Lines required for menu: ( ${#array} + 1 ) to round up on uneven array entries + WHIP_SIZE_Z=$(( ( ${#G_WHIP_MENU_ARRAY[@]} + 1 ) / 2 )) # Auto length for ─ - # Get max length of all the lines in odd number array 1st | '' 'this one' - local i=0 + # - Get max length of all lines in array indices 1 + 2n | '' 'this one' + local i local character_count_max=0 for (( i=1; i<${#G_WHIP_MENU_ARRAY[@]}; i+=2 )) do - if (( ${#G_WHIP_MENU_ARRAY[$i]} > $character_count_max )); then - - character_count_max=${#G_WHIP_MENU_ARRAY[$i]} - - # - cap to X | need to calculate all length of array 1st... - #if (( $character_count_max >= $WHIP_SIZE_X )); then - - #character_count_max=$WHIP_SIZE_X - #break - - #fi - - fi + (( ${#G_WHIP_MENU_ARRAY[$i]} > $character_count_max )) && character_count_max=${#G_WHIP_MENU_ARRAY[$i]} done ((character_count_max--)) # -1 for additional ● - # Now add the additional required lines - for (( i=0; i<${#G_WHIP_MENU_ARRAY[@]}; i++ )) + # - Now add the additional required lines + for (( i=1; i<${#G_WHIP_MENU_ARRAY[@]}; i+=2 )) do - if [[ ${G_WHIP_MENU_ARRAY[$i]} == '●'* ]]; then - - while (( ${#G_WHIP_MENU_ARRAY[$i]} < $character_count_max )) - do + [[ ${G_WHIP_MENU_ARRAY[$i]} == '●'* ]] || continue - G_WHIP_MENU_ARRAY[$i]+='─' + while (( ${#G_WHIP_MENU_ARRAY[$i]} < $character_count_max )) + do - done + G_WHIP_MENU_ARRAY[$i]+='─' - G_WHIP_MENU_ARRAY[$i]+='●' + done - fi + G_WHIP_MENU_ARRAY[$i]+='●' done - # - G_WHIP_CHECKLIST_ARRAY - elif (( $input_mode == 2 )); then + # - G_WHIP_CHECKLIST + elif [[ $input_mode == 3 ]]; then - # - ( ${#array} + 2 ) to round up single+double array entries - lines_required_whip_z=$(( ( ${#G_WHIP_CHECKLIST_ARRAY[@]} + 2 ) / 3 )) + # Lines required for checklist: ( ${#array} + 2 ) to round up single+double array entries + WHIP_SIZE_Z=$(( ( ${#G_WHIP_CHECKLIST_ARRAY[@]} + 2 ) / 3 )) # Auto length for ─ - # Get max length of all the lines in array index 1 1st | '' 'this one' '' - local i=0 + # - Get max length of all lines in array indices 1 + 3n 1st | '' 'this one' '' + local i local character_count_max=0 for (( i=1; i<${#G_WHIP_CHECKLIST_ARRAY[@]}; i+=3 )) do - if (( ${#G_WHIP_CHECKLIST_ARRAY[$i]} > $character_count_max )); then - - character_count_max=${#G_WHIP_CHECKLIST_ARRAY[$i]} - - # - cap to X | need to calculate all length of array 1st... - #if (( $character_count_max >= $WHIP_SIZE_X )); then - - #character_count_max=$WHIP_SIZE_X - #break - - #fi - - fi + (( ${#G_WHIP_CHECKLIST_ARRAY[$i]} > $character_count_max )) && character_count_max=${#G_WHIP_CHECKLIST_ARRAY[$i]} done ((character_count_max--)) # -1 for additional ● - # Now add the additional required lines - for (( i=0; i<${#G_WHIP_CHECKLIST_ARRAY[@]}; i++ )) + # - Now add the additional required lines + for (( i=1; i<${#G_WHIP_CHECKLIST_ARRAY[@]}; i+=3 )) do - if [[ ${G_WHIP_CHECKLIST_ARRAY[$i]} == '●'* ]]; then - - while (( ${#G_WHIP_CHECKLIST_ARRAY[$i]} < $character_count_max )) - do + [[ ${G_WHIP_CHECKLIST_ARRAY[$i]} == '●'* ]] || continue - #echo -e "${#G_WHIP_CHECKLIST_ARRAY[$i]} > $WHIP_LENGTH_AUTOLINEFILL | index=$i" - G_WHIP_CHECKLIST_ARRAY[$i]+='─' + while (( ${#G_WHIP_CHECKLIST_ARRAY[$i]} < $character_count_max )) + do - done + G_WHIP_CHECKLIST_ARRAY[$i]+='─' - G_WHIP_CHECKLIST_ARRAY[$i]+='●' + done - fi + G_WHIP_CHECKLIST_ARRAY[$i]+='●' done fi - # Calculate end result - # - Message will not fit! - if (( $lines_required_whip_y > $WHIP_SIZE_Y )); then - - G_DIETPI-NOTIFY 2 "Lines required for Whiptail box and its contents (y=$lines_required_whip_y, z=$lines_required_whip_z), exceeds screen dimensions (y=$WHIP_SIZE_Y)." - - # - Calculate a lower size of WHIP_SIZE_Y to fit everything and make it look nice! - else + # Adjust sizes to fit content + # - G_WHIP_MENU/G_WHIP_CHECKLIST needs to hold text + selection field (WHIP_SIZE_Z) + if [[ $input_mode == [23] ]]; then - # - Calc max size for lines_max_whip_z, based on lines_required_whip_y and current screen size - if (( $lines_required_whip_z > 0 )); then + # If required lines would exceed screen, reduce WHIP_SIZE_Z + if (( $whip_lines_text + $WHIP_SIZE_Z > $WHIP_SIZE_Y )); then - local lines_max_whip_z=$lines_required_whip_z + WHIP_SIZE_Z=$(( $WHIP_SIZE_Y - $whip_lines_text )) + # Assure at least 2 lines to have the selection field scroll bar identifiable + if (( $WHIP_SIZE_Z < 2 )); then - if (( ( $lines_max_whip_z + $lines_required_whip_y ) > $WHIP_SIZE_Y )); then + WHIP_SIZE_Z=2 + # Since text is partly hidden now, add text scroll ability and info to backtitle + WHIP_SCROLLTEXT='--scrolltext' + WHIP_BACKTITLE+=' | Use up/down buttons to scroll text' - lines_max_whip_z=$(( $WHIP_SIZE_Y - $lines_required_whip_y )) - - # lines_max_whip_z < 1 indicates WHIP_SIZE_Y is too small to fit all message text and any lines_required_whip_z. - # So we must force lines_max_whip_z=1 resulting in some missing message text - if (( $lines_max_whip_z < 1 )); then + fi - lines_max_whip_z=2 - G_DIETPI-NOTIFY 2 "Lines required for Whiptail box and its contents (y=$lines_required_whip_y, z=$lines_required_whip_z), exceeds screen dimensions (y=$WHIP_SIZE_Y)." + # else reduce WHIP_SIZE_Y to hold all content + else - fi + WHIP_SIZE_Y=$(( $whip_lines_text + $WHIP_SIZE_Z )) - fi + fi - WHIP_SIZE_Y=$(( $lines_required_whip_y + $lines_max_whip_z )) - WHIP_SIZE_Z=$lines_max_whip_z + # - Everything else needs to hold text only + elif (( $whip_lines_text > $WHIP_SIZE_Y )); then - else + WHIP_SCROLLTEXT='--scrolltext' + WHIP_BACKTITLE+=' | Use up/down buttons to scroll text' - WHIP_SIZE_Y=$lines_required_whip_y + else - fi + WHIP_SIZE_Y=$whip_lines_text fi } # G_WHIP_MSG "message" - # - Display a whip message + # - Display a message from input string G_WHIP_MSG(){ local WHIP_MESSAGE=$@ if (( $G_INTERACTIVE )); then - G_WHIP_INIT 0 - whiptail --title "$G_PROGRAM_NAME" --msgbox "$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" --backtitle "$WHIP_BACKTITLE" $WHIP_SIZE_Y $WHIP_SIZE_X + local WHIP_ERROR WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y + G_WHIP_INIT + whiptail ${G_PROGRAM_NAME+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --msgbox "$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" $WHIP_SCROLLTEXT $WHIP_SIZE_Y $WHIP_SIZE_X else @@ -801,41 +746,52 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then } - # G_WHIP_SCROLLBOX "message" - # - Display a whip message inside a scrollbox - G_WHIP_SCROLLBOX(){ + # G_WHIP_VIEWFILE "/path/to/file" + # - Display content from input file + # - Exit code: 1=file not found, else=file shown or noninteractive + G_WHIP_VIEWFILE(){ - local WHIP_MESSAGE=$@ + local result=0 if (( $G_INTERACTIVE )); then - G_WHIP_INIT 0 - whiptail --title "$G_PROGRAM_NAME" --scrolltext --msgbox "$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" --backtitle "$WHIP_BACKTITLE" $WHIP_SIZE_Y $WHIP_SIZE_X + local WHIP_ERROR WHIP_MESSAGE WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y WHIP_TEXTFILE=$1 header='File viewer' + [[ $log == 1 ]] && header='Log viewer' + if [[ -f $WHIP_TEXTFILE ]]; then - else + G_WHIP_INIT + whiptail --title "${G_PROGRAM_NAME+$G_PROGRAM_NAME | }$header" --backtitle "$WHIP_BACKTITLE" --textbox "$WHIP_TEXTFILE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" $WHIP_SCROLLTEXT $WHIP_SIZE_Y $WHIP_SIZE_X - G_DIETPI-NOTIFY 2 "$WHIP_MESSAGE" + else + + result=1 + WHIP_ERROR="[FAILED] File does not exist: $WHIP_TEXTFILE" + G_WHIP_INIT + whiptail --title "${G_PROGRAM_NAME+$G_PROGRAM_NAME | }$header" --backtitle "$WHIP_BACKTITLE" --msgbox "$WHIP_ERROR" --ok-button "$G_WHIP_BUTTON_OK_TEXT" $WHIP_SCROLLTEXT $WHIP_SIZE_Y $WHIP_SIZE_X + + fi fi G_WHIP_DESTROY + return $result } # G_WHIP_YESNO "message" - # - Prompt user for a Yes/No, return result - # - returns result 0=Ok, everything else considered a user cancelled result + # - Prompt user for Yes/No | Ok/Cancel choice and return result + # - Exit code: 0=Yes/Ok, else=No/Cancel or noninteractive G_WHIP_YESNO(){ local result=1 if (( $G_INTERACTIVE )); then - local WHIP_MESSAGE=$@ - G_WHIP_INIT 0 - local option_default_no='--defaultno' - [[ ${G_WHIP_DEFAULT_ITEM,,} == 'yes' || ${G_WHIP_DEFAULT_ITEM,,} == 'ok' ]] && option_default_no='' - whiptail --title "$G_PROGRAM_NAME" --yesno "$WHIP_MESSAGE" --backtitle "$WHIP_BACKTITLE" --yes-button "$G_WHIP_BUTTON_OK_TEXT" --no-button "$G_WHIP_BUTTON_CANCEL_TEXT" $option_default_no $WHIP_SIZE_Y $WHIP_SIZE_X + local WHIP_ERROR WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y WHIP_MESSAGE=$@ + G_WHIP_INIT + local default_no='--defaultno' + [[ ${G_WHIP_DEFAULT_ITEM,,} == 'yes' || ${G_WHIP_DEFAULT_ITEM,,} == 'ok' ]] && default_no= + whiptail ${G_PROGRAM_NAME+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --yesno "$WHIP_MESSAGE" --yes-button "$G_WHIP_BUTTON_OK_TEXT" --no-button "$G_WHIP_BUTTON_CANCEL_TEXT" $default_no $WHIP_SCROLLTEXT $WHIP_SIZE_Y $WHIP_SIZE_X result=$? fi @@ -847,7 +803,7 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then # G_WHIP_INPUTBOX "message" # - Prompt user to input text and save it to G_WHIP_RETURNED_VALUE - # - returns result 0=Ok, everything else considered a user cancelled result + # - Exit code: 0=input done, else=user cancelled or noninteractive G_WHIP_INPUTBOX(){ local result=1 @@ -855,16 +811,17 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then if (( $G_INTERACTIVE )); then - local WHIP_MESSAGE=$@ - G_WHIP_INIT 0 - G_WHIP_RETURNED_VALUE=$(whiptail --title "$G_PROGRAM_NAME" --inputbox "$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" --cancel-button "$G_WHIP_BUTTON_CANCEL_TEXT" --default-item "$G_WHIP_DEFAULT_ITEM" --backtitle "$WHIP_BACKTITLE" $WHIP_SIZE_Y $WHIP_SIZE_X "$G_WHIP_DEFAULT_ITEM" 3>&1 1>&2 2>&3-; echo $? > /tmp/.G_WHIP_INPUTBOX_RESULT) - result=$(&1 1>&2 2>&3-; echo $? > /tmp/.G_WHIP_INPUTBOX_RESULT) + result=$(&1 1>&2 2>&3-) - local password_1=$(whiptail --title "$G_PROGRAM_NAME" --passwordbox 'Please enter the new password again:' --ok-button "$G_WHIP_BUTTON_OK_TEXT" --nocancel --backtitle "$WHIP_BACKTITLE" $WHIP_SIZE_Y $WHIP_SIZE_X 3>&1 1>&2 2>&3-) - if [[ $password_0 && $password_0 == "$password_1" ]]; then - - result=$password_0 - return_value=0 - break - - else - - whiptail --title "$G_PROGRAM_NAME" --msgbox '[FAILED] No password entered, or invalid match.\n\nPlease try again...' --ok-button 'Retry' --backtitle "$WHIP_BACKTITLE" 9 60 - - fi + G_WHIP_INIT + local password_0=$(whiptail ${G_PROGRAM_NAME+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --passwordbox "$WHIP_ERROR$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" --nocancel $WHIP_SCROLLTEXT $WHIP_SIZE_Y $WHIP_SIZE_X 3>&1 1>&2 2>&3-) + [[ $password_0 ]] || { WHIP_ERROR='[FAILED] No password entered, please try again...\n\n'; continue; } + local password_1=$(whiptail ${G_PROGRAM_NAME+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --passwordbox 'Please enter the new password again:' --ok-button "$G_WHIP_BUTTON_OK_TEXT" --nocancel 7 $WHIP_SIZE_X 3>&1 1>&2 2>&3-) + [[ $password_0 == "$password_1" ]] || { WHIP_ERROR='[FAILED] Passwords do not match, please try again...\n\n'; continue; } + result=$password_0 + return_value=0 + break done @@ -913,18 +864,18 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then } # G_WHIP_MENU "message" - # - Prompt user to select option from G_WHIP_MENU_ARRAY and sets G_WHIP_RETURNED_VALUE - # - returns result 0=Ok, everything else considered a user canceled result + # - Prompt user to select option from G_WHIP_MENU_ARRAY and save choice to G_WHIP_RETURNED_VALUE + # - Exit code: 0=selection done, else=user cancelled or noninteractive G_WHIP_MENU(){ local result=1 - unset G_WHIP_RETURNED_VALUE # in case left from last G_WHIP + unset G_WHIP_RETURNED_VALUE # in case left from last call if (( $G_INTERACTIVE )); then - local WHIP_MESSAGE=$@ - G_WHIP_INIT 1 - G_WHIP_RETURNED_VALUE=$(whiptail --title "$G_PROGRAM_NAME" --menu "$WHIP_MESSAGE" --default-item "$G_WHIP_DEFAULT_ITEM" --ok-button "$G_WHIP_BUTTON_OK_TEXT" --cancel-button "$G_WHIP_BUTTON_CANCEL_TEXT" --backtitle "$WHIP_BACKTITLE" $WHIP_SIZE_Y $WHIP_SIZE_X $WHIP_SIZE_Z "${G_WHIP_MENU_ARRAY[@]}" 3>&1 1>&2 2>&3-; echo $? > /tmp/.WHIP_MENU_RESULT) + local WHIP_ERROR WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y WHIP_SIZE_Z WHIP_MESSAGE=$@ + G_WHIP_INIT 2 + G_WHIP_RETURNED_VALUE=$(whiptail ${G_PROGRAM_NAME+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --menu "$WHIP_MESSAGE" --ok-button "$G_WHIP_BUTTON_OK_TEXT" --cancel-button "$G_WHIP_BUTTON_CANCEL_TEXT" --default-item "$G_WHIP_DEFAULT_ITEM" $WHIP_SCROLLTEXT $WHIP_SIZE_Y $WHIP_SIZE_X $WHIP_SIZE_Z "${G_WHIP_MENU_ARRAY[@]}" 3>&1 1>&2 2>&3-; echo $? > /tmp/.WHIP_MENU_RESULT) result=$(&1 1>&2 2>&3-; echo $? > /tmp/.WHIP_CHECKLIST_RESULT) + local WHIP_ERROR WHIP_BACKTITLE WHIP_SCROLLTEXT WHIP_SIZE_X WHIP_SIZE_Y WHIP_SIZE_Z WHIP_MESSAGE=$@ + G_WHIP_INIT 3 + G_WHIP_RETURNED_VALUE=$(whiptail ${G_PROGRAM_NAME+--title "$G_PROGRAM_NAME"} --backtitle "$WHIP_BACKTITLE" --checklist "$WHIP_MESSAGE" --separate-output --ok-button "$G_WHIP_BUTTON_OK_TEXT" --cancel-button "$G_WHIP_BUTTON_CANCEL_TEXT" --default-item "$G_WHIP_DEFAULT_ITEM" $WHIP_SCROLLTEXT $WHIP_SIZE_Y $WHIP_SIZE_X $WHIP_SIZE_Z "${G_WHIP_CHECKLIST_ARRAY[@]}" 3>&1 1>&2 2>&3-; echo $? > /tmp/.WHIP_CHECKLIST_RESULT) G_WHIP_RETURNED_VALUE=$(echo -e "$G_WHIP_RETURNED_VALUE" | tr '\n' ' ') result=$(&1 1>&2 2>&3-) + local choice=$(whiptail --title "${G_PROGRAM_NAME+$G_PROGRAM_NAME | }Error handler" --menu "$whip_msg" --cancel-button "$no_button_text" --scrolltext 24 90 $retry_menu_options_count "${aretry_menu_options[@]}" 3>&1 1>&2 2>&3-) if (( $? == 0 )); then if [[ $choice == 'Retry' ]]; then @@ -1126,7 +1033,7 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then elif [[ $choice == 'Send report' ]]; then send_bugreport=1 - bugreport_id=$(mawk 'NR==5 {print}' /DietPi/dietpi/.hw_model) + bugreport_id=$(mawk 'NR==5' /DietPi/dietpi/.hw_model) fi @@ -1134,7 +1041,7 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then else - whiptail --title 'DietPi Error Handler:' --msgbox "$whip_msg" --scrolltext 22 85 + whiptail --title "${G_PROGRAM_NAME+$G_PROGRAM_NAME | }Error handler" --msgbox "$whip_msg" --scrolltext 22 85 fi @@ -1146,7 +1053,7 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then fi # GitHub printout - if [[ $G_ERROR_HANDLER_INFO_ONLY != 1 ]]; then + if [[ ${G_PROGRAM_NAME,,} == 'dietpi-'* && $G_ERROR_HANDLER_INFO_ONLY != 1 ]]; then echo -e " \e[41m @@ -1163,9 +1070,9 @@ $(ps f -eo pid,user,tty,cmd | grep -i '[d]ietpi')"; then - DietPi version | $version_info - Image creator | $image_creator - Pre-image | $preimage_name -- SBC device | $G_HW_MODEL_DESCRIPTION (index=$G_HW_MODEL) +- SBC device | $G_HW_MODEL_DESCRIPTION (ID=$G_HW_MODEL) - Kernel version | $(uname -a) -- Distro | $G_DISTRO_NAME (index=$G_DISTRO) +- Distro | $G_DISTRO_NAME (ID=$G_DISTRO) - Command | $G_ERROR_HANDLER_COMMAND - Exit code | $G_ERROR_HANDLER_EXITCODE - Software title | $G_PROGRAM_NAME @@ -1252,8 +1159,7 @@ $logfile_content while (( $G_ERROR_HANDLER_RETRY )) do - [[ $l_message ]] || local l_message=$G_ERROR_HANDLER_COMMAND - G_DIETPI-NOTIFY -2 "$l_message" + G_DIETPI-NOTIFY -2 "${l_message:-$G_ERROR_HANDLER_COMMAND}" $G_ERROR_HANDLER_COMMAND &> /tmp/G_ERROR_HANDLER_COMMAND G_ERROR_HANDLER_EXITCODE=$? @@ -1287,7 +1193,7 @@ $logfile_content elif [[ -f '/DietPi/dietpi.txt' ]]; then - timeout=$(grep -m1 '^[[:blank:]]*CONFIG_G_CHECK_URL_TIMEOUT=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + timeout=$(sed -n '/^[[:blank:]]*CONFIG_G_CHECK_URL_TIMEOUT=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) disable_error=1 G_CHECK_VALIDINT "$timeout" 0 || timeout=5 fi @@ -1299,7 +1205,7 @@ $logfile_content elif [[ -f '/DietPi/dietpi.txt' ]]; then - attempts=$(grep -m1 '^[[:blank:]]*CONFIG_G_CHECK_URL_ATTEMPTS=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + attempts=$(sed -n '/^[[:blank:]]*CONFIG_G_CHECK_URL_ATTEMPTS=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) disable_error=1 G_CHECK_VALIDINT "$attempts" 0 || attempts=3 fi @@ -1827,7 +1733,7 @@ $logfile_content local return_value=1 local input_path=$1 local input_required_space=$2 - local available_space=$(df -m --output=avail $input_path | mawk 'NR==2 {print $1;exit}') + local available_space=$(df -m --output=avail $input_path | mawk 'NR==2 {print $1}') if [[ ! $input_required_space ]]; then @@ -2109,18 +2015,16 @@ $logfile_content # Restore backup and update DietPi to latest development branch code # - Restore backup # - Set dev branch - # - Update DietPi, setting subversion code -1 + # - Reapply latest DietPi update # - Update backup G_DEV_1(){ G_CHECK_ROOT_USER 1 - export G_INTERACTIVE=0 /DietPi/dietpi/dietpi-backup -1 G_CONFIG_INJECT 'DEV_GITBRANCH=' 'DEV_GITBRANCH=dev' /DietPi/dietpi.txt /DietPi/dietpi/dietpi-update -1 /DietPi/dietpi/dietpi-backup 1 - unset G_INTERACTIVE } @@ -2137,7 +2041,7 @@ $logfile_content # Automatically opt in to DietPi-Survey and run + send benchmark + data G_DEV_BENCH(){ - echo 1 > /DietPi/dietpi/.dietpi-survey + G_CONFIG_INJECT 'SURVEY_OPTED_IN=' 'SURVEY_OPTED_IN=1' /DietPi/dietpi.txt G_INTERACTIVE=0 /DietPi/dietpi/func/dietpi-benchmark 2 } @@ -2147,12 +2051,12 @@ $logfile_content # - $1 Setting pattern to find existing setting with grep extended regular expression support # - $2 Target setting + value, to inject into config file: After bash string expansion (e.g. variables), everything else will be taken literally, thus no further escaping is required. # - $3 Path to config file - # - Optional: $4 Line pattern after which the setting will be added instead of end of file with grep extended regular expression support + # - $4 (optional) Line pattern after which the setting will be added instead of end of file with grep extended regular expression support # - GCI_PASSWORD=1 G_CONFIG_INJECT, password entry, do not print raw output to screen. # - GCI_PRESERVE=1 G_CONFIG_INJECT preserves current setting, if present. # - GCI_BACKUP=1 G_CONFIG_INJECT creates a backup before editing the file, if backup does not yet exist, to: $3.bak # - GCI_NEWLINE=1 G_CONFIG_INJECT explicitly expands newlines \n within $2, which by default are taken literally - # - Be careful with this, since pattern matching is only done per line which can lead to doubled lines when applying G_CONFIG_INJECT a second time. + # NB: Be careful with this, since pattern matching is only done per line which can lead to doubled lines when applying G_CONFIG_INJECT a second time. # NB: # - Within double quotes "", as usual, escape literally meant double quotes and dollar signs $ with leading backslash \. # - Within single quotes '', as usual, escape literally meant single quotes via: '\'' # End leading string; Add escaped single quote; Start trailing string @@ -2170,13 +2074,12 @@ $logfile_content [[ $GCI_NEWLINE == 1 ]] && setting=${setting//\\\\n/\\n} local file=$3 local after=${4//\//\\\/} - local error='' + local error # Replace password string by asterisks in output string if [[ $GCI_PASSWORD == 1 ]]; then - local password='' - password=$(sed -E "s/^.*$pattern[[:blank:]]*//" <<< "$setting_raw") + local password=$(sed -E "s/^.*$pattern[[:blank:]]*//" <<< "$setting_raw") setting_raw="$(sed -E "s/(^.*$pattern[[:blank:]]*).*$/\1/" <<< "$setting_raw")${password//?/*}" unset password @@ -2209,10 +2112,10 @@ NB: if [[ ! -w $file ]]; then - G_WHIP_MSG "[FAILED] File does not exist or cannot be written to by current user\n -Please verify the existence of the file \$3 - $file\n -Retry with proper permissions or apply the setting manually: + G_WHIP_MSG "[FAILED] File does not exist or cannot be written to by current user +\nPlease verify the existence of the file \$3 + $file +\nRetry with proper permissions or apply the setting manually: $setting_raw" elif error=$(grep -Eq "^[[:blank:]]*$pattern" $file 2>&1); then @@ -2229,15 +2132,15 @@ Retry with proper permissions or apply the setting manually: elif error=$( (( $(grep -Ec "^[[:blank:]]*$pattern" $file 2>&1) > 1 )) 2>&1); then [[ $error ]] && { syntax_error; return 1; } - G_WHIP_MSG "[FAILED] Setting was found multiple times\n -The pattern \$1 + G_WHIP_MSG "[FAILED] Setting was found multiple times +\nThe pattern \$1 $(sed -E "c\\$pattern" <<< '') was found multiple times in file \$3 - $file\n -____________ + $file +\n____________ $(grep -En "^[[:blank:]]*$pattern" $file) -____________\n -Either the pattern \$1 needs to be more specific or the desired setting can appear multiple times by design and it cannot be predicted which instance to edit. +____________ +\nEither the pattern \$1 needs to be more specific or the desired setting can appear multiple times by design and it cannot be predicted which instance to edit. Please retry with more specific parameter \$1 or apply the setting manually: $setting_raw" @@ -2271,12 +2174,12 @@ Please retry with more specific parameter \$1 or apply the setting manually: else [[ $error ]] && { syntax_error; return 1; } - G_WHIP_MSG "[FAILED] Setting could not be added after desired line\n -The pattern \$4 + G_WHIP_MSG "[FAILED] Setting could not be added after desired line +\nThe pattern \$4 $(sed -E "c\\$after" <<< '') could not be found in file \$3 - $file\n -Please retry with valid parameter \$4 or apply the setting manually: + $file +\nPlease retry with valid parameter \$4 or apply the setting manually: $setting_raw" fi diff --git a/dietpi/func/dietpi-logclear b/dietpi/func/dietpi-logclear index fe71380c83..3c1bd5e0d3 100644 --- a/dietpi/func/dietpi-logclear +++ b/dietpi/func/dietpi-logclear @@ -68,12 +68,12 @@ #----------------------------------------------------------------------------------- # Process Logfiles - for ((i=0; i<${#ARRAY_LOG_FILEPATH[@]}; i++)) + for i in "${ARRAY_LOG_FILEPATH[@]}" do # File details - FILE_NAME=${ARRAY_LOG_FILEPATH[$i]#/var/log/} - FILESIZE_BYTES=$(stat -c%s "${ARRAY_LOG_FILEPATH[$i]}") + FILE_NAME=${i#/var/log/} + FILESIZE_BYTES=$(stat -c%s "$i") PROCESS_FILE=1 FILE_TYPE=0 @@ -98,7 +98,7 @@ # Delete all compressed filetypes if (( $FILE_TYPE == 1 )); then - rm "${ARRAY_LOG_FILEPATH[$i]}" + rm "$i" ((INFO_LOGS_DELETED++)) ((INFO_LOGS_NOTSUPPORTED++)) @@ -116,23 +116,23 @@ fi # Write current logfile contents to existing. - cat "${ARRAY_LOG_FILEPATH[$i]}" >> "$FILEPATH_BACKUPFOLDER/$FILE_NAME" + cat "$i" >> "$FILEPATH_BACKUPFOLDER/$FILE_NAME" ((INFO_BACKUPS_MADE++)) # Clear logfile contents - > "${ARRAY_LOG_FILEPATH[$i]}" + > "$i" ((INFO_LOGS_CLEARED++)) # Clear logfile contents elif (( $INPUT == 1 )); then - > "${ARRAY_LOG_FILEPATH[$i]}" + > "$i" ((INFO_LOGS_CLEARED++)) # Hard delete log files elif (( $INPUT == 2 )); then - rm "${ARRAY_LOG_FILEPATH[$i]}" + rm "$i" ((INFO_LOGS_DELETED++)) fi diff --git a/dietpi/func/dietpi-obtain_hw_model b/dietpi/func/dietpi-obtain_hw_model index ea92da53ad..90b4a349e9 100644 --- a/dietpi/func/dietpi-obtain_hw_model +++ b/dietpi/func/dietpi-obtain_hw_model @@ -24,12 +24,13 @@ # G_HW_MODEL 68 NanoPC T4 # G_HW_MODEL 67 NanoPi K1 Plus # G_HW_MODEL 66 NanoPi M1 Plus - # G_HW_MODEL 65 NanoPi NEO 2 + # G_HW_MODEL 65 NanoPi NEO2 # G_HW_MODEL 64 NanoPi NEO Air # G_HW_MODEL 63 NanoPi M1/T1 - # G_HW_MODEL 62 NanoPi M3/T3/F3(fire3) + # G_HW_MODEL 62 NanoPi M3/T3/Fire3 # G_HW_MODEL 61 NanoPi M2/T2 - # G_HW_MODEL 60 NanoPi Neo + # G_HW_MODEL 60 NanoPi NEO + # G_HW_MODEL 59 ZeroPi # G_HW_MODEL 53 BananaPi (sinovoip) # G_HW_MODEL 52 Asus Tinker Board # G_HW_MODEL 51 BananaPi Pro (Lemaker) @@ -49,20 +50,20 @@ # G_HW_MODEL 32 OrangePi Zero (H2+) # G_HW_MODEL 31 OrangePi One # G_HW_MODEL 30 OrangePi PC - # G_HW_MODEL 22 Generic device (eg: unknown to DietPi) - # G_HW_MODEL 21 x86_64 native (PC) - # G_HW_MODEL 20 VM x64 (VMware, VirtualBox, Hyper-V, ...) + # G_HW_MODEL 22 Generic device + # G_HW_MODEL 21 x86_64 PC + # G_HW_MODEL 20 x86_64 VM # G_HW_MODEL 15 Odroid N2 # G_HW_MODEL 14 Odroid N1 # G_HW_MODEL 13 Odroid U3 # G_HW_MODEL 12 Odroid C2 - # G_HW_MODEL 11 Odroid XU3/XU4/HC1/HC2 + # G_HW_MODEL 11 Odroid XU3/XU4/HC1/HC2/MC1 # G_HW_MODEL 10 Odroid C1 # G_HW_MODEL 4 Raspberry Pi 4 # G_HW_MODEL 3 Raspberry Pi 3/3+ # G_HW_MODEL 2 Raspberry Pi 2 - # G_HW_MODEL 1 Raspberry Pi 1/Zero (512mb) - # G_HW_MODEL 0 Raspberry Pi 1 (256mb) + # G_HW_MODEL 1 Raspberry Pi 1/Zero (512 MiB) + # G_HW_MODEL 0 Raspberry Pi 1 (256 MiB) # ---- Line 2 ---- # G_HW_MODEL_DESCRIPTION # ---- Line 3 ---- @@ -604,12 +605,18 @@ G_HW_MODEL_DESCRIPTION='NanoPi M2/T2' - # NanoPi Neo + # NanoPi NEO elif (( $G_HW_MODEL == 60 )); then G_HW_MODEL_DESCRIPTION='NanoPi Neo' G_HW_CPUID=1 + # ZeroPi + elif (( $G_HW_MODEL == 59 )); then + + G_HW_MODEL_DESCRIPTION='ZeroPi' + G_HW_CPUID=1 + # BananaPi (1st Gen) elif (( $G_HW_MODEL == 53 )); then diff --git a/dietpi/func/dietpi-set_cpu b/dietpi/func/dietpi-set_cpu index bfd9561efc..cc6a5c998f 100644 --- a/dietpi/func/dietpi-set_cpu +++ b/dietpi/func/dietpi-set_cpu @@ -9,11 +9,20 @@ #//////////////////////////////////// # # Info: - # - Runs at boot up /DietPi/dietpi/boot - # - Sets CPU governor | ondemand | powersave | performance etc - # - Sets CPU governor user prefs | throttle up percent etc + # - Location: /{DietPi,boot}/dietpi/func/dietpi-set_cpu + # - Runs at boot, called by /DietPi/dietpi/preboot + # - Applies CPU governor: ondemand, powersave, performance, etc. + # - Applies CPU governor settings: throttle up percent etc. #//////////////////////////////////// + # Exit if not supported + if [[ ! -f '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors' ]]; then + + echo 'DietPi-CPU_set | CPU governors are not supported on this device. Aborting...' + exit + + fi + # Import DietPi-Globals -------------------------------------------------------------- . /DietPi/dietpi/func/dietpi-globals G_PROGRAM_NAME='DietPi-CPU_set' @@ -21,28 +30,23 @@ G_INIT # Import DietPi-Globals -------------------------------------------------------------- - # Exit path for VM - if (( $G_HW_MODEL == 20 )); then - - echo -e '\nNotice: CPU Governors are not available for VM.\n' - exit - - fi - CPU_GOVERNOR=$(sed -n '/^[[:blank:]]*CONFIG_CPU_GOVERNOR=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + [[ $CPU_GOVERNOR ]] || CPU_GOVERNOR='ondemand' + + Check_CPU_Gov_Available(){ - Check_GPU_Gov_Available(){ + local available_governors=$( /sys/devices/system/cpu/intel_pstate/no_turbo - G_DIETPI-NOTIFY 2 'Disabled Intel Turbo Mode' else + G_DIETPI-NOTIFY 2 'Enabling Intel Turbo Mode' echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo - G_DIETPI-NOTIFY 2 'Enabled Intel Turbo Mode' fi + else + + G_DIETPI-NOTIFY 2 'Intel Turbo Mode is not supported on this device' + fi # Standard via kernel (MHz) elif [[ -f '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq' ]]; then # Reset to defaults if no/invalid entry - local converted_hz_value_max=-1 # -1 indicates reset CPU freqs - local converted_hz_value_min=-1 # -1 indicates reset CPU freqs - disable_error=1 G_CHECK_VALIDINT "$cpu_max_freq" && converted_hz_value_max=$(( $cpu_max_freq * 1000 )) - disable_error=1 G_CHECK_VALIDINT "$cpu_min_freq" && converted_hz_value_min=$(( $cpu_min_freq * 1000 )) + local converted_khz_value_max=-1 # -1 indicates reset CPU freqs + local converted_khz_value_min=-1 # -1 indicates reset CPU freqs + disable_error=1 G_CHECK_VALIDINT "$cpu_max_freq" 1 && converted_khz_value_max=$(( $cpu_max_freq * 1000 )) # MHz => kHz + disable_error=1 G_CHECK_VALIDINT "$cpu_min_freq" 1 && converted_khz_value_min=$(( $cpu_min_freq * 1000 )) # MHz => kHz + + G_DIETPI-NOTIFY 2 "Setting CPU frequency limits : Max = $cpu_max_freq MHz | Min = $cpu_min_freq MHz" - G_DIETPI-NOTIFY 2 "Setting CPU freq: Max = $cpu_max_freq kHz | Min = $cpu_min_freq kHz" - for ((i=$input_core_start; i<$input_core_end; i++)) + for i in /sys/devices/system/cpu/cpu[0-9]*/cpufreq do - if (( $converted_hz_value_min > 0 )); then + if (( $converted_khz_value_min > 0 )); then - echo $converted_hz_value_min > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_min_freq + echo $converted_khz_value_min > $i/scaling_min_freq else - mawk '{print $1}' /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_available_frequencies > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_min_freq + mawk '{print $1}' $i/scaling_available_frequencies > $i/scaling_min_freq fi - if (( $converted_hz_value_max > 0 )); then + if (( $converted_khz_value_max > 0 )); then - echo $converted_hz_value_max > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_max_freq + echo $converted_khz_value_max > $i/scaling_max_freq else - mawk '{print $NF}' /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_available_frequencies > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_max_freq + mawk '{print $NF}' $i/scaling_available_frequencies > $i/scaling_max_freq fi done + else + + G_DIETPI-NOTIFY 2 'CPU frequency limits are not supported on this device' + fi fi @@ -151,7 +161,7 @@ local cpu_throttle_up_percent=$(sed -n '/^[[:blank:]]*CONFIG_CPU_USAGE_THROTTLE_UP=/{s/[^=]*=//p;q}' /DietPi/dietpi.txt) # Set CPU governor interactive settings - if [[ $input_gov_name == 'interactive' ]]; then + if [[ $CPU_GOVERNOR == 'interactive' ]]; then # Set hispeed_load, if available on system (eg: XU4 kernel lacks this feature) if [[ -f '/sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load' ]]; then @@ -159,10 +169,14 @@ G_DIETPI-NOTIFY 2 "Setting go_hispeed_load: $cpu_throttle_up_percent %" echo $cpu_throttle_up_percent > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + else + + G_DIETPI-NOTIFY 2 'go_hispeed_load is not supported on your device' + fi # Set CPU governor ondemand settings - elif [[ $input_gov_name == 'ondemand' ]]; then + elif [[ $CPU_GOVERNOR == 'ondemand' ]]; then local cpu_ondemand_sampling_rate=$(sed -n '/^[[:blank:]]*CONFIG_CPU_ONDEMAND_SAMPLE_RATE=/{s/[^=]*=//p;q}' /DietPi/dietpi.txt) local cpu_ondemand_sampling_down_factor=$(sed -n '/^[[:blank:]]*CONFIG_CPU_ONDEMAND_SAMPLE_DOWNFACTOR=/{s/[^=]*=//p;q}' /DietPi/dietpi.txt) @@ -180,36 +194,46 @@ echo $cpu_ondemand_sampling_down_factor > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor # - XU4 3.x kernel - else + elif [[ -f '/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold' ]]; then # Apply to all cores - for ((i=$input_core_start; i<$input_core_end; i++)) + for i in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/ondemand do - echo $cpu_throttle_up_percent > /sys/devices/system/cpu/cpu${i}/cpufreq/ondemand/up_threshold - echo $cpu_ondemand_sampling_rate > /sys/devices/system/cpu/cpu${i}/cpufreq/ondemand/sampling_rate - echo $cpu_ondemand_sampling_down_factor > /sys/devices/system/cpu/cpu${i}/cpufreq/ondemand/sampling_down_factor + echo $cpu_throttle_up_percent > $i/up_threshold + echo $cpu_ondemand_sampling_rate > $i/sampling_rate + echo $cpu_ondemand_sampling_down_factor > $i/sampling_down_factor done + else + + G_DIETPI-NOTIFY 2 'up_threshold is not supported on your device' + fi # Set CPU governor conservative settings - elif [[ $input_gov_name == 'conservative' ]]; then + elif [[ $CPU_GOVERNOR == 'conservative' ]]; then + + G_DIETPI-NOTIFY 2 "Setting up_threshold: $cpu_throttle_up_percent %" # XU3/4 different path (must apply to each core) - if (( $G_HW_MODEL == 11 )); then + if [[ $G_HW_MODEL != 11 && -f '/sys/devices/system/cpu/cpufreq/conservative/up_threshold' ]]; then - for ((i=$input_core_start; i<$input_core_end; i++)) + echo $cpu_throttle_up_percent > /sys/devices/system/cpu/cpufreq/conservative/up_threshold + + elif [[ -f '/sys/devices/system/cpu/cpu0/cpufreq/conservative' ]]; then + + for i in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/conservative do - echo $cpu_throttle_up_percent > /sys/devices/system/cpu/cpu${i}/cpufreq/conservative/up_threshold + echo $cpu_throttle_up_percent > $i/up_threshold done else - echo $cpu_throttle_up_percent > /sys/devices/system/cpu/cpufreq/conservative/up_threshold + G_DIETPI-NOTIFY 2 'up_threshold is not supported on your device' fi @@ -221,14 +245,14 @@ # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #----------------------------------------------------------------------------------- - G_DIETPI-NOTIFY 3 $G_PROGRAM_NAME 'Applying CPU gov' + G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" "Applying CPU governor settings: $CPU_GOVERNOR" #----------------------------------------------------------------------------------- - Check_GPU_Gov_Available + Check_CPU_Gov_Available # Apply CPU0 gov to all cores (if required) - Apply_CPU_Gov $CPU_GOVERNOR 0 $G_HW_CPU_CORES + Apply_CPU_Gov - G_DIETPI-NOTIFY 0 "CPU gov applied: $CPU_GOVERNOR\n" + G_DIETPI-NOTIFY 0 "Applied CPU governor settings: $CPU_GOVERNOR" #----------------------------------------------------------------------------------- exit diff --git a/dietpi/func/dietpi-set_hardware b/dietpi/func/dietpi-set_hardware index f92f613464..0f1abd93ce 100644 --- a/dietpi/func/dietpi-set_hardware +++ b/dietpi/func/dietpi-set_hardware @@ -29,6 +29,7 @@ $FP_SCRIPT gpumemsplit 64/128/256 # RPi only $FP_SCRIPT rpi-camera enable/disable $FP_SCRIPT rpi-opengl vc4-kms-v3d/vc4-fkms-v3d/disable $FP_SCRIPT rpi3_usb_boot enable +$FP_SCRIPT rpi-eeprom " #//////////////////////////////////// # Grab Inputs @@ -192,6 +193,27 @@ _EOF_ } + #///////////////////////////////////////////////////////////////////////////////////// + # rpi-eeprom: https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md + #///////////////////////////////////////////////////////////////////////////////////// + RPi_EEPROM(){ + + (( $G_HW_MODEL == 4 )) || { Unsupported_Input_Name; return 1; } # Exit path for non-RPi4 + + # Install required APT package, be failsafe and install/upgrade VC firmware and bootloader as well + G_AGUP + G_AGI rpi-eeprom rpi-eeprom-images flashrom libraspberrypi-bin raspberrypi-bootloader + # - Workaround: https://github.com/RPi-Distro/repo/issues/156 + G_AG_CHECK_INSTALL_PREREQ binutils + + # Update/flash new bootloader and VL805 USB firmware to EEPROM + rpi-eeprom-update -a + + # Required? Enable update service to run on every boot + systemctl enable rpi-eeprom-update + + } + #///////////////////////////////////////////////////////////////////////////////////// # gpumemsplit #///////////////////////////////////////////////////////////////////////////////////// @@ -2230,6 +2252,10 @@ _EOF_ RPi_USB_Boot_Main + elif [[ $INPUT_DEVICE_NAME == 'rpi-eeprom' ]]; then + + RPi_EEPROM + elif [[ $INPUT_DEVICE_NAME == 'headless' ]]; then Headless_Main diff --git a/dietpi/func/dietpi-set_swapfile b/dietpi/func/dietpi-set_swapfile index f6747eb501..ccff300da2 100644 --- a/dietpi/func/dietpi-set_swapfile +++ b/dietpi/func/dietpi-set_swapfile @@ -24,8 +24,8 @@ G_INIT # Import DietPi-Globals -------------------------------------------------------------- - SWAP_SIZE=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') - SWAP_LOCATION=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + SWAP_SIZE=$(sed -n '/^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + SWAP_LOCATION=$(sed -n '/^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) disable_error=1 G_CHECK_VALIDINT "$1" && SWAP_SIZE_TARGET=$1 || SWAP_SIZE_TARGET=$SWAP_SIZE [[ $2 ]] && SWAP_LOCATION_TARGET=$2 || SWAP_LOCATION_TARGET=$SWAP_LOCATION @@ -40,13 +40,11 @@ Update_Tmp(){ # Set /tmp to 50% of RAM+SWAP: https://github.com/MichaIng/DietPi/issues/1027#issuecomment-369373082 - local mem_total=$(free -m | mawk '/Mem:/ {print $2;exit}') - local swap_size=$(free -m | mawk '/Swap:/ {print $2;exit}') - local tmp_target_size="$(( ( $mem_total + $swap_size ) / 2 ))M" + local tmp_target_size="$(( $(free -tm | mawk '/^Total:/{print $2;exit}') / 2 ))M" G_DIETPI-NOTIFY 2 "Setting /tmp tmpfs size: $tmp_target_size" - sed -i "/[[:blank:]]\/tmp[[:blank:]]/ctmpfs \/tmp tmpfs defaults,size=$tmp_target_size,noatime,nodev,nosuid,mode=1777 0 0" /etc/fstab + sed -i "/[[:blank:]]\/tmp[[:blank:]]/ctmpfs \/tmp tmpfs size=$tmp_target_size,noatime,lazytime,nodev,nosuid,mode=1777" /etc/fstab systemctl daemon-reload mount -a # Required if /tmp was somehow not mounted before. Will be skipped if already mounted G_RUN_CMD mount -o remount /tmp # Required to apply new settings/size. "remount" required to preserve current content, or, doubled mount @@ -74,7 +72,7 @@ Swap_Enable(){ local swap_dir="${SWAP_LOCATION_TARGET%/*}/" - local fs_type=$(findmnt -n -o FSTYPE -T "$swap_dir") + local fs_type=$(findmnt -no FSTYPE -T "$swap_dir") # Exclude devices # - BBB @@ -140,7 +138,7 @@ Swap_Disable # - Auto size? - (( $SWAP_SIZE_TARGET == 1 )) && SWAP_SIZE_TARGET=$(( 2048 - $(free -m | mawk '/Mem:/ {print $2;exit}') )) + (( $SWAP_SIZE_TARGET == 1 )) && SWAP_SIZE_TARGET=$(( 2048 - $(free -m | mawk '/^Mem:/{print $2;exit}') )) # - Configure new swapfile? (( $SWAP_SIZE_TARGET > 0 )) && Swap_Enable diff --git a/dietpi/func/obtain_network_details b/dietpi/func/obtain_network_details index fd7f65a427..a742feca97 100644 --- a/dietpi/func/obtain_network_details +++ b/dietpi/func/obtain_network_details @@ -12,15 +12,14 @@ # Info: # - Location: /{DietPi,boot}/dietpi/func/obtain_network_details # - Attempts to find the 1st available index numbers for eth[0-9] and wlan[0-9] devices - # - Obtains the active network adapter (eth, then wlan). - # - Saves the above data to $FP_NETFILE for use system-wide - # - # line1: eth index - # line2: wlan index - # line3: Active adapter name (eg: eth0) - # line4: Active IP address - # line5: ETH_IP= - # line6: WLAN_IP= + # - Obtains the active network interface (eth, then wlan). + # - Saves the above data to $FP_NETFILE for system-wide use: + # line1: eth index + # line2: wlan index + # line3: Active interface name (eg: eth0) + # line4: Active IP address + # line5: ETH_IP= + # line6: WLAN_IP= #//////////////////////////////////// # Exit, if already running @@ -29,12 +28,11 @@ #///////////////////////////////////////////////////////////////////////////////////// # Global #///////////////////////////////////////////////////////////////////////////////////// - FP_NETFILE='/DietPi/dietpi/.network' ETH_INDEX='' WLAN_INDEX='' - ACTIVE_DEVICE='' + ACTIVE_IFACE='' ACTIVE_IP='' ETH_IP='' WLAN_IP='' @@ -42,68 +40,64 @@ Scan(){ # ETH - local eth_dev eth_index eth_out eth_ip + local eth_iface eth_index eth_out eth_ip for i in /sys/class/net/eth* do # Check if any eth dev exists [[ -e $i ]] || break - # Get dev name and index, assign not yet if lower index found - eth_dev=${i#*net/} - eth_index=${eth_dev#eth} + # Get interface name and index, assign if no lower index was assigned yet + eth_iface=${i#*net/} + eth_index=${eth_iface#eth} [[ $ETH_INDEX ]] || ETH_INDEX=$eth_index - # Get and check IP, assign not yet if lower index IP found - eth_out=$(ip a s $eth_dev 2>/dev/null) || continue - # - Detect IPv4 and, if no available, IPv6 - [[ $eth_out =~ [[:blank:]]inet6?[[:blank:]] ]] || continue - eth_ip=${eth_out#* inet* } - eth_ip=${eth_ip%%/*} + # Get and check IP, assign if no lower index IP was assigned yet + eth_out=$(ip -br a s $eth_iface 2> /dev/null) || continue + eth_out=${eth_out%%/*} # Remove trailing white space and net mask, if IP assigned + eth_ip=${eth_out##*[[:blank:]]} # Remove everything until IP, if assigned, else will empty string due to trailing white space [[ $eth_ip ]] || continue [[ $ETH_IP ]] || { ETH_IP=$eth_ip; ETH_INDEX=$eth_index; } # Check connection state - [[ $eth_out =~ [[:blank:]]UP[[:blank:]] ]] || continue + [[ $eth_out == *[[:blank:]]UP[[:blank:]]* ]] || continue # Assign active dev info ETH_INDEX=$eth_index ETH_IP=$eth_ip - ACTIVE_DEVICE=$eth_dev + ACTIVE_IFACE=$eth_iface ACTIVE_IP=$ETH_IP break done # WLAN - local wlan_dev wlan_index wlan_out wlan_ip + local wlan_iface wlan_index wlan_out wlan_ip for i in /sys/class/net/wlan* do # Check if any wlan dev exists [[ -e $i ]] || break - # Get dev name and index, assign not yet if lower index found - wlan_dev=${i#*net/} - wlan_index=${wlan_dev#wlan} + # Get interface name and index, assign if no lower index was assigned yet + wlan_iface=${i#*net/} + wlan_index=${wlan_iface#wlan} [[ $WLAN_INDEX ]] || WLAN_INDEX=$wlan_index - # Get and check IP, assign not yet if lower index IP found - wlan_out=$(ip a s $wlan_dev 2>/dev/null) || continue - # - Detect IPv4 and, if no available, IPv6 - [[ $wlan_out =~ [[:blank:]]inet6?[[:blank:]] ]] || continue - wlan_ip=${wlan_out#* inet* } - wlan_ip=${wlan_ip%%/*} + # Get and check IP, assign if no lower index IP was assigned yet + wlan_out=$(ip -br a s $wlan_iface 2> /dev/null) || continue + wlan_out=${wlan_out%%/*} # Remove trailing white space and net mask, if IP assigned + wlan_ip=${wlan_out##*[[:blank:]]} # Remove everything until IP, if assigned, else will empty string due to trailing white space [[ $wlan_ip ]] || continue [[ $WLAN_IP ]] || { WLAN_IP=$wlan_ip; WLAN_INDEX=$wlan_index; } # Check connection state - [[ $wlan_out =~ [[:blank:]]UP[[:blank:]] ]] || continue + [[ $wlan_out == *[[:blank:]]UP[[:blank:]]* ]] || continue - # Assign active dev info if none (eth) assigned yet + # Assign active dev info if none (eth) was assigned yet WLAN_INDEX=$wlan_index WLAN_IP=$wlan_ip - [[ $ACTIVE_DEVICE ]] || { ACTIVE_DEVICE=$wlan_dev; ACTIVE_IP=$WLAN_IP; } + [[ $ACTIVE_IFACE ]] || { ACTIVE_IFACE=$wlan_iface; ACTIVE_IP=$WLAN_IP; } break done @@ -115,21 +109,42 @@ #///////////////////////////////////////////////////////////////////////////////////// Scan #----------------------------------------------------------------------------------- + # Active interface fallback due to possible "UNKNOWN" connection state and to always have an interface assigned if any present + if [[ ! $ACTIVE_IFACE ]]; then + + if [[ $ETH_IP ]]; then + + ACTIVE_IFACE="eth$ETH_INDEX" + ACTIVE_IP=$ETH_IP + + elif [[ $WLAN_IP ]]; then + + ACTIVE_IFACE="wlan$WLAN_INDEX" + ACTIVE_IP=$WLAN_IP + + elif [[ $ETH_INDEX ]]; then + + ACTIVE_IFACE="eth$ETH_INDEX" + + elif [[ $WLAN_INDEX ]]; then + + ACTIVE_IFACE="wlan$WLAN_INDEX" + + fi + + fi + #----------------------------------------------------------------------------------- # Write to file - cat << _EOF_ > $FP_NETFILE -${ETH_INDEX:-0} + echo "${ETH_INDEX:-0} ${WLAN_INDEX:-0} -${ACTIVE_DEVICE:-NONE} +${ACTIVE_IFACE:-NONE} ${ACTIVE_IP:-Use dietpi-config to setup a connection} ETH_IP=$ETH_IP -WLAN_IP=$WLAN_IP -_EOF_ +WLAN_IP=$WLAN_IP" > $FP_NETFILE # Assure that non-root user can write file (( $UID )) || chmod 666 $FP_NETFILE - #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- - } diff --git a/dietpi/func/run_ntpd b/dietpi/func/run_ntpd index 48c6dc3bae..9c69325ca3 100644 --- a/dietpi/func/run_ntpd +++ b/dietpi/func/run_ntpd @@ -52,7 +52,7 @@ do # NB: Following will always report "Synced", once systemd has completed it once - if systemctl status systemd-timesyncd | grep -qi '^[[:blank:]]*status: "synchronized to time server'; then + if systemctl -n 0 status systemd-timesyncd | grep -qiE '^[[:blank:]]*status: "(synchronized|initial synchronization) to time server'; then G_DIETPI-NOTIFY 0 'NTPD: systemd-timesyncd synced' (( $NTP_UPDATE_MODE < 4 )) && systemctl stop systemd-timesyncd diff --git a/dietpi/misc/dietpi-justboom b/dietpi/misc/dietpi-justboom index a0a4b84062..17371e36b0 100644 --- a/dietpi/misc/dietpi-justboom +++ b/dietpi/misc/dietpi-justboom @@ -302,7 +302,7 @@ Please select a soundcard via 'dietpi-config' or install ALSA, or ideally an aud if [[ $G_WHIP_RETURNED_VALUE == 'ALSA Output Info' ]]; then G_DIETPI-NOTIFY 3 DietPi-JustBoom "ALSA Output Info" - local stream_result=$( /DietPi/dietpi/.install_stage Restart_DietPi_Update - # - As first run dietpi-update is executed from old dietpi-software, we need to reboot to load new first run setup scripts. + # As first run dietpi-update is executed from old dietpi-software, we need to reboot to load new first run setup scripts. else echo 0 > /DietPi/dietpi/.install_stage @@ -109,14 +107,16 @@ # Pre-v6.25: Apply target Git owner/branch now, to prevent downloads from non-matching branch, e.g. on software reinstalls if (( $G_DIETPI_VERSION_SUB < 25 )); then - G_GITOWNER=$(grep -m1 '^[[:blank:]]*DEV_GITOWNER=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + G_GITOWNER=$(sed -n '/^[[:blank:]]*DEV_GITOWNER=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) G_GITOWNER=${G_GITOWNER:-MichaIng} - G_GITBRANCH=$(grep -m1 '^[[:blank:]]*DEV_GITBRANCH=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + G_GITBRANCH=$(sed -n '/^[[:blank:]]*DEV_GITBRANCH=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) G_GITBRANCH=${G_GITBRANCH:-master} - G_VERSIONDB_SAVE fi + # Pre-v6.27: Save version info for sub scripts, which will be done within dietpi-update script from v6.27 on + (( $G_DIETPI_VERSION_SUB < 27 )) && G_VERSIONDB_SAVE + #///////////////////////////////////////////////////////////////////////////////////// # Incremental patch system Incremental_Patch_System(){ @@ -124,8 +124,8 @@ if (( $G_DIETPI_VERSION_SUB == -1 )); then #------------------------------------------------------------------------------- - #Asus TB G_HW_MODEL change - if [[ -f '/etc/.dietpi_hw_model_identifier' && $(sed -n 1p /etc/.dietpi_hw_model_identifier) == 100 ]]; then + # Asus TB G_HW_MODEL change + if [[ -f '/etc/.dietpi_hw_model_identifier' && $(mawk 'NR==1' /etc/.dietpi_hw_model_identifier) == 100 ]]; then G_HW_MODEL=52 echo $G_HW_MODEL > /etc/.dietpi_hw_model_identifier @@ -133,16 +133,16 @@ fi #------------------------------------------------------------------------------- - #bash.bashrc removal of any outstanding dietpi entries (moved to globals). Just incase I missed any manually during PREP... + # bash.bashrc removal of any outstanding dietpi entries (moved to globals). Just incase I missed any manually during PREP... sed -i '/#DietPi_Entries/Q' /etc/bash.bashrc sed -i '/#Apply system locale/Q' /etc/bash.bashrc sed -i '/#DietPi Additions/Q' /etc/bash.bashrc #------------------------------------------------------------------------------- - #Fix doubled and renamed config files: https://github.com/MichaIng/DietPi/commit/68148cec6b49afc787deca638456e1c4689e1cab#diff-8370b86e635383d521462994afe04a2d + # Fix doubled and renamed config files: https://github.com/MichaIng/DietPi/commit/68148cec6b49afc787deca638456e1c4689e1cab#diff-8370b86e635383d521462994afe04a2d [[ -f '/etc/apt/apt.conf.d/99force-ipv' ]] && rm /etc/apt/apt.conf.d/99force-ipv [[ -f '/etc/sysctl.d/97-dietpi.conf' ]] && rm /etc/sysctl.d/97-dietpi.conf #------------------------------------------------------------------------------- - #Core_ENV update: https://github.com/MichaIng/DietPi/pull/1419 + # Core_ENV update: https://github.com/MichaIng/DietPi/pull/1419 # - consoleblank disable x86_64 if [[ -f '/etc/default/grub' ]]; then @@ -153,15 +153,15 @@ fi #------------------------------------------------------------------------------- - #Remove -dev keyring + # Remove -dev keyring apt-mark auto debian-keyring #------------------------------------------------------------------------------- elif (( $G_DIETPI_VERSION_SUB == 0 )); then #------------------------------------------------------------------------------- - #Reinstalls: - # Kodi: https://github.com/MichaIng/DietPi/issues/1428 + # Reinstalls: + # Kodi: https://github.com/MichaIng/DietPi/issues/1428 # Fail2Ban: https://github.com/MichaIng/DietPi/issues/1431 # Tonido: https://github.com/MichaIng/DietPi/issues/1432 (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 31 73 134 @@ -170,13 +170,11 @@ elif (( $G_DIETPI_VERSION_SUB == 1 )); then #------------------------------------------------------------------------------- - #locale rework/reset: https://github.com/MichaIng/DietPi/issues/1430#issuecomment-364763302 + # locale rework/reset: https://github.com/MichaIng/DietPi/issues/1430#issuecomment-364763302 [[ -f '/etc/environment' ]] && mv /etc/environment /mnt/dietpi_userdata/environment.bak > /etc/environment - /DietPi/dietpi/func/dietpi-set_software locale en_GB.UTF-8 - - G_WHIP_MSG 'Notice (locale):\n\nTo resolve broken locales, they have been reset to "en_GB.UTF-8".\n\nIf you had a different locale configured on this system, please use "dietpi-config" at a later date to re-configure.\n\nIn relation to that, DietPi does not use "/etc/environment" anymore, thus it is cleaned. In case you manually edited it, a backup was created: /mnt/dietpi_userdata/environment.bak' + G_WHIP_MSG '[ INFO ] Locales reset\n\nTo resolve broken locales, they have been reset to "en_GB.UTF-8".\n\nIf you had a different locale configured on this system, please use "dietpi-config" at a later date to re-configure.\n\nIn relation to that, DietPi does not use "/etc/environment" anymore, thus it is cleaned. In case you manually edited it, a backup was created: /mnt/dietpi_userdata/environment.bak' #------------------------------------------------------------------------------ # Removed control from DietPi-Services: https://github.com/MichaIng/DietPi/issues/1501 systemctl enable --now dnsmasq &> /dev/null @@ -188,11 +186,11 @@ # DietPi-Software removals: https://github.com/MichaIng/DietPi/issues/1491 if [[ -f /DietPi/dietpi/.installed ]]; then - sed -i '/^aSOFTWARE_INSTALL_STATE\[100\]=/c\aSOFTWARE_INSTALL_STATE\[100\]=0' /DietPi/dietpi/.installed # Grashopper (now pijuice) - sed -i '/^aSOFTWARE_INSTALL_STATE\[106\]=/c\aSOFTWARE_INSTALL_STATE\[106\]=0' /DietPi/dietpi/.installed # raspcontrol (now ntp) + sed -i '/^aSOFTWARE_INSTALL_STATE\[100\]=/c\aSOFTWARE_INSTALL_STATE\[100\]=0' /DietPi/dietpi/.installed # Grashopper (now PiJuice) + sed -i '/^aSOFTWARE_INSTALL_STATE\[106\]=/c\aSOFTWARE_INSTALL_STATE\[106\]=0' /DietPi/dietpi/.installed # Raspcontrol (now NTP) if grep -qi '^aSOFTWARE_INSTALL_STATE\[170\]=2' /DietPi/dietpi/.installed; then - sed -i '/^aSOFTWARE_INSTALL_STATE\[106\]=/c\aSOFTWARE_INSTALL_STATE\[106\]=2' /DietPi/dietpi/.installed # NTP (replaces raspcontrol) + sed -i '/^aSOFTWARE_INSTALL_STATE\[106\]=/c\aSOFTWARE_INSTALL_STATE\[106\]=2' /DietPi/dietpi/.installed # NTP (replaces Raspcontrol) sed -i '/^aSOFTWARE_INSTALL_STATE\[170\]=/c\aSOFTWARE_INSTALL_STATE\[170\]=0' /DietPi/dietpi/.installed # NTP (now 106) fi @@ -215,6 +213,7 @@ #------------------------------------------------------------------------------- # Switch from rc.local to own postboot script: https://github.com/MichaIng/DietPi/issues/1376 + systemctl enable dietpi-postboot if [[ -f '/etc/rc.local' ]]; then G_WHIP_MSG 'DietPi will not use "/etc/rc.local" for its own scripts anymore.\n\nHowever, in case you manually added something, we safe a backup to "/mnt/dietpi_userdata/rc.local.bak", from where you can copy & paste back to the cleaned "/etc/rc.local".\n\nIt will work as before.' @@ -237,37 +236,16 @@ exit 0 _EOF_ chmod +x /etc/rc.local - fi - - systemctl enable dietpi-postboot - - if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[168\]=2' /DietPi/dietpi/.installed; then - - [[ -d '/var/lib/dietpi/postboot.d' ]] || mkdir /var/lib/dietpi/postboot.d - cat << _EOF_ > /var/lib/dietpi/postboot.d/moode -#!/bin/bash -# moOde additions -SQLDB=/var/local/www/db/moode-sqlite3.db - -# set cpu govenor -RESULT=\$(sqlite3 \$SQLDB "select value from cfg_system where param='cpugov'") -echo "\$RESULT" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor - -/usr/bin/udisks-glue > /dev/null 2>&1 -/var/www/command/worker.php > /dev/null 2>&1 -_EOF_ - fi #------------------------------------------------------------------------------- G_DIETPI-NOTIFY 2 'Reducing getty count and resource usage' systemctl mask getty-static #------------------------------------------------------------------------------- # Meveric, update repo to use our EU mirror: https://github.com/MichaIng/DietPi/issues/1519#issuecomment-368234302 - sed -i 's@https://oph.mdrjr.net/meveric@http://fuzon.co.uk/meveric@' /etc/apt/sources.list.d/meveric* &> /dev/null + sed -Ei 's@https?://oph\.mdrjr\.net@http://fuzon.co.uk@' /etc/apt/sources.list.d/meveric* &> /dev/null #------------------------------------------------------------------------------- # Remove any existing apt recommends settings, before applying ours: https://github.com/MichaIng/DietPi/issues/1482#issuecomment-368031044 rm -f /etc/apt/apt.conf.d/*recommends* - G_ERROR_HANDLER_COMMAND='/etc/apt/apt.conf.d/99-dietpi-norecommends' cat << _EOF_ > $G_ERROR_HANDLER_COMMAND APT::Install-Recommends "false"; @@ -298,9 +276,9 @@ _EOF_ if [[ -f '/DietPi/dietpi/.dietpi-letsencrypt' ]]; then # Switch Minio to new certbot.service.d/ hook: - if grep -q '^aSOFTWARE_INSTALL_STATE\[158\]=2' /DietPi/dietpi/.installed; then + if [[ -f '/etc/systemd/system/certbot.service' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[158\]=2' /DietPi/dietpi/.installed; then - [[ -f '/etc/systemd/system/certbot.service' ]] && rm /etc/systemd/system/certbot.service + rm /etc/systemd/system/certbot.service fi # Overall settings and config renewal, skip DietPi-Services: @@ -312,7 +290,7 @@ _EOF_ G_AGI dirmngr #------------------------------------------------------------------------------- # Odroids FFmpeg decendency fix: https://github.com/MichaIng/DietPi/issues/1556#issuecomment-369463910 - if (( $G_HW_MODEL > 9 && $G_HW_MODEL < 15 )); then + if [[ $G_HW_MODEL == 1[0-5] ]]; then rm -f /etc/apt/preferences.d/meveric* cat << _EOF_ > /etc/apt/preferences.d/backports @@ -336,10 +314,10 @@ _EOF_ elif (( $G_DIETPI_VERSION_SUB == 3 )); then #------------------------------------------------------------------------------- - #Service updates: https://dietpi.com/phpbb/viewtopic.php?f=11&t=1148&p=11322#p11322 - $(command -v mkdir) -p /var/tmp/dietpi/logs + # Service updates: https://dietpi.com/phpbb/viewtopic.php?f=11&t=1148&p=11322#p11322 + mkdir -p /var/tmp/dietpi/logs #------------------------------------------------------------------------------- - #Fix microcode installation based on image creation CPU instead of image target CPU: https://github.com/MichaIng/DietPi/pull/1596 + # Fix microcode installation based on image creation CPU instead of image target CPU: https://github.com/MichaIng/DietPi/pull/1596 if (( $G_HW_ARCH == 10 )); then if grep -qi 'vendor_id.*intel' /proc/cpuinfo; then @@ -356,54 +334,51 @@ _EOF_ fi #------------------------------------------------------------------------------- - #Reinstalls + # Reinstalls # UrBackupServer (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 111 #------------------------------------------------------------------------------- - #Cron minutely support: https://github.com/MichaIng/DietPi/pull/1578 - mkdir -p /etc/cron.minutely + # Cron minutely support: https://github.com/MichaIng/DietPi/pull/1578 grep -q 'cron\.minutely' /etc/crontab || echo '#*/0 * * * * root cd / && run-parts --report /etc/cron.minutely' >> /etc/crontab #------------------------------------------------------------------------------- elif (( $G_DIETPI_VERSION_SUB == 4 )); then #------------------------------------------------------------------------------- - #Removal of dphys-swapfile, switch to our own swapfile control system: https://github.com/MichaIng/DietPi/issues/1602 + # Removal of dphys-swapfile, switch to our own swapfile control system: https://github.com/MichaIng/DietPi/issues/1602 sed -i '/[[:space:]]dphys-swapfile[[:space:]]/d' /etc/fstab - local swap_size=0 - local swap_location='/var/swap' + local swap_size swap_location if [[ -f '/etc/dphys-swapfile' ]]; then - swap_size=$(grep -m1 '^[[:blank:]]*CONF_SWAPSIZE=' /etc/dphys-swapfile | sed 's/^[^=]*=//') - swap_location=$(grep -m1 '^[[:blank:]]*CONF_SWAPFILE=' /etc/dphys-swapfile | sed 's/^[^=]*=//') + swap_size=$(sed -n '/^[[:blank:]]*CONF_SWAPSIZE=/{s/^[^=]*=//p;q}' /etc/dphys-swapfile) + swap_location=$(sed -n '/^[[:blank:]]*CONF_SWAPFILE=/{s/^[^=]*=//p;q}' /etc/dphys-swapfile) fi - sed -i "/^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=/c\AUTO_SETUP_SWAPFILE_SIZE=$swap_size" /DietPi/dietpi.txt - sed -i "/^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=/c\AUTO_SETUP_SWAPFILE_LOCATION=$swap_location" /DietPi/dietpi.txt + G_CONFIG_INJECT 'AUTO_SETUP_SWAPFILE_SIZE=' "AUTO_SETUP_SWAPFILE_SIZE=${swap_size:-1}" /DietPi/dietpi.txt + G_CONFIG_INJECT 'AUTO_SETUP_SWAPFILE_LOCATION=' "AUTO_SETUP_SWAPFILE_LOCATION=${swap_location:-/var/swap}" /DietPi/dietpi.txt - #Re-Apply swap to set /tmp tmpfs size: https://github.com/MichaIng/DietPi/issues/1027#issuecomment-369435049 + # Re-Apply swap to set /tmp tmpfs size: https://github.com/MichaIng/DietPi/issues/1027#issuecomment-369435049 # + Force auto swapfile size https://github.com/MichaIng/DietPi/issues/1593#issuecomment-371516418 /DietPi/dietpi/func/dietpi-set_swapfile 1 G_AGP dphys-swapfile #------------------------------------------------------------------------------- - #Reinstalls + # Reinstalls # v6.20 Shairport-sync: https://github.com/MichaIng/DietPi/issues/1620#issuecomment-373086888 # v6.23 Squeezebox server: - # v6.20 AmiBerry 2.18: https://github.com/MichaIng/DietPi/issues/1410#issuecomment-374060452 + # v6.20 Amiberry 2.18: https://github.com/MichaIng/DietPi/issues/1410#issuecomment-374060452 # Mopidy: https://github.com/MichaIng/DietPi/issues/1625 # v6.17 MPD: https://github.com/MichaIng/DietPi/issues/1614 if (( $G_DIETPI_INSTALL_STAGE == 2 )); then killall -qw squeezeboxserver - [[ -f /var/lib/dietpi/dietpi-software/services/squeezeboxserver.service ]] && rm /var/lib/dietpi/dietpi-software/services/squeezeboxserver.service - + [[ -f '/var/lib/dietpi/dietpi-software/services/squeezeboxserver.service' ]] && rm /var/lib/dietpi/dietpi-software/services/squeezeboxserver.service /DietPi/dietpi/dietpi-software reinstall 118 fi #------------------------------------------------------------------------------- - #RPi 3 B+: Set correct disabled clocks for B+ (scraped by dietpi-config > overclocking) + # RPi 3 B+: Set correct disabled clocks for B+ (scraped by dietpi-config > overclocking) if grep -qi 'RPi 3 Model B+' /DietPi/dietpi/.hw_model; then sed -i '/arm_freq=/c\#arm_freq=1400' /DietPi/config.txt @@ -411,21 +386,21 @@ _EOF_ fi #------------------------------------------------------------------------------- - #sudoers and sysctl adjustments moved to *.d/ files: https://github.com/MichaIng/DietPi/pull/1635 + # sudoers and sysctl adjustments moved to *.d/ files: https://github.com/MichaIng/DietPi/pull/1635 echo 'dietpi ALL=NOPASSWD: ALL' > /etc/sudoers.d/dietpi sed -i '/dietpi/d' /etc/sudoers - #Our config must not start with '99-' to assure priority higher than '99-sysctl.conf' + # Our config must not start with '99-' to assure priority higher than '99-sysctl.conf' # - New config is installed automatically via v6.9 update system. [[ -f '/etc/sysctl.d/99-dietpi.conf' ]] && rm /etc/sysctl.d/99-dietpi.conf #------------------------------------------------------------------------------- - # - RPi resolve gettext error: https://github.com/MichaIng/DietPi/issues/1631#issuecomment-373965406 + # RPi resolve gettext error: https://github.com/MichaIng/DietPi/issues/1631#issuecomment-373965406 [[ -f '/etc/profile.d/wifi-country.sh' ]] && rm /etc/profile.d/wifi-country.sh #------------------------------------------------------------------------------- elif (( $G_DIETPI_VERSION_SUB == 5 )); then #------------------------------------------------------------------------------- - #RPi APT mirror fix: https://github.com/MichaIng/DietPi/issues/1659 + # RPi APT mirror fix: https://github.com/MichaIng/DietPi/issues/1659 if (( $G_HW_MODEL < 10 )); then G_AGDUG @@ -434,18 +409,18 @@ _EOF_ fi #------------------------------------------------------------------------------- - #Remove minutely running "make_nas_processes_faster" cron job, present on images with preinstalled OMV: https://github.com/MichaIng/DietPi/issues/1654 + # Remove minutely running "make_nas_processes_faster" cron job, present on images with preinstalled OMV: https://github.com/MichaIng/DietPi/issues/1654 [[ -f '/etc/cron.d/make_nas_processes_faster' ]] && rm /etc/cron.d/make_nas_processes_faster #------------------------------------------------------------------------------- - #Add Dropbear ecdsa and dss host keys, if missing: https://github.com/MichaIng/DietPi/issues/1670 - if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[104\]=2' /DietPi/dietpi/.installed; then + # Add Dropbear ecdsa and dss host keys, if missing: https://github.com/MichaIng/DietPi/issues/1670 + if command -v dropbearkey &> /dev/null; then - [[ -f '/etc/dropbear/dropbear_ecdsa_host_key' ]] || dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key &> /dev/null - [[ -f '/etc/dropbear/dropbear_dss_host_key' ]] || dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key &> /dev/null + [[ -f '/etc/dropbear/dropbear_ecdsa_host_key' ]] || dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key + [[ -f '/etc/dropbear/dropbear_dss_host_key' ]] || dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key fi #------------------------------------------------------------------------------- - #Reinstall firmware-misc-nonfree by default (ralink): https://github.com/MichaIng/DietPi/issues/1675 + # Reinstall firmware-misc-nonfree by default (Ralink): https://github.com/MichaIng/DietPi/issues/1675 if dpkg-query -s wpasupplicant &> /dev/null; then G_AGI firmware-misc-nonfree @@ -460,10 +435,10 @@ _EOF_ elif (( $G_DIETPI_VERSION_SUB == 6 )); then #------------------------------------------------------------------------------- - #Add nodered (if installed) to gpio group: https://github.com/MichaIng/DietPi/issues/1687 - getent passwd nodered &> /dev/null && usermod -a -G gpio nodered + # Add nodered (if installed) to gpio group: https://github.com/MichaIng/DietPi/issues/1687 + getent passwd nodered &> /dev/null && usermod -aG gpio nodered #------------------------------------------------------------------------------- - #Deluge systemd service update: https://github.com/MichaIng/DietPi/issues/1658 + # Deluge systemd service update: https://github.com/MichaIng/DietPi/issues/1658 # + Service fix for in v6.6 https://github.com/MichaIng/DietPi/issues/1689#issuecomment-379024795 # => Fixed with reinstall on v6.21 => v6.22 [[ -f '/var/lib/dietpi/dietpi-software/services/deluge.service' ]] && rm /var/lib/dietpi/dietpi-software/services/deluge.service @@ -472,20 +447,20 @@ _EOF_ elif (( $G_DIETPI_VERSION_SUB == 7 )); then #------------------------------------------------------------------------------- - #Uninstalls: + # Uninstalls: # Removal of fbset on new installs: https://github.com/MichaIng/DietPi/issues/1716 (( $G_DIETPI_INSTALL_STAGE == 0 )) && apt-mark auto fbset #------------------------------------------------------------------------------- - #Reinstalls: + # Reinstalls: # XRDP: https://github.com/MichaIng/DietPi/issues/1727#issuecomment-383858979 - # v6.20 AmiBerry 2.19: https://github.com/MichaIng/DietPi/issues/1707 + # v6.20 Amiberry 2.19: https://github.com/MichaIng/DietPi/issues/1707 # Pi-SPC (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 29 166 #------------------------------------------------------------------------------- - #Pi-hole: Enable FTLDNS support by removing pihole-FTL from DietPi control: https://github.com/MichaIng/DietPi/pull/1714 + # Pi-hole: Enable FTLDNS support by removing pihole-FTL from DietPi control: https://github.com/MichaIng/DietPi/pull/1714 systemctl enable pihole-FTL 2> /dev/null #------------------------------------------------------------------------------- - #Remove allo Piano firmware, if not chosen as soundcard, to allow installation on demand: https://github.com/MichaIng/DietPi/issues/1656 + # Remove Allo Piano firmware, if not chosen as soundcard, to allow installation on demand: https://github.com/MichaIng/DietPi/issues/1656 if { (( $G_HW_MODEL < 10 )) && ! grep -q 'allo-piano-dac' /DietPi/config.txt; } || { (( $G_HW_MODEL == 70 )) && ! grep -q 'allo-piano-dac' /etc/modules; }; then @@ -493,56 +468,49 @@ _EOF_ fi #------------------------------------------------------------------------------- - #RPi UART: https://github.com/MichaIng/DietPi/issues/1759 + # RPi UART: https://github.com/MichaIng/DietPi/issues/1759 if [[ -f '/DietPi/config.txt' ]]; then - local serial_state=$(grep -m1 '^[[:blank:]]*CONFIG_SERIAL_CONSOLE_ENABLE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') - G_CONFIG_INJECT 'enable_uart=' "enable_uart=$serial_state" /DietPi/config.txt + local serial_state=$(sed -n '/^[[:blank:]]*CONFIG_SERIAL_CONSOLE_ENABLE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + G_CONFIG_INJECT 'enable_uart=' "enable_uart=${serial_state:-0}" /DietPi/config.txt fi #------------------------------------------------------------------------------- - #pre-create postboot dir for all systems + # Pre-create postboot dir for all systems mkdir -p /var/lib/dietpi/postboot.d #------------------------------------------------------------------------------- elif (( $G_DIETPI_VERSION_SUB == 8 )); then #------------------------------------------------------------------------------- - #NTP removal, switch to systemd: + # NTP removal, switch to systemd: killall -w /DietPi/dietpi/func/run_ntpd &> /dev/null killall -w ntpd &> /dev/null G_AGP ntp sed -i '/^aSOFTWARE_INSTALL_STATE\[106\]=/c\aSOFTWARE_INSTALL_STATE\[106\]=0' /DietPi/dietpi/.installed &> /dev/null - /DietPi/dietpi/func/dietpi-set_software ntpd-mode $(grep -m1 '^[[:blank:]]*CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') + /DietPi/dietpi/func/dietpi-set_software ntpd-mode $(sed -n '/^[[:blank:]]*CONFIG_NTP_MODE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) systemctl daemon-reload /DietPi/dietpi/func/run_ntpd #------------------------------------------------------------------------------- - #Move DietPi globals and login scripts into new /etc/bashrc.d location to load on all interactive shells: + # Move DietPi globals and login scripts into new /etc/bashrc.d location to load on all interactive shells: mkdir -p /etc/bashrc.d # => v6.22 #G_CONFIG_INJECT '.*/etc/bashrc\.d/.*' 'for i in /etc/bashrc.d/*.sh; do [ -r "$i" ] && . $i; done' /etc/bash.bashrc - for i in /{root,home/*}/.bashrc; do [[ -f $i ]] && sed -i '/\/DietPi/d' $i; done #should already be removed, failsafe start clean + for i in /{root,home/*}/.bashrc; do [[ -f $i ]] && sed -i '/\/DietPi/d' $i; done # should already be removed, failsafe start clean rm -f /etc/profile.d/99-dietpi* # - Enable bash-completion for non-login shells: # - NB: It is called twice on login shells then, but breaks directly if called already once. [[ -f '/etc/profile.d/bash_completion.sh' ]] && ln -sf /etc/profile.d/bash_completion.sh /etc/bashrc.d/dietpi-bash_completion.sh #------------------------------------------------------------------------------- - #Sparky unmute fix (re: @sudeep) + # Sparky unmute fix (re: @sudeep) # v2: https://github.com/MichaIng/DietPi/pull/1779 - if (( $G_HW_MODEL == 70 )) && grep -qi 'CONFIG_SOUNDCARD=usb-dac' /DietPi/dietpi.txt; then - - for x in $(amixer -c $SOUNDCARD_TARGET_CARD controls | grep layback) - do + if (( $G_HW_MODEL == 70 )) && grep -qi '^[[:blank:]]*CONFIG_SOUNDCARD=usb-dac' /DietPi/dietpi.txt; then - amixer -c $SOUNDCARD_TARGET_CARD cset "$x" 100% - - done - alsactl store - systemctl restart alsa-restore + /DietPi/dietpi/func/dietpi-set_hardware soundcard $(sed -n '/^[[:blank:]]*CONFIG_SOUNDCARD=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) fi #------------------------------------------------------------------------------- - #Reinstalls + # Reinstalls # RPi (apply to all) LXDE missing icons under pcmanfm reinstall: https://github.com/MichaIng/DietPi/issues/1558#issuecomment-390328173 # v6.12 AirSonic # v6.23 SubSonic @@ -552,27 +520,27 @@ _EOF_ # v6.19 Xserver: https://github.com/MichaIng/DietPi/issues/1823 (( $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 + # 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 #------------------------------------------------------------------------------- - #Re-Run set uid for sudo: https://github.com/MichaIng/DietPi/issues/794#issuecomment-392335392 + # Re-run set uid for sudo: https://github.com/MichaIng/DietPi/issues/794#issuecomment-392335392 chmod 4755 $(command -v sudo) #------------------------------------------------------------------------------- - #Removal due to changed file locations: https://github.com/MichaIng/DietPi/pull/1802 + # Removal due to changed file locations: https://github.com/MichaIng/DietPi/pull/1802 rm -f /{DietPi,boot}/dietpi/func/dietpi-set_core_environment rm -f /{DietPi,boot}/dietpi/conf/cron.daily_dietpi rm -f /{DietPi,boot}/dietpi/conf/cron.hourly_dietpi - [[ -f /var/lib/dietpi/fs_partition_resize.sh ]] && rm /var/lib/dietpi/fs_partition_resize.sh - [[ -f /var/lib/dietpi/dietpi-software/services/kill-ssh-user-sessions-before-network.sh ]] && rm /var/lib/dietpi/dietpi-software/services/kill-ssh-user-sessions-before-network.sh + [[ -f '/var/lib/dietpi/fs_partition_resize.sh' ]] && rm /var/lib/dietpi/fs_partition_resize.sh + [[ -f '/var/lib/dietpi/dietpi-software/services/kill-ssh-user-sessions-before-network.sh' ]] && rm /var/lib/dietpi/dietpi-software/services/kill-ssh-user-sessions-before-network.sh #------------------------------------------------------------------------------- - #Offer to change global and unix user passwords to make users aware of the existance or "dietpi" and how the dietpi.txt password is used. - # If already installed only, else, dietpi-software will handle this on first run, after the update + # Offer to change global and unix user passwords to make users aware of the existance or "dietpi" and how the dietpi.txt password is used. + # - If already installed only, else, dietpi-software will handle this on first run, after the update (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/func/dietpi-set_software passwords elif (( $G_DIETPI_VERSION_SUB == 9 )); then #------------------------------------------------------------------------------- - #Switch to IP commands, removal of net-tools: https://github.com/MichaIng/DietPi/pull/1839 + # Switch to IP commands, removal of net-tools: https://github.com/MichaIng/DietPi/pull/1839 # - Only apply, if HomeAssistant is not installed, as it depends on net-tools: https://github.com/MichaIng/DietPi/issues/1911 if ! [[ -f '/DietPi/dietpi/.installed' ]] || ! grep -q '^aSOFTWARE_INSTALL_STATE\[157\]=2' /DietPi/dietpi/.installed; then @@ -581,11 +549,11 @@ _EOF_ fi #------------------------------------------------------------------------------- - #Reinstalls + # Reinstalls # v6.19 GMrender: https://dietpi.com/phpbb/viewtopic.php?f=11&t=3900&p=12985#p12985 # v6.19 Xserver (ASUSTB GPU) #------------------------------------------------------------------------------- - #DietPi-Backup rewrite, no longer supports older backups: https://github.com/MichaIng/DietPi/issues/1851 + # DietPi-Backup rewrite, no longer supports older backups: https://github.com/MichaIng/DietPi/issues/1851 if [[ -f '/DietPi/dietpi/.dietpi-backup_settings' ]]; then G_WHIP_MSG 'DietPi-Backup has been re-written to improve support for custom include/exclude options. It also removes the option for userdata backups, as this is now included by default.\n\nNB: Existing backups are no longer supported and cannot be restored. We highly recommend removing the older backup (eg: "rm -R /mnt/dietpi-backup"), then, create a new backup.' @@ -604,22 +572,22 @@ _EOF_ fi #------------------------------------------------------------------------------- - #Remove config.txt for non-RPi devices: https://github.com/MichaIng/DietPi/pull/1863 + # Remove config.txt for non-RPi devices: https://github.com/MichaIng/DietPi/pull/1863 (( $G_HW_MODEL > 9 )) && rm -f /{DietPi,boot}/config.txt #------------------------------------------------------------------------------- - #Removal of NTP from dietpi-software + # Removal of NTP from dietpi-software sed -i '/^aSOFTWARE_INSTALL_STATE\[106\]=/c\aSOFTWARE_INSTALL_STATE\[106\]=0' /DietPi/dietpi/.installed &> /dev/null - # Cleared for roon extension manager addition + # - Cleared for roon extension manager addition sed -i '/^aSOFTWARE_INSTALL_STATE\[86\]=/c\aSOFTWARE_INSTALL_STATE\[86\]=0' /DietPi/dietpi/.installed &> /dev/null - # Cleared for ubooquity addition + # - Cleared for ubooquity addition sed -i '/^aSOFTWARE_INSTALL_STATE\[80\]=/c\aSOFTWARE_INSTALL_STATE\[80\]=0' /DietPi/dietpi/.installed &> /dev/null - # Moode cleared + # - Moode cleared sed -i '/^aSOFTWARE_INSTALL_STATE\[168\]=/c\aSOFTWARE_INSTALL_STATE\[168\]=0' /DietPi/dietpi/.installed &> /dev/null #------------------------------------------------------------------------------- - #Unused and replaced with dietpi-fs_partition_resize.service - rm /etc/systemd/system/dietpi-fs_expand.service &> /dev/null + # Unused and replaced with dietpi-fs_partition_resize.service + [[ -f '/etc/systemd/system/dietpi-fs_expand.service' ]] && rm /etc/systemd/system/dietpi-fs_expand.service #------------------------------------------------------------------------------- - #ASUS TB fonts broken as /usr/share/font removed but pkg's still exist, need to also do a fresh PREP on this image + # ASUS TB fonts broken as /usr/share/font removed but pkg's still exist, need to also do a fresh PREP on this image if (( $G_HW_MODEL == 52 )); then if (( $G_DIETPI_INSTALL_STAGE == 0 )); then @@ -644,16 +612,15 @@ _EOF_ elif (( $G_DIETPI_VERSION_SUB == 11 )); then #------------------------------------------------------------------------------- - #Software removals: + # Software removals: # JRiver: https://github.com/MichaIng/DietPi/issues/1080#issuecomment-403489246 sed -i '/^aSOFTWARE_INSTALL_STATE\[148\]=/c\aSOFTWARE_INSTALL_STATE\[148\]=0' /DietPi/dietpi/.installed &> /dev/null #------------------------------------------------------------------------------- - #ASUS TB WiFi: https://github.com/MichaIng/DietPi/issues/1760 + # ASUS TB WiFi: https://github.com/MichaIng/DietPi/issues/1760 (( $G_HW_MODEL == 52 )) && G_CONFIG_INJECT '8723bs' '8723bs' /etc/modules #------------------------------------------------------------------------------- - #Software reinstalls: - # https://github.com/MichaIng/DietPi/issues/1877#issuecomment-403421942 - # Items which run as own user: + # Software reinstalls: https://github.com/MichaIng/DietPi/issues/1877#issuecomment-403421942 + # - Items which run as own user: # YMPD # v6.17 MPD # minidlna @@ -667,10 +634,10 @@ _EOF_ # v6.15 PlexPy # Koel # v6.25 O!MPD: https://github.com/MichaIng/DietPi/issues/1934#issuecomment-406059462 - # - NO REINSTALL: due to many changes, or, too much risk for existing user settings, fresh installs only - # CubeRite - # qBitTorrent - # tonido + # - NO REINSTALL: due to many changes, or, too much risk for existing user settings, fresh installs only + # CubeRite + # qBitTorrent + # tonido if (( $G_DIETPI_INSTALL_STAGE == 2 )); then if [[ -d '/root/.config/NzbDrone' ]]; then @@ -699,14 +666,14 @@ _EOF_ fi #------------------------------------------------------------------------------- - #Increase /var/log max size to 50MB, if lower than 50MB: https://github.com/pi-hole/pi-hole/issues/2270#issuecomment-405109135 + # Increase /var/log max size to 50MB, if lower than 50MB: https://github.com/pi-hole/pi-hole/issues/2270#issuecomment-405109135 if df | grep '^tmpfs.*/var/log' &> /dev/null; then local var_log_size_new=50 - if (( $(grep -m1 '^[[:blank:]]*AUTO_SETUP_RAMLOG_MAXSIZE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') < $var_log_size_new )); then + if (( $(sed -n '/^[[:blank:]]*AUTO_SETUP_RAMLOG_MAXSIZE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) < $var_log_size_new )); then - sed -i "/^[[:blank:]]*AUTO_SETUP_RAMLOG_MAXSIZE=/c\AUTO_SETUP_RAMLOG_MAXSIZE=$var_log_size_new" /DietPi/dietpi.txt + G_CONFIG_INJECT 'AUTO_SETUP_RAMLOG_MAXSIZE=' "AUTO_SETUP_RAMLOG_MAXSIZE=$var_log_size_new" /DietPi/dietpi.txt fi @@ -715,26 +682,26 @@ _EOF_ fi #------------------------------------------------------------------------------- - #Fix Xserver uninstall issus by not purging dependencies, but leaving them for autoremove: https://github.com/MichaIng/DietPi/pull/1930/files + # Fix Xserver uninstall issus by not purging dependencies, but leaving them for autoremove: https://github.com/MichaIng/DietPi/pull/1930/files local dpkg_list=$(dpkg --get-selections) grep -q '^xinit[[:space:]]' <<< "$dpkg_list" && apt-mark auto xauth x11-common grep -q '^mesa-utils-extra[[:space:]]' <<< "$dpkg_list" && apt-mark auto libgles2-mesa #------------------------------------------------------------------------------- - #Reinstall net-tools as dependency, if HomeAssistant is installed. Thanks to @lupa18 for reporting this: https://github.com/MichaIng/DietPi/issues/1911 + # Reinstall net-tools as dependency, if HomeAssistant is installed. Thanks to @lupa18 for reporting this: https://github.com/MichaIng/DietPi/issues/1911 if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[157\]=2' /DietPi/dietpi/.installed; then G_AGI net-tools fi #------------------------------------------------------------------------------- - #Removal of CurlFTPFS from dietpi-software + # Removal of CurlFTPFS from dietpi-software sed -i '/^aSOFTWARE_INSTALL_STATE\[2\]=/c\aSOFTWARE_INSTALL_STATE\[2\]=0' /DietPi/dietpi/.installed &> /dev/null #------------------------------------------------------------------------------- - #/var/lib/dietpi/dietpi-ramlog/storage moved to /var/tmp/dietpi/logs/dietpi-ramlog_store https://github.com/MichaIng/DietPi/pull/1919 - #automatically generated during ramlog, remove old location only + # /var/lib/dietpi/dietpi-ramlog/storage moved to /var/tmp/dietpi/logs/dietpi-ramlog_store https://github.com/MichaIng/DietPi/pull/1919 + # automatically generated during ramlog, remove old location only [[ -d /var/lib/dietpi/dietpi-ramlog/storage ]] && rm -R /var/lib/dietpi/dietpi-ramlog/storage #------------------------------------------------------------------------------- - #Reinstall "netbase", in case of installed NFS client and/or server, to reenable NFSv3 support: https://github.com/MichaIng/DietPi/issues/1898 + # Reinstall "netbase", in case of installed NFS client and/or server, to reenable NFSv3 support: https://github.com/MichaIng/DietPi/issues/1898 if (( $G_DIETPI_INSTALL_STAGE == 2 )); then if grep -q '^aSOFTWARE_INSTALL_STATE\[109\]=2' /DietPi/dietpi/.installed || @@ -1244,7 +1211,7 @@ You will not face any practical differences, since both services start the same elif (( $G_DIETPI_VERSION_SUB == 19 )); then #------------------------------------------------------------------------------- - #PB, fix kernel upgrades, switch from dev to stable and enable auto upgrades. + # PB, fix kernel upgrades, switch from dev to stable and enable auto upgrades. if (( $G_HW_MODEL == 44 )) && [[ ! -f '/etc/armbian-release' ]]; then cat << _EOF_ > /etc/armbian-release @@ -1268,7 +1235,7 @@ _EOF_ fi #------------------------------------------------------------------------------- - #rpi-update drop support info + # rpi-update drop support info if command -v rpi-update &> /dev/null && G_WHIP_YESNO '[INFO] RPi-Update detected\n\nIn our effort to improve system stability, and, offer software installations which build custom modules (eg: WireGuard), we can no longer support systems with non-stock-APT kernel installed (eg: rpi-update).\n\nWould you like to revert to the APT kernel now, ensuring stability and official DietPi system support?'; then local rpi_firmware='raspberrypi-bootloader raspberrypi-kernel libraspberrypi-bin libraspberrypi0' @@ -1279,11 +1246,11 @@ _EOF_ fi #------------------------------------------------------------------------------- - #Apply Nginx vhost patch: https://github.com/MichaIng/DietPi/pull/2327 + # Apply Nginx vhost patch: https://github.com/MichaIng/DietPi/pull/2327 # - Moved from v6.18 => v6.19 patch for users, which update directly from v6.19.5 to v6.20 grep -q 'include /etc/nginx/sites-dietpi/\*\.config;' /etc/nginx/sites-available/default &> /dev/null && G_CONFIG_INJECT 'include /etc/nginx/sites-dietpi/\*\.config;' 'include /etc/nginx/sites-dietpi/*.conf;' /etc/nginx/sites-available/default #------------------------------------------------------------------------------- - #Migrate Blynk to new dir structure: https://github.com/MichaIng/DietPi/issues/2322 + # Migrate Blynk to new dir structure: https://github.com/MichaIng/DietPi/issues/2322 if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[131\]=2' /DietPi/dietpi/.installed && [[ -d $G_FP_DIETPI_USERDATA/blynk && ! -d $G_FP_DIETPI_USERDATA/blynk/data ]]; then @@ -1296,7 +1263,7 @@ _EOF_ fi #------------------------------------------------------------------------------- - #Grafana: Remove obsolete x86_64 APT source, reinstall below to apply official repo: https://github.com/MichaIng/DietPi/issues/2449 + # Grafana: Remove obsolete x86_64 APT source, reinstall below to apply official repo: https://github.com/MichaIng/DietPi/issues/2449 rm -f /etc/apt/sources.list.d/grafana*.list #------------------------------------------------------------------------------- # - Reinstalls @@ -1306,44 +1273,26 @@ _EOF_ # NAA Daemon: https://github.com/MichaIng/DietPi/issues/2387#issue-395321320 # MPD: https://github.com/MichaIng/DietPi/issues/2377 # Samba: https://github.com/MichaIng/DietPi/issues/2396#issuecomment-451701569 - # Amiberry 2.24 + # v6.27 Amiberry 2.24 # Shairport Sync: https://github.com/MichaIng/DietPi/issues/2439 - # Grafana: https://github.com/MichaIng/DietPi/issues/2449 + # v6.27 Grafana: https://github.com/MichaIng/DietPi/issues/2449 if (( $G_DIETPI_INSTALL_STAGE == 2 )); then - /DietPi/dietpi/dietpi-software reinstall 37 65 77 108 124 128 131 + /DietPi/dietpi/dietpi-software reinstall 37 65 124 128 131 - # - Samba: Link disk cache to RAM: https://github.com/MichaIng/DietPi/issues/2396 + # 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 - [[ -e '/var/cache/samba' ]] && rm -R /var/cache/samba - mkdir -p /var/run/samba-cache - ln -s /var/run/samba-cache /var/cache/samba - echo 'd /var/run/samba-cache - - - - -' > /etc/tmpfiles.d/dietpi-samba_cache.conf + rm -Rf /var/cache/samba + mkdir -p /run/samba-cache + ln -s /run/samba-cache /var/cache/samba + echo 'd /run/samba-cache - - - - -' > /etc/tmpfiles.d/dietpi-samba_cache.conf fi fi #------------------------------------------------------------------------------- - #Docker fix on RPi due to faulty current "docker-ce" repo version: https://github.com/MichaIng/DietPi/issues/2282 - local dpkg_out='' - if (( $G_HW_MODEL < 10 )) && dpkg_out=$(dpkg-query -s 'docker-ce' 2>&1); then - - echo 'Package: docker-ce -Pin: version 5:18.09.0~3-0~raspbian-stretch -Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix - - if grep -q '5:18.09.0~3-0~raspbian-stretch' <<< "$dpkg_out"; then - - G_DIETPI-NOTIFY 2 'Docker: Downgrading your "docker-ce" package to the last working version' - G_AGI docker-ce=18.06.1~ce~3-0~raspbian - G_AGA - - fi - - fi - #------------------------------------------------------------------------------- - #DietPi file renaming/removal: + # DietPi file renaming/removal: # - autologin.conf: https://github.com/MichaIng/DietPi/pull/2343 [[ -f '/etc/systemd/system/getty@tty1.service.d/autologin.conf' ]] && mv /etc/systemd/system/getty@tty1.service.d/autologin.conf /etc/systemd/system/getty@tty1.service.d/dietpi-autologin.conf # - README.md: https://github.com/MichaIng/DietPi/pull/2341 @@ -1364,19 +1313,19 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix #.dietpi-autostart_index removal, if zero: https://github.com/MichaIng/DietPi/pull/2343 [[ -f '/DietPi/dietpi/.dietpi-autostart_index' ]] && (( $(> /DietPi/dietpi.txt fi - # - Apply new headless mode method, if set + # Apply new headless mode method, if set if grep -q '^[[:blank:]]*CONFIG_HDMI_OUTPUT=0' /DietPi/dietpi.txt; then /DietPi/dietpi/func/dietpi-set_hardware headless 1 fi - # - Renamed to: AUTO_SETUP_HEADLESS (added by verify_dietpi.txt automatically) + # Renamed to: AUTO_SETUP_HEADLESS (added by verify_dietpi.txt automatically) sed -i '/CONFIG_HDMI_OUTPUT/d' /DietPi/config.txt fi #------------------------------------------------------------------------------- - #Buster: "systemd" does not depend on "procps" anymore, thus we need to set it manually installed, simply applied on all distro versions. + # Buster: "systemd" does not depend on "procps" anymore, thus we need to set it manually installed, simply applied on all distro versions. G_AGI procps #------------------------------------------------------------------------------- - #Remove wireless-power setting from /etc/network/interfaces, if not supported by adapter/firmware: https://github.com/MichaIng/DietPi/issues/2198 - iwconfig wlan$(sed -n 2p /DietPi/dietpi/.network) power off &> /dev/null || sed -i '/^wireless-power/d' /etc/network/interfaces - #------------------------------------------------------------------------------- - #Grafana port change - [[ -f '/etc/grafana/grafana.ini' ]] && G_WHIP_MSG '[INFO]:\nGrafana port has changed to 3001 (previously 3000).' + # Remove wireless-power setting from /etc/network/interfaces, if not supported by adapter/firmware: https://github.com/MichaIng/DietPi/issues/2198 + iwconfig wlan$(mawk 'NR==2' /DietPi/dietpi/.network) power off &> /dev/null || sed -i '/^wireless-power/d' /etc/network/interfaces #------------------------------------------------------------------------------- - #Remove armbian banner/profiles left on ASUS TB image + # Remove armbian banner/profiles left on ASUS TB image rm -f /etc/profile.d/armbian-* #------------------------------------------------------------------------------- elif (( $G_DIETPI_VERSION_SUB == 20 )); then #------------------------------------------------------------------------------- - #Image updates - if (( $G_HW_MODEL == 40 || $G_HW_MODEL == 42 || $G_HW_MODEL == 43 )) && #$G_HW_MODEL == 42 || #Kernel panic... - [[ ! -f '/etc/armbian-release' ]]; then + # Image updates + if [[ $G_HW_MODEL == 4[023] && ! -f '/etc/armbian-release' ]]; then - G_WHIP_MSG "[INFO]:\nThe base image for $G_HW_MODEL_DESCRIPTION has been updated.\nPlease reinstall your system with the latest image from https://dietpi.com/download.\n\nYou can continue to use this existing installation, however, some kernel features may not be available." + G_WHIP_MSG "[ INFO ] The base image for $G_HW_MODEL_DESCRIPTION has been updated.\n\nPlease reinstall your system with the latest image from https://dietpi.com/download.\n\nYou can continue to use this existing installation, however, some kernel features may not be available." fi #------------------------------------------------------------------------------- @@ -1452,19 +1397,19 @@ Also have a look at "Sonarr", another alternative TV show manager, available for elif (( $G_DIETPI_VERSION_SUB == 21 )); then #------------------------------------------------------------------------------- - #Redo our /etc/bash.bashrc entry, user confirmed 4 entries: https://github.com/MichaIng/DietPi/issues/2529 - #As well allow ".bash" file ending and remove obsolete dietpi-*.sh scripts: https://github.com/MichaIng/DietPi/pull/2636 + # Redo our /etc/bash.bashrc entry, user confirmed 4 entries: https://github.com/MichaIng/DietPi/issues/2529 + # As well allow ".bash" file ending and remove obsolete dietpi-*.sh scripts: https://github.com/MichaIng/DietPi/pull/2636 sed -i '\#for i in /etc/bashrc#d' /etc/bash.bashrc G_CONFIG_INJECT '.*/etc/bashrc\.d/.*' 'for i in /etc/bashrc.d/*.sh /etc/bashrc.d/*.bash; do [ -r "$i" ] && . $i; done' /etc/bash.bashrc rm -f /etc/bashrc.d/dietpi-*.sh #------------------------------------------------------------------------------- - #Mopidy fix: https://github.com/MichaIng/DietPi/issues/2536 - getent passwd mopidy &> /dev/null && usermod -a -G dietpi,audio -d $G_FP_DIETPI_USERDATA/mopidy mopidy + # Mopidy fix: https://github.com/MichaIng/DietPi/issues/2536 + getent passwd mopidy &> /dev/null && usermod -aG dietpi,audio -d $G_FP_DIETPI_USERDATA/mopidy mopidy #------------------------------------------------------------------------------- - #Remove obsolete workaround for archive.raspberrypi.org repo on Buster: https://github.com/MichaIng/DietPi/issues/1286#issuecomment-463856159 + # Remove obsolete workaround for archive.raspberrypi.org repo on Buster: https://github.com/MichaIng/DietPi/issues/1286#issuecomment-463856159 (( $G_DISTRO == 5 && $G_HW_MODEL < 10 )) && sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/raspi.list #------------------------------------------------------------------------------- - #Removed dependency on "p7zip-full", use "7zr" (p7zip) instead: https://github.com/MichaIng/DietPi/pull/2559 + # Removed dependency on "p7zip-full", use "7zr" (p7zip) instead: https://github.com/MichaIng/DietPi/pull/2559 G_AGI p7zip if dpkg-query -s p7zip-full &> /dev/null && ! G_WHIP_BUTTON_OK_TEXT='Yes' G_WHIP_BUTTON_CANCEL_TEXT='No' G_WHIP_YESNO '[QUESTION] Do you want to keep "p7zip-full"?\n @@ -1479,7 +1424,7 @@ Do you still want to keep "p7zip-full"?'; then fi #------------------------------------------------------------------------------- - #Fix Pi-hole permissions to allow "pihole -up" + # Fix Pi-hole permissions to allow "pihole -up" if [[ -d '/var/www/html/pihole' ]]; then cd /var/www/html/admin && git reset --hard HEAD @@ -1487,24 +1432,24 @@ Do you still want to keep "p7zip-full"?'; then fi #------------------------------------------------------------------------------- - #MPD: Fix permissions issue: https://github.com/MichaIng/DietPi/issues/2462 + # MPD: Fix permissions issue: https://github.com/MichaIng/DietPi/issues/2462 if [[ -f '/etc/mpd.conf' ]]; then sed -Ei '/^(user|group)[[:blank:]]/d' /etc/mpd.conf sed -i '/^Group=/d' /lib/systemd/system/mpd.service G_CONFIG_INJECT 'User=' 'User=mpd' /lib/systemd/system/mpd.service '\[Service\]' G_CONFIG_INJECT 'PermissionsStartOnly=' 'PermissionsStartOnly=true' /lib/systemd/system/mpd.service '^User=mpd' - usermod -a -G audio,dietpi mpd + usermod -aG audio,dietpi mpd systemctl daemon-reload systemctl restart mpd fi #------------------------------------------------------------------------------- - #Transfer project and lead over to Micha (legend!) :) #: https://github.com/MichaIng/DietPi/issues/2589#issue-413925061 + # 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 #------------------------------------------------------------------------------- - #Fix rc-local.service from old images to match new systemd-rc-local-generator: https://github.com/MichaIng/DietPi/issues/2566 + # Fix rc-local.service from old images to match new systemd-rc-local-generator: https://github.com/MichaIng/DietPi/issues/2566 systemctl disable rc-local &> /dev/null systemctl disable rc.local &> /dev/null grep -q 'dietpi' /lib/systemd/system/rc-local.service && cat << _EOF_ > /lib/systemd/system/rc-local.service @@ -1531,21 +1476,21 @@ GuessMainPID=no _EOF_ systemctl daemon-reload #------------------------------------------------------------------------------- - #Remove obsolete DietPi-Sync log: https://github.com/MichaIng/DietPi/pull/2606 + # Remove obsolete DietPi-Sync log: https://github.com/MichaIng/DietPi/pull/2606 [[ -f '/var/log/dietpi-sync.log' ]] && rm /var/log/dietpi-sync.log #------------------------------------------------------------------------------- - #XU4, use Meveric's xorg.conf which detects 3.x and 4.x kernel configuration requirments: - if (( $G_HW_MODEL == 11 )) && [[ -f '/etc/X11/xorg.conf' ]]; then + # XU4, use Meveric's xorg.conf which detects 3.x and 4.x kernel configuration requirments: + if [[ $G_HW_MODEL == 11 && -f '/etc/X11/xorg.conf' ]]; then rm /etc/X11/xorg.conf G_AGI --reinstall firmware-samsung xf86-video-armsoc-odroid malit628-odroid fi #------------------------------------------------------------------------------- - #RPi | Remove "framebuffer_depth" handling: https://github.com/MichaIng/DietPi/pull/2635 + # RPi | Remove "framebuffer_depth" handling: https://github.com/MichaIng/DietPi/pull/2635 (( $G_HW_MODEL < 10 )) && sed -i '/framebuffer_depth/d' /DietPi/config.txt #------------------------------------------------------------------------------- - #Nextcloud: Add OCM/OCS provider redirects as this is checked and printed as warning on admin panel: https://github.com/MichaIng/DietPi/issues/2638 + # Nextcloud: Add OCM/OCS provider redirects as this is checked and printed as warning on admin panel: https://github.com/MichaIng/DietPi/issues/2638 if [[ -f '/etc/apache2/sites-available/dietpi-nextcloud.conf' ]] && ! grep -q 'oc[ms]-provider' /etc/apache2/sites-available/dietpi-nextcloud.conf; then @@ -1571,17 +1516,17 @@ Redirect permanent /ocs-provider /nextcloud/ocs-provider' >> /etc/apache2/sites- fi #------------------------------------------------------------------------------- - #Reinstalls - # Amiberry 2.25: https://github.com/MichaIng/DietPi/issues/2599 + # Reinstalls + # v6.27 Amiberry 2.25: https://github.com/MichaIng/DietPi/issues/2599 # Allo GUI v13: https://github.com/sparky-sbc/sparky-test/tree/master/dietpi-gui-usbdebug # Deluge: Patch according to installer rework: https://github.com/MichaIng/DietPi/pull/2594 # rTorrent: https://github.com/MichaIng/DietPi/issues/2629 if (( $G_DIETPI_INSTALL_STAGE == 2 )); then - local reinstall_indices='108 160' + local reinstall_indices='160' if grep -q '^aSOFTWARE_INSTALL_STATE\[107\]=2' /DietPi/dietpi/.installed && - [[ -f /root/.rtorrent.rc ]]; then + [[ -f '/root/.rtorrent.rc' ]]; then reinstall_indices+=' 107' G_CONFIG_INJECT 'system.umask.set[[:blank:]=]' 'system.umask.set = 002' /root/.rtorrent.rc @@ -1718,90 +1663,39 @@ Further info and usage: https://dietpi.com/phpbb/viewtopic.php?f=8&t=5828' fi #----------------------------------------------------------------------- # PHP7.3 migration: https://github.com/MichaIng/DietPi/issues/2367 - local reinstall_ids='' - local upgrade_php=0 - if grep -q '^aSOFTWARE_INSTALL_STATE\[89\]=2' /DietPi/dietpi/.installed; then + local upgrade_php='' + # - Only upgrade versions lower than 7.2 and skip any check version Buster+ where this is impossible + if (( $G_DISTRO < 5 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[89\]=2' /DietPi/dietpi/.installed && ! command -v php7.{2,3} &> /dev/null; then + + upgrade_php=89 - # ownCloud (up to v10.2) does not yet support PHP7.3, so install PHP7.2 for now - # phpBB 3.2.X: https://github.com/phpbb/phpbb/blob/3.2.x/phpBB/install/app.php#L23 + # Software which does not support PHP7.3, install PHP7.2 instead local PHP_NAME='php7.3' - [[ -f '/var/www/owncloud/occ' || -f '/var/www/phpBB3/config.php' ]] && PHP_NAME='php7.2' + # - phpBB 3.2.X: https://github.com/phpbb/phpbb/blob/3.2.x/phpBB/install/app.php#L23 + [[ -f '/var/www/phpBB3/config.php' ]] && PHP_NAME='php7.2' + # - ownCloud up to v10.2 + if [[ -f '/var/www/owncloud/version.php' ]]; then - if ! command -v $PHP_NAME &> /dev/null; then + local oc_version_major=$(sed -n '/$OC_VersionString/{s/^[^0-9]*//;s/\..*$//;p;q}' /var/www/owncloud/version.php) + local oc_version_minor=$(sed -n '/$OC_VersionString/{s/^[^.]*\.//;s/\..*$//;p;q}' /var/www/owncloud/version.php) + (( $oc_version_major < 10 || ( $oc_version_major == 10 && oc_version_minor < 3 ) )) && PHP_NAME='php7.2' - reinstall_ids+=' 89' - G_WHIP_MSG "[ INFO ] PHP upgrade\n + fi + + G_WHIP_MSG "[ INFO ] PHP upgrade\n Your PHP instance will be upgraded to ${PHP_NAME^^}. This enhances security and performance of your web applications and is required to run some of the latest web application versions, e.g. Nextcloud 16, ownCloud 10.2 and others.\n -We will update webserver configurations and backup the whole /etc/php(5) directory to /mnt/dietpi_userdata/php(5)_bak, so you can recover custom settings.\n +We will update webserver configurations and backup the whole /etc/php directory to /mnt/dietpi_userdata/php_bak, so you can recover custom settings.\n NB: For any custom PHP-dependent web applications, which you have installed manually (outside of DietPi-Software), you might need to adjust the used socket to: /run/php/$PHP_NAME-fpm.sock NBB: Reinstall manually installed PHP modules via: G_AGI $PHP_NAME-" - upgrade_php=1 - - # We need to upgrade Jessie Nextcloud users since NC13 does not support PHP7.3 yet. Check for NC < 14 in general and do incremental upgrading in case. - local upgrade_nextcloud=0 - while [[ -f '/var/www/nextcloud/version.php' ]] - do - - # - Estimate Nextcloud version, skip if higher than 13 or invalid - local nextcloud_version=$(grep '$OC_VersionString' /var/www/nextcloud/version.php | sed "s/^.*= '//" | sed 's/\..*$//g') - disable_error=1 G_CHECK_VALIDINT "$nextcloud_version" 9 13 || break - - # - Inform user - G_WHIP_MSG '[ INFO ] Nextcloud will be upgraded\n -Your Nextcloud version does not yet support PHP7.3. On Jessie systems this is expected where Nextcloud 14+ was not supported.\n -We will upgrade your Nextcloud version to Nextcloud 14 now to allow the PHP upgrade, which on the other hand enables you to further upgrade Nextcloud to its current major version.\n -We will create a full backup of your Nextcloud install directory and database to: /mnt/dietpi_userdata/nextcloud_data/ -Your Nextcloud data are not touched.' - upgrade_nextcloud=1 - - # - Backup database and install dir: Use our cloud migration script - # In case of failure, exit to not create any damage - local url="https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.meta/dietpi-cloud-migration" - G_CHECK_URL "$url" - curl -sSL "$url" | bash - G_ERROR_HANDLER_EXITCODE=$? - G_ERROR_HANDLER_COMMAND='Nextcloud backup' - G_ERROR_HANDLER_RETRY=0 - G_ERROR_HANDLER - - # - Incremental upgrade since skipping major versions is not supported. There should be no installs < NC13 but let's be failsafe. - until (( $nextcloud_version > 13 )) - do - - ((nextcloud_version++)) - G_CHECK_URL https://download.nextcloud.com/server/releases/latest-$nextcloud_version.tar.bz2 - G_RUN_CMD wget https://download.nextcloud.com/server/releases/latest-$nextcloud_version.tar.bz2 - G_RUN_CMD rm -R /var/www/nextcloud - G_RUN_CMD tar xf latest-$nextcloud_version.tar.bz2 -C /var/www - G_RUN_CMD cp -a /mnt/dietpi_userdata/nextcloud_data/dietpi-nextcloud-installation-backup/config/config.php /var/www/nextcloud/config/config.php - # - Restore custom apps but prevent overwriting upgraded ones or adding obsolete files - for i in /mnt/dietpi_userdata/nextcloud_data/dietpi-nextcloud-installation-backup/apps/* - do - - [[ -d /var/www/nextcloud/apps/${i##*/} ]] || G_RUN_CMD cp -a $i /var/www/nextcloud/apps/ - - done - # - Permissions - G_RUN_CMD chown -R www-data:www-data /var/www/nextcloud - G_RUN_CMD find /var/www/nextcloud/ -type d -exec chmod 750 {} \; - G_RUN_CMD find /var/www/nextcloud/ -type f -exec chmod 640 {} \; - # - Upgrade until NC13, then upgrade after PHP7.3 has been installed, since NC13 does not support PHP5.6 anymore - (( $nextcloud_version < 14 )) && { ncc upgrade || exit 1; } - - done - break - - done - - [[ -d '/etc/php' ]] && G_RUN_CMD cp -a /etc/php /mnt/dietpi_userdata/php_bak - [[ -d '/etc/php5' ]] && G_RUN_CMD cp -a /etc/php5 /mnt/dietpi_userdata/php5_bak - - # - Lighttpd - [[ -f '/etc/lighttpd/conf-available/15-fastcgi-php.conf' ]] && sed -i "s@\"socket\".*\$@\"socket\" => \"/run/php/$PHP_NAME-fpm.sock\",@" /etc/lighttpd/conf-available/15-fastcgi-php.conf - # - Nginx - [[ -f '/etc/nginx/nginx.conf' ]] && sed -i "s#/run/php.*-fpm.sock#/run/php/$PHP_NAME-fpm.sock#g" /etc/nginx/nginx.conf - fi + # Backup config + [[ -d '/etc/php' ]] && G_RUN_CMD cp -a /etc/php /mnt/dietpi_userdata/php_bak + + # Update PHP socket + # - Lighttpd + [[ -f '/etc/lighttpd/conf-available/15-fastcgi-php.conf' ]] && sed -i "s@\"socket\".*\$@\"socket\" => \"/run/php/$PHP_NAME-fpm.sock\",@" /etc/lighttpd/conf-available/15-fastcgi-php.conf + # - Nginx + [[ -f '/etc/nginx/nginx.conf' ]] && sed -i "s#/run/php.*-fpm.sock#/run/php/$PHP_NAME-fpm.sock#g" /etc/nginx/nginx.conf fi #----------------------------------------------------------------------- @@ -1826,20 +1720,19 @@ Your Nextcloud data are not touched.' fi # SABnzbd: https://github.com/MichaIng/DietPi/pull/2768 - # Jackett: https://github.com/MichaIng/DietPi/pull/2773 + # v6.27 Jackett: https://github.com/MichaIng/DietPi/pull/2773 if [[ -d '/opt/jackett/.config' ]]; then cp -a /opt/jackett/.config/. /opt/jackett/ rm -R /opt/jackett/.config fi - /DietPi/dietpi/dietpi-software reinstall 34 35 42 139 147 $reinstall_ids + /DietPi/dietpi/dietpi-software reinstall 34 35 42 139 $upgrade_php #----------------------------------------------------------------------- # Remove old PHP version - if (( $upgrade_php )); then + if [[ $upgrade_php ]]; then - G_AGP php{5,7.0,7.1}-* libapache2-mod-php{5,7.0,7.1} - [[ $PHP_NAME = 'php7.3' ]] && G_AGP php7.2-* libapache2-mod-php7.2 + G_AGP php{7.0,7.1}-* libapache2-mod-php{7.0,7.1} # New mod-php must be enabled manually since this is skipped by APT as long as prior version is active command -v a2enmod &> /dev/null && a2enmod $PHP_NAME @@ -1861,16 +1754,6 @@ opcache.max_accelerated_files=10000\nopcache.memory_consumption=128\nopcache.sav fi grep -q '^aSOFTWARE_INSTALL_STATE\[48\]=2' /DietPi/dietpi/.installed && G_AGI $PHP_NAME-intl - # Upgrade Nextcloud - if (( $upgrade_nextcloud )); then - - G_RUN_CMD systemctl start mariadb redis-server - ncc upgrade - ncc db:add-missing-indices - ncc db:convert-filecache-bigint - - fi - fi fi @@ -1880,8 +1763,8 @@ opcache.max_accelerated_files=10000\nopcache.memory_consumption=128\nopcache.sav #------------------------------------------------------------------------------- # Add Plex and Emby users to dietpi group to grant media and network mount access - getent passwd emby &> /dev/null && usermod -a -G dietpi emby - getent passwd plex &> /dev/null && usermod -a -G dietpi plex + getent passwd emby &> /dev/null && usermod -aG dietpi emby + getent passwd plex &> /dev/null && usermod -aG dietpi plex #------------------------------------------------------------------------------- # Patch Lighttpd config file on ARMv6 (Buster version installed): https://github.com/MichaIng/DietPi/issues/2808 if [[ -f '/etc/lighttpd/lighttpd.conf' && ! -f '/usr/share/lighttpd/create-mime.assign.pl' && -f '/usr/share/lighttpd/create-mime.conf.pl' ]]; then @@ -1902,7 +1785,7 @@ opcache.max_accelerated_files=10000\nopcache.memory_consumption=128\nopcache.sav if [[ -f '/usr/share/applications/dietpi-process_tool.desktop' ]]; then rm /usr/share/applications/dietpi-process_tool.desktop - G_RUN_CMD wget https://github.com/MichaIng/DietPi/raw/$G_GITBRANCH/.conf/desktop/apps/dietpi-services.desktop -O /usr/share/applications/dietpi-services.desktop + G_RUN_CMD wget https://github.com/$G_GITOWNER/DietPi/raw/$G_GITBRANCH/.conf/desktop/apps/dietpi-services.desktop -O /usr/share/applications/dietpi-services.desktop chmod +x /usr/share/applications/dietpi-services.desktop fi @@ -1958,21 +1841,6 @@ Use "dietpi-config" to adjust these settings to your needs.' fi #------------------------------------------------------------------------------- - # Disable and remove all ARMbian services, especially to catch new zRam implementation, conflicting/bugging RAMlog in cases: https://github.com/MichaIng/DietPi/issues/2738 - for i in /etc/init.d/armbian* /{etc,lib,usr/lib}/systemd/system/armbian*.service{,.d} - do - - [[ -e $i ]] || continue - [[ -f $i ]] && systemctl disable --now ${i##*/} - rm -R $i - - done - rm -f /etc/apt/apt.conf.d/*armbian* - rm -f /etc/cron.*/armbian* - rm -f /etc/default/armbian* - [[ -d '/usr/lib/armbian' ]] && rm -R /usr/lib/armbian - [[ -d '/usr/share/armbian' ]] && rm -R /usr/share/armbian - #------------------------------------------------------------------------------- # Update x86_64 kernel module settings if (( $G_HW_ARCH == 10 )); then @@ -2002,10 +1870,10 @@ _EOF_ fi #------------------------------------------------------------------------------- # Install "haveged" entropy daemon by default on all DietPi systems: https://github.com/MichaIng/DietPi/issues/2806 - G_AGI haveged + (( $G_HW_MODEL > 9 )) && G_AGI haveged #------------------------------------------------------------------------------- # RPi3: Remove doubled config.txt temp_limit value due to: https://github.com/MichaIng/DietPi/commit/cafcbc599ef23c337e75003fb8eacc446877eaba#diff-68acf994541fd7b6ea4f6b02d04ee328L60 - if (( $G_HW_MODEL == 3 )) && (( $(grep -c '^[[:blank:]#]*temp_limit=' /DietPi/config.txt) > 1 )); then + if (( $G_HW_MODEL == 3 && $(grep -c '^[[:blank:]#]*temp_limit=' /DietPi/config.txt) > 1 )); then local current=$(grep '^[[:blank:]]*temp_limit=' /DietPi/config.txt | sed 's/^[^=]*=//' | tail -1) # Get current effective (last) value disable_error=1 G_CHECK_VALIDINT "$current" || current=75 # If none, use 75'c as DietPi default on RPi3 @@ -2074,18 +1942,8 @@ A backup will be created to "/etc/mympd/mympd.conf.bak_DDMMYYY_N" from where you sed -i '/^[[:blank:]#]*i2c_arm_baudrate=/d' /DietPi/config.txt sed -i '/^[[:blank:]#]*bcm2835-v4l2/d' /etc/modules grep -q '^[[:blank:]]*start_x=1' /DietPi/config.txt || /DietPi/dietpi/func/dietpi-set_hardware rpi-camera disable - if [[ -f '/etc/modprobe.d/disable_bt.conf' ]]; then - - G_CONFIG_INJECT 'dtoverlay=disable-bt' 'dtoverlay=disable-bt' /DietPi/config.txt - dtoverlay disable-bt - - fi - if [[ -f '/etc/modprobe.d/disable_wifi_rpi3_onboard.conf' ]]; then - - G_CONFIG_INJECT 'dtoverlay=disable-wifi' 'dtoverlay=disable-wifi' /DietPi/config.txt - dtoverlay disable-wifi - - fi + [[ -f '/etc/modprobe.d/disable_bt.conf' ]] && G_CONFIG_INJECT 'dtoverlay=disable-bt' 'dtoverlay=disable-bt' /DietPi/config.txt + [[ -f '/etc/modprobe.d/disable_wifi_rpi3_onboard.conf' ]] && G_CONFIG_INJECT 'dtoverlay=disable-wifi' 'dtoverlay=disable-wifi' /DietPi/config.txt # Offer re-adding of "initial_turbo" on RPi: https://github.com/MichaIng/DietPi/issues/3147 if ! grep -q '^[[:blank:]]*initial_turbo' /DietPi/config.txt; then @@ -2100,7 +1958,7 @@ Do you want to have the recommended "initial_turbo=20" re-added to your config.t fi #------------------------------------------------------------------------------- - # Docker: Remove obsolete RPi workaround, since a new version has been released + # Docker: Remove obsolete RPi fix: https://github.com/MichaIng/DietPi/issues/2282 (new version is available now) [[ -f '/etc/apt/preferences.d/dietpi-docker_fix' ]] && rm /etc/apt/preferences.d/dietpi-docker_fix #------------------------------------------------------------------------------- # Config file renaming: https://github.com/MichaIng/DietPi/pull/3000 @@ -2325,23 +2183,120 @@ Would you like to switch back to the Nginx authentication method now?' && certbo fi #------------------------------------------------------------------------------- + elif (( $G_DIETPI_VERSION_SUB == 26 )); then + + #------------------------------------------------------------------------------- + # ownCloud: Remove obsolete PHP7.3 block: https://github.com/MichaIng/DietPi/pull/3169 + [[ -f '/etc/apt/preferences.d/dietpi-owncloud' ]] && rm /etc/apt/preferences.d/dietpi-owncloud + #------------------------------------------------------------------------------- + # RPi4 EEPROM install/update: https://github.com/MichaIng/DietPi/issues/3217 + (( $G_HW_MODEL == 4 )) && /DietPi/dietpi/func/dietpi-set_hardware rpi-eeprom + #------------------------------------------------------------------------------- + # Remove obsolete apt-transport-https on Buster+ where it is a transitional dummy package only, HTTPS support fixed part of apt: https://packages.debian.org/buster/apt-transport-https + (( $G_DISTRO > 4 )) && G_AGP apt-transport-https + #------------------------------------------------------------------------------- + # Remove microcode packages from VM, where they are and must be without effect + (( $G_HW_MODEL == 20 )) && G_AGP {intel,amd64}-microcode && G_AGA + #------------------------------------------------------------------------------- + G_DIETPI-NOTIFY 2 'Removing obsolete DietPi files that could have remained on older systems...' + rm -vRf /{DietPi,boot}/dietpi/{server_version*,login} /boot/dietpi/patch_file + #------------------------------------------------------------------------------- + # Mask ARMbian services, which are otherwise re-enabled on related APT package upgrade + local packages=$(dpkg-query -Wf '${PACKAGE}\n' linux-*-root-* 2> /dev/null) + [[ $packages ]] && G_DIETPI-NOTIFY 2 'Masking and removing conflicting ARMbian services and files...' + for i in $packages + do + + services=$(dpkg -L $i | sed -n '\|^/lib/systemd/system/[^/]*\.service$|{s|^.*/||g;p}') + [[ $services == *'armbian'* ]] || continue # Failsafe + systemctl disable --now $services + systemctl mask $services + + done + # Place DPKG exclude file, especially to skip cron jobs, which are doomed to fail and an unnecessary overhead + syslog spam on DietPi + rm -vf /etc/apt/apt.conf.d/*armbian* + rm -vf /etc/cron.*/*armbian* + #rm -vf /etc/default/*armbian* + rm -vf /etc/update-motd.d/*armbian* + rm -vf /etc/profile.d/*armbian* + #[[ -d '/usr/lib/armbian' ]] && rm -vR /usr/lib/armbian + [[ -d '/usr/share/armbian' ]] && rm -vR /usr/share/armbian + cat << _EOF_ > /etc/dpkg/dpkg.cfg.d/dietpi-no_armbian +# Exclude conflicting ARMbian files +path-exclude /lib/systemd/system/*armbian* +path-exclude /etc/apt/apt.conf.d/*armbian* +path-exclude /etc/cron.*/*armbian* +#path-exclude /etc/default/*armbian* # Breaks ARMbian root package upgrade +path-exclude /etc/update-motd.d/*armbian* +path-exclude /etc/profile.d/*armbian* +#path-exclude /usr/lib/armbian # Breaks ARMbian root package upgrade +path-exclude /usr/share/armbian +_EOF_ + #------------------------------------------------------------------------------- + # Reinstalls + # Syncthing: https://github.com/MichaIng/DietPi/pull/3202 + # Grafana: https://github.com/MichaIng/DietPi/issues/3213 + # Jackett: https://github.com/MichaIng/DietPi/issues/2593 + # Amiberry: https://github.com/MichaIng/DietPi/pull/3252 + # Home Assistant: No reinstall but inform user about required Python update: https://github.com/MichaIng/DietPi/pull/3220 + if (( $G_DIETPI_INSTALL_STAGE == 2 )); then + + if [[ -d '/home/homeassistant/.pyenv/versions/3.6.3' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[157\]=2' /DietPi/dietpi/.installed; then + + G_WHIP_MSG '[WARNING] Home Assistant: Python3.6 will be deprecated +\nThe Python version for your Home Assistant pyenv needs to be updated to avoid deprecation with new HA versions: https://github.com/MichaIng/DietPi/issues/3219 +\nSince this can take a very long time, we do not automate this during the DietPi update. When you can effort the time, please run: +- dietpi-software reinstall 157' + + fi + if [[ -d '/etc/syncthing' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[50\]=2' /DietPi/dietpi/.installed; then + + if [[ -d '/opt/syncthing' ]]; then + + G_RUN_CMD cp -a /etc/syncthing/. /opt/syncthing/ + rm -R /etc/syncthing + + else + + G_RUN_CMD mv /etc/syncthing /opt/syncthing + + fi + [[ -d '/var/log/syncthing' ]] && rm -R /var/log/syncthing + G_WHIP_MSG '[ INFO ] Syncthing reinstall +\nThe Syncthing binary has been moved from /etc/syncthing to /opt/syncthing. +\nThe service has been updated to support auto-updates. You may want to enable it via web UI. +\nFile logging has been disabled. To view Syncthing logs, run: + - journalctl -u syncthing' + + fi + if [[ $G_HW_ARCH == 1 && -f '/etc/apt/sources.list.d/grafana.list' ]] && grep -q 'bintray.com' /etc/apt/sources.list.d/grafana.list && grep -q '^aSOFTWARE_INSTALL_STATE\[77\]=2' /DietPi/dietpi/.installed; then + + G_DIETPI-NOTIFY 2 'Removing obsolete bintray.com APT repo prior to Grafana update...' + rm -v /etc/apt/sources.list.d/grafana.list + + fi + if [[ -f '/usr/local/lib/libSDL2.txt' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[108\]=2' /DietPi/dietpi/.installed; then + + G_DIETPI-NOTIFY 2 'Removing obsolete SDL2 libraries prior to Amiberry update...' + rm -v /usr/local/lib/libSDL2* + + fi + /DietPi/dietpi/dietpi-software reinstall 50 77 108 147 + + fi + #------------------------------------------------------------------------------- + fi #------------------------------------------------------------------------------- - # NB: All if statements must contain at least one command. Prevents bash having a hissy fit :) - # The fastest dummy command is ":", which really does nothing ;). - # NBB: Avoid multiple reinstalls of same software ID. Check last column of table: https://github.com/MichaIng/DietPi/wiki/DietPi-Software-list + # NB: Avoid multiple reinstalls of same software ID. Check last column of table: https://github.com/MichaIng/DietPi/wiki/DietPi-Software-list #------------------------------------------------------------------------------- - } #------------------------------------------------------------------------------- # Run Incremental_Patch_System #------------------------------------------------------------------------------- - sleep 0.25 - #------------------------------------------------------------------------------- - exit + exit 0 #------------------------------------------------------------------------------- - } diff --git a/dietpi/pre-patch_file b/dietpi/pre-patch_file index 8d7c050da3..2efc81862e 100644 --- a/dietpi/pre-patch_file +++ b/dietpi/pre-patch_file @@ -156,8 +156,6 @@ _EOF_ fi #------------------------------------------------------------------------------- # Pre-patch 13/14: https://github.com/MichaIng/DietPi/issues/3131#issuecomment-536997267 - # Pre-patch 15: WireGuard: Enable auto-rebuild after kernel upgrades on RPi - # Pre-patch 16: https://github.com/MichaIng/DietPi/pull/2571 # Pre-patch 17: https://github.com/MichaIng/DietPi/issues/3031#issuecomment-540477241 if (( $G_DIETPI_VERSION_SUB < 26 )); then @@ -172,13 +170,6 @@ _EOF_ echo 'deb http://raspbian.raspberrypi.org/raspbian/ bullseye main' > /etc/apt/sources.list.d/dietpi-wireguard.list || exit 14 - if command -v wg &> /dev/null && grep -q '^aSOFTWARE_INSTALL_STATE\[172\]=2' /DietPi/dietpi/.installed; then - - echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 15 | Enable WireGuard auto-rebuild after kernel upgrades on RPi' - echo -e '#!/bin/dash\ndpkg-reconfigure wireguard-dkms' > /etc/kernel/postinst.d/dietpi-wireguard || exit 15 - - fi - # non-RPi else @@ -188,18 +179,30 @@ _EOF_ fi + if (( $(mawk 'NR==1' /DietPi/dietpi/.hw_model || mawk 'NR==1' /boot/dietpi/.hw_model) < 10 )) && dpkg-query -s kodi &> /dev/null; then + + echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 17 | Pre-create /etc/polkit-1/localauthority/50-local.d to prevent Kodi upgrade failure' + mkdir -p /etc/polkit-1/localauthority/50-local.d || exit 17 + + fi + + fi + #------------------------------------------------------------------------------- + # Pre-patch 16: https://github.com/MichaIng/DietPi/pull/2571 + if (( $G_DIETPI_VERSION_SUB < 27 )); then + if [[ -f '/etc/apt/preferences.d/dietpi-wireguard' ]]; then echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 16 | Harden "bullseye" repo preferences for WireGuard installs' echo -e 'Package: *\nPin: release n=bullseye\nPin-Priority: -1\n -Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin-Priority: 99' > /etc/apt/preferences.d/dietpi-wireguard || exit 16 +Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin-Priority: 100' > /etc/apt/preferences.d/dietpi-wireguard || exit 16 fi - if (( $(mawk 'NR==1' /DietPi/dietpi/.hw_model || mawk 'NR==1' /boot/dietpi/.hw_model) < 10 )) && dpkg-query -s kodi &> /dev/null; then + if [[ -f '/etc/kernel/postinst.d/dietpi-wireguard' ]]; then - echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 17 | Pre-create /etc/polkit-1/localauthority/50-local.d to prevent Kodi upgrade failure' - mkdir -p /etc/polkit-1/localauthority/50-local.d + echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 18 | Remove WireGuard auto-rebuild skript, since DKMS is now triggered correctly' + rm /etc/kernel/postinst.d/dietpi-wireguard || exit 18 fi diff --git a/dietpi/server_version-6 b/dietpi/server_version-6 index 999697a5b0..6834eb2924 100644 --- a/dietpi/server_version-6 +++ b/dietpi/server_version-6 @@ -1,3 +1,3 @@ 6 -26 -3 +27 +0 diff --git a/rootfs/etc/bashrc.d/dietpi.bash b/rootfs/etc/bashrc.d/dietpi.bash index 4d1289e2a1..f96ca5177f 100644 --- a/rootfs/etc/bashrc.d/dietpi.bash +++ b/rootfs/etc/bashrc.d/dietpi.bash @@ -15,20 +15,19 @@ #//////////////////////////////////// # Failsafe: Never load this script in non-interactive shells, e.g. SFTP, SCP or rsync - [[ -t 0 && $PS1 && $- == *i* ]] || return 0 + [[ -t 0 && $PS1 && $- == *'i'* ]] || return 0 # DietPi-Globals: dietpi-* aliases, G_* functions and variables . /DietPi/dietpi/func/dietpi-globals || { echo -e '[\e[31mFAILED\e[0m] DietPi-Login | Failed to load DietPi-Globals. Skipping DietPi login scripts...'; return 1; } # "G_DIETPI-NOFITY -2 message" starts a process animation. If scripts fail to kill the animation, e.g. cancelled by user, terminal bash prompt has to do it as last resort. - PROMPT_COMMAND="[[ -w /tmp/dietpi-process.pid ]] && rm /tmp/dietpi-process.pid && tput cub 9 && tput ed; $PROMPT_COMMAND" + [[ $PROMPT_COMMAND == *'dietpi-process.pid'* ]] || PROMPT_COMMAND="[[ -w '/tmp/dietpi-process.pid' ]] && rm /tmp/dietpi-process.pid && echo -ne '\r\e[J'; $PROMPT_COMMAND" # Workaround if SSH client overrides locale with "POSIX" fallback: https://github.com/MichaIng/DietPi/issues/1540#issuecomment-367066178 if [[ $(locale) =~ 'POSIX' ]]; then - current_locale=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_LOCALE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') - export LANG=${current_locale:=en_GB.UTF-8} - export LC_ALL=$current_locale + current_locale=$(sed -n '/^[[:blank:]]*AUTO_SETUP_LOCALE=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + export LC_ALL=${current_locale:-en_GB.UTF-8} unset current_locale fi @@ -37,12 +36,10 @@ if [[ $SSH_TTY ]] && ! toe -a | grep -q "^$TERM[[:blank:]]"; then TERM_old=$TERM - ncurses_term='' - - [[ $TERM =~ 256 ]] && export TERM='xterm-256color' || export TERM='xterm' + [[ $TERM == *'256'* ]] && export TERM='xterm-256color' || export TERM='xterm' G_WHIP_MENU_ARRAY=('0' 'Ignore for now, I will change the SSH clients terminal.') - + ncurses_term= if ! dpkg-query -s ncurses-term &> /dev/null; then ncurses_term=' or install the "ncurses-term" APT packages, which enables a wider terminal support' @@ -54,7 +51,6 @@ G_PROGRAM_NAME='Unsupported SSH client terminal' G_WHIP_MENU "[WARNING] Your SSH client passed an unsupported terminal: TERM=$TERM_old\n As a workaround we fooled the server by setting: TERM=$TERM. This is not the cleanest solution, since commands might expect colours or formats, that are not supported by the actual terminal.\n Please change your SSH clients terminal, respectively the passed \$TERM string$ncurses_term." && (( $G_WHIP_RETURNED_VALUE )) && G_AGI ncurses-term - unset TERM_old ncurses_term fi