Skip to content

How to add a new software title

MichaIng edited this page Jun 4, 2021 · 13 revisions

Add menu array entries

Related function: Software_Arrays_Init()

Example:

#------------------ Desktops: LXDE ------------------
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'

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]=1

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

aSOFTWARE_DEPS[$software_id]='5 6'

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):

for ((i=10; i<=$MAX_G_HW_MODEL; i++))
do
	aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,$i]=0
done

Add install code

Related functions: Install_Software()

Example:

software_id=52 # Cuberite
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then

	Banner_Installing

	# x86_64
	if (( $G_HW_ARCH == 10 )); then

		INSTALL_URL_ADDRESS='https://builds.cuberite.org/job/Cuberite%20Linux%20x64%20Master/lastSuccessfulBuild/artifact/Cuberite.tar.gz'

	# 32bit ARM
	elif (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then

		INSTALL_URL_ADDRESS='https://builds.cuberite.org/job/Cuberite%20Linux%20raspi-armhf%20Master/lastSuccessfulBuild/artifact/Cuberite.tar.gz'

	fi

	Download_Install "$INSTALL_URL_ADDRESS" $G_FP_DIETPI_USERDATA/cubrite

	# - Move everything into base directory (cuberite)
	mv $G_FP_DIETPI_USERDATA/cubrite/Server/* $G_FP_DIETPI_USERDATA/cubrite/
	rm -R $G_FP_DIETPI_USERDATA/cubrite/Server

fi
  • software_id needs to match the one chosen above.
  • (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )) checks if the software title is marked for install (=1).
  • Banner_Installing to print an informational banner.
  • INSTALL_URL_ADDRESS is usually used to define a download URL.
  • G_CHECK_URL "$INSTALL_URL_ADDRESS" can be used to check if the URL is actually available.
  • Download_Install "$INSTALL_URL_ADDRESS" includes the URL check, downloads the resource and automatically installs DPKG packages or extracts archives, based on file type.
  • DEPS_LIST='<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 config code

Related function: Configure_Software()

Example:

software_id=80 # Ubooquity
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then

	Banner_Configuration

	useradd -rM ubooquity -G dietpi -s /usr/sbin/nologin

	mkdir -p $G_FP_DIETPI_USERDATA/ebooks $G_FP_DIETPI_USERDATA/comics

	chmod +x $G_FP_DIETPI_USERDATA/ubooquity/Ubooquity.jar
	cat << _EOF_ > /etc/systemd/system/ubooquity.service
[Unit]
Description=Ubooquity (DietPi)
After=dietpi-boot.service network.target

[Service]
User=ubooquity
WorkingDirectory=$G_FP_DIETPI_USERDATA/ubooquity
ExecStart=$(command -v java) -jar $G_FP_DIETPI_USERDATA/ubooquity/Ubooquity.jar --headless --remoteadmin --adminport 2038 --libraryport 2039

[Install]
WantedBy=multi-user.target
_EOF_

fi
  • Similar to install code but used to create run users, set permission, create systemd units and/or adjust program settings, if required.

Add uninstall code

Related function: Uninstall_Software()

Example:

software_id=34 # Subsonic
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then

	Banner_Uninstalling
	G_AGP subsonic
	getent passwd subsonic &> /dev/null && userdel -rf subsonic
	[[ -d /var/subsonic ]] && rm -R /var/subsonic

fi
  • Similar to install/config code but runs when software titles has been selected for uninstall.
  • Purge related APT/DPkg packages, remove manually created run users, files and directories.