How to add a new software title - MichaIng/DietPi GitHub Wiki

Add menu array entries

Related function: Software_Arrays_Init()

Example:

software_id=23
aSOFTWARE_NAME[$software_id]='LXDE'
aSOFTWARE_DESC[$software_id]='ultra lightweight desktop'
aSOFTWARE_CATX[$software_id]=0
aSOFTWARE_DOCS[$software_id]='https://dietpi.com/docs/software/desktop/#lxde'
aSOFTWARE_DEPS[$software_id]='5 6 browser'

software_id

Choose a free unique software ID. On a current DietPi system run dietpi-software free to list currently unused IDs. Run dietpi-software list to list all software titles with their ID.

aSOFTWARE_NAME[$software_id]

Add the name to be displayed in the DietPi-Software install menu.

aSOFTWARE_DESC[$software_id]

Add a short description to be displayed next to the software name.

aSOFTWARE_CATX[$software_id]

Choose a category under which the software title should be listed in the menu. See the aSOFTWARE_CATEGORIES array in the current DietPi-Software script for available categories.

aSOFTWARE_DOCS[$software_id]

Every software title should have it's documentation page: https://dietpi.com/docs/software/ It can be added via our DietPi-Docs repository: https://github.com/MichaIng/DietPi-Docs Include the full URL that points to the documentation, including the header anchor (e.g. #lxde).

aSOFTWARE_DEPS[$software_id]

Add software titles that need to be installed as dependency, as space-separated list of software IDs. This example will install ALSA (ID: 5), X.Org X server (ID: 6), and offers users a choice for installing a web browser, as usual dependencies for any desktop:

aSOFTWARE_DEPS[$software_id]='5 6 browser'

aSOFTWARE_INTERACTIVE[$software_id]=1

Define if the installation process requires interactive user input, e.g. when some choice needs to be made or an external installer requires such. By this the software title will never be installed automated when chosen for first run install (DietPi-Automation) or if no input terminal is available.

Disable install option for certain CPU architectures, Debian versions or hardware models

aSOFTWARE_AVAIL_G_HW_ARCH[$software_id,$i]=0
aSOFTWARE_AVAIL_G_DISTRO[$software_id,$i]=0
aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,$i]=0

$i needs to be the related index, identifying the architecture, distro version or hardware model respectively. The following script shows the related indices: https://github.com/MichaIng/DietPi/blob/dev/dietpi/func/dietpi-obtain_hw_model

E.g. to disable the install option for all non-RPi (0-9 are reserved for RPi):

(( $G_HW_MODEL > 9 )) && aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,$G_HW_MODEL]=0

Add install code

Related functions: Install_Software()

Example:

if To_Install 41 emby-server # Emby Server
then
	case $G_HW_ARCH in
		2) local arch='armhf';;
		3) local arch='arm64';;
		*) local arch='amd64';;
	esac

	local fallback_url="https://github.com/MediaBrowser/Emby.Releases/releases/download/4.7.10.0/emby-server-deb_4.7.10.0_$arch.deb"
	Download_Install "$(curl -sSfL 'https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest' | mawk -F\" "/\"browser_download_url\": .*\/emby-server-deb_[^\"\/]*_$arch\.deb\"/{print \$4}")"
	G_EXEC systemctl stop emby-server

	# User: The DEB package install overrides this, hence the method needs to be changed when using an APT repository!
	Create_User -g dietpi -G emby,video,render -d /var/lib/emby emby

	Download_Test_Media
fi
  • The first argument passed to To_Install needs to match the software_id chosen above.
  • The second argument is optional and the software's service name. This is used to unmask the service before starting the installation and to enable it after all installs have finished. These are often only failsafe steps since usually the service is not masked and enabled automatically when installed via DEB package.
  • G_CHECK_URL "$INSTALL_URL_ADDRESS" can be used to check if the URL is actually available.
  • Download_Install "<URL>" includes the URL check, downloads the resource and automatically installs DEB packages or extracts archives, based on file type.
  • aDEPS=('<pkg_name1>' '<pkg_name2>' ...) can be used to have APT packages installed in parallel to the resource download, if required. This has to be defined prior to Download_Install call to be handled.
  • See the comments above the Download_Install() function declaration for more details.

Add uninstall code

Related function: Uninstall_Software()

Example:

if To_Uninstall 52 # Cuberite
then
	Remove_Service cuberite 1 1 # removes the "cuberite.service" ($1), a user ($2) and a group ($3) with the same name
	[[ -d '/mnt/dietpi_userdata/cuberite' ]] && G_EXEC rm -R /mnt/dietpi_userdata/cuberite
fi
  • Similar to install/config code but runs when software the title has been selected for uninstall.
  • Purge related APT/DEB packages, remove created services, users, files and directories.
  • The Remove_Service function is a shortcut for removing any systemd and init.d service given by the first argument. The second argument is an optional username which shall be removed, or 1 if it matches the service name. The 3rd argument is an optional group name to remove, or 1 if it matches the service name.
⚠️ **GitHub.com Fallback** ⚠️