Skip to content

Commit 37d1f08

Browse files
committed
dietpi-software: Add support for automatied APT package installs
- DietPi-Software | The new AUTO_SETUP_APT_INSTALLS dietpi.txt setting can now be used to have APT packages automatically installed after the first run setup of DietPi systems. See dietpi.txt for details. - DietPi-Software | The AUTO_SETUP_INSTALL_SOFTWARE_ID dietpi.txt settings now allows to define multiple software IDs in a single line, separated by space. For now, multiple AUTO_SETUP_INSTALL_SOFTWARE_ID lines are still supported, but this will change in the future. If you keep a dietpi.txt for future DietPi instances, and make use of the AUTO_SETUP_INSTALL_SOFTWARE_ID setting, please update it accordingly.
1 parent 97fc20e commit 37d1f08

File tree

3 files changed

+45
-25
lines changed

3 files changed

+45
-25
lines changed

CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ v9.10
44
Enhancements:
55
- RISC-V | Debian Trixie does now support this architecture, hence our VisionFive 2 and Star64 images are now provided with Debian Trixie/testing instead of Debian Sid/unstable, and existing systems will be migrated to the Trixie suite.
66
- RISC-V | Additional software options have been enabled for RISC-V systems: Bazarr, Raspotify, NZBGet, MicroK8s and AdGuard Home
7+
- DietPi-Software | The new AUTO_SETUP_APT_INSTALLS dietpi.txt setting can now be used to have APT packages automatically installed after the first run setup of DietPi systems. See dietpi.txt for details.
8+
- DietPi-Software | The AUTO_SETUP_INSTALL_SOFTWARE_ID dietpi.txt settings now allows to define multiple software IDs in a single line, separated by space. For now, multiple AUTO_SETUP_INSTALL_SOFTWARE_ID lines are still supported, but this will change in the future. If you keep a dietpi.txt for future DietPi instances, and make use of the AUTO_SETUP_INSTALL_SOFTWARE_ID setting, please update it accordingly.
79
- DietPi-Software | myMPD: We enabled the software option for ARMv6 Bookworm systems, since packages for Raspbian Bookworm are now available. Many thanks to @hackslikeus for bringing up the topic: https://github.com/MichaIng/DietPi/issues/7345
810
- DietPi-Software | vaultwarden: Our builds will now show the package version within the web UI. Many thanks to @gh3597 for reporting it missing and how to add it: https://github.com/MichaIng/DietPi/issues/7364
911

dietpi.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ AUTO_SETUP_HEADLESS=0
5959
# Unmask (enable) systemd-logind service (including dbus), which is masked by default on DietPi
6060
AUTO_UNMASK_LOGIND=0
6161

62+
# Install APT packages automatically after first run setup.
63+
# - Add as many APT package names as you wish, separated by space.
64+
# - They will be installed after dietpi-software options and before the script defined via AUTO_SETUP_CUSTOM_SCRIPT_EXEC (see below) is executed.
65+
# - E.g. the following (without the leading "#") will install the APT packages iotop, iptables and xz-utils:
66+
#AUTO_SETUP_APT_INSTALLS=iotop iptables xz-utils
67+
6268
# Custom Script (pre-networking and pre-DietPi install)
6369
# - Allows you to automatically execute a custom script before network is up on first boot.
6470
# - Copy your script to /boot/Automation_Custom_PreScript.sh and it will be executed automatically.
@@ -111,14 +117,14 @@ AUTO_SETUP_AUTOSTART_TARGET_INDEX=0
111117
AUTO_SETUP_AUTOSTART_LOGIN_USER=root
112118

113119
##### Non-interactive first run setup #####
114-
# On first login, run update, initial setup and software installs without any user input
120+
# On first boot, run update, initial setup and software installs without any user interaction.
115121
# - Setting this to "1" is required for AUTO_SETUP_GLOBAL_PASSWORD and AUTO_SETUP_INSTALL_SOFTWARE_ID.
116122
# - Setting this to "1" indicates that you accept the DietPi GPLv2 license, available at /boot/dietpi-LICENSE.txt, superseding AUTO_SETUP_ACCEPT_LICENSE.
117123
AUTO_SETUP_AUTOMATED=0
118124

119-
# Global password to be applied for the system
125+
# On first boot, apply this password for login users and software installs automatically.
120126
# - Requires AUTO_SETUP_AUTOMATED=1
121-
# - Affects "root" and "dietpi" users login passwords and is used by dietpi-software as default for software installs which require a password.
127+
# - Affects "root" and "dietpi" user's login passwords and is used by dietpi-software as default for software installs which require a password.
122128
# - During first run setup, the password is removed from this file and instead encrypted and saved to root filesystem.
123129
# - WARN: The default SSH server Dropbear does not support passwords over 100 characters.
124130
# - WARN: We cannot guarantee that all software options can handle special characters like \"$.
@@ -127,10 +133,10 @@ AUTO_SETUP_GLOBAL_PASSWORD=dietpi
127133
# Software to automatically install
128134
# - Requires AUTO_SETUP_AUTOMATED=1
129135
# - List of available software IDs: https://github.com/MichaIng/DietPi/wiki/DietPi-Software-list
130-
# - Add as many entries as you wish, one each line.
136+
# - Add as many software IDs as you wish, separated by space.
131137
# - DietPi will automatically install all dependencies, like ALSA/X11 for desktops etc.
132-
# - E.g. the following (without the leading "#") will install the LXDE desktop automatically on first boot:
133-
#AUTO_SETUP_INSTALL_SOFTWARE_ID=23
138+
# - E.g. the following (without the leading "#") will install the LXDE desktop, the TigerVNC server and the Kodi media centre automatically on first boot:
139+
#AUTO_SETUP_INSTALL_SOFTWARE_ID=23 28 31
134140

135141
#------------------------------------------------------------------------------------------------------
136142
##### Misc DietPi program settings #####

dietpi/dietpi-software

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14644,30 +14644,34 @@ _EOF_
1464414644

1464514645
# Find all software entries of AUTO_SETUP_INSTALL_SOFTWARE_ID= in dietpi.txt. Then set to state 1 for installation.
1464614646
G_DIETPI-NOTIFY 2 'Checking AUTO_SETUP_INSTALL_SOFTWARE_ID entries'
14647-
while read -r software_id
14647+
# - Pre-v9.10: Support multiple AUTO_SETUP_INSTALL_SOFTWARE_ID lines
14648+
while read -ra software_ids
1464814649
do
14649-
# Skip if software does not exist, is not supported on architecture, hardware model or Debian version
14650-
if [[ ! ${aSOFTWARE_NAME[$software_id]} ]]
14651-
then
14652-
G_DIETPI-NOTIFY 1 "Software title with ID $software_id does not exist. Skipping it."
14653-
14654-
elif (( ! ${aSOFTWARE_AVAIL_G_HW_ARCH[$software_id,$G_HW_ARCH]:=1} ))
14655-
then
14656-
G_DIETPI-NOTIFY 1 "Software title ${aSOFTWARE_NAME[$software_id]} is not supported on $G_HW_ARCH_NAME systems. Skipping it."
14650+
# v9.10: Support multiple IDs per AUTO_SETUP_INSTALL_SOFTWARE_ID line
14651+
for software_id in "${software_ids[@]}"
14652+
do
14653+
# Skip if software does not exist, is not supported on architecture, hardware model or Debian version
14654+
if [[ ! ${aSOFTWARE_NAME[$software_id]} ]]
14655+
then
14656+
G_DIETPI-NOTIFY 1 "Software title with ID $software_id does not exist. Skipping it."
1465714657

14658-
elif (( ! ${aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,$G_HW_MODEL]:=1} ))
14659-
then
14660-
G_DIETPI-NOTIFY 1 "Software title ${aSOFTWARE_NAME[$software_id]} is not supported on $G_HW_MODEL_NAME. Skipping it."
14658+
elif (( ! ${aSOFTWARE_AVAIL_G_HW_ARCH[$software_id,$G_HW_ARCH]:=1} ))
14659+
then
14660+
G_DIETPI-NOTIFY 1 "Software title ${aSOFTWARE_NAME[$software_id]} is not supported on ${RPI_64KERNEL_32OS:-$G_HW_ARCH_NAME} systems. Skipping it."
1466114661

14662-
elif (( ! ${aSOFTWARE_AVAIL_G_DISTRO[$software_id,$G_DISTRO]:=1} )); then
14662+
elif (( ! ${aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,$G_HW_MODEL]:=1} ))
14663+
then
14664+
G_DIETPI-NOTIFY 1 "Software title ${aSOFTWARE_NAME[$software_id]} is not supported on $G_HW_MODEL_NAME. Skipping it."
1466314665

14664-
G_DIETPI-NOTIFY 1 "Software title ${aSOFTWARE_NAME[$software_id]} is not supported on Debian ${G_DISTRO_NAME^}. Skipping it."
14665-
else
14666-
aSOFTWARE_INSTALL_STATE[$software_id]=1
14667-
G_DIETPI-NOTIFY 0 "Software title ${aSOFTWARE_NAME[$software_id]} flagged for installation."
14668-
fi
14666+
elif (( ! ${aSOFTWARE_AVAIL_G_DISTRO[$software_id,$G_DISTRO]:=1} )); then
1466914667

14670-
done < <(grep '^[[:blank:]]*AUTO_SETUP_INSTALL_SOFTWARE_ID=' /boot/dietpi.txt | mawk '{print $1}' | sed 's/[^0-9]*//g')
14668+
G_DIETPI-NOTIFY 1 "Software title ${aSOFTWARE_NAME[$software_id]} is not supported on Debian ${G_DISTRO_NAME^}. Skipping it."
14669+
else
14670+
aSOFTWARE_INSTALL_STATE[$software_id]=1
14671+
G_DIETPI-NOTIFY 0 "Software title ${aSOFTWARE_NAME[$software_id]} flagged for installation."
14672+
fi
14673+
done
14674+
done < <(grep '^[[:blank:]]*AUTO_SETUP_INSTALL_SOFTWARE_ID=' /boot/dietpi.txt | sed -e 's/^[^=]*=//' -e 's/#.*$//')
1467114675
}
1467214676

1467314677
# Setup steps after software installs
@@ -14806,6 +14810,14 @@ _EOF_
1480614810

1480714811
G_DIETPI-NOTIFY 0 'Applied final first run setup steps'
1480814812

14813+
# Process automatic APT package installs
14814+
local packages=() package
14815+
read -ra packages < <($(sed -n '/^[[:blank:]]*AUTO_SETUP_APT_INSTALLS=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)
14816+
for package in "${packages[@]}"
14817+
do
14818+
G_EXEC_NOHALT=1 G_AGI "$package"
14819+
done
14820+
1480914821
# Custom 1st run script
1481014822
[[ $AUTOINSTALL_CUSTOMSCRIPTURL != '0' || -f '/boot/Automation_Custom_Script.sh' ]] || return 0
1481114823

0 commit comments

Comments
 (0)