Skip to content

How to add a new software title

MichaIng edited this page Aug 10, 2019 · 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_TYPE[$software_id]=0
aSOFTWARE_CATEGORY_INDEX[$software_id]=0
aSOFTWARE_ONLINEDOC_URL[$software_id]='p=42#p42'
aSOFTWARE_REQUIRES_ALSA[$software_id]=1
aSOFTWARE_REQUIRES_XSERVERXORG[$software_id]=1

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_TYPE[$software_id]

Choose if/where the software is listed. "0" will be listed in the "Software Optimised" menu. "1" will be listed in the "Software Additional" menu. Choose "-1" if the software should be not listed in any menu, e.g. if it shall be only pulled as dependency, via choice- or preference system.

aSOFTWARE_CATEGORY_INDEX[$software_id]

Choose a category under which the software title should be listed in the menu. This depends on aSOFTWARE_TYPE "0" or "1". See the aSOFTWARE_CATEGORIES_DIETPI (TYPE=0) and aSOFTWARE_CATEGORIES_LINUX (TYPE=1) arrays in the current DietPi-Software script for available categories.

aSOFTWARE_ONLINEDOC_URL[$software_id]

Every software title should have it's documentation page in the DietPi forum: https://dietpi.com/phpbb/viewtopic.php?p=5#p5 Add the URI arguments of the post as string to this array entry: 'p=<post_id>#p<post_id>' The <post_id> can be found as very last integer of the URI, when selecting the post in your web browser.

aSOFTWARE_REQUIRES_XXXX[$software_id]=1

Add required software titles to be install priorly. Currently available:

aSOFTWARE_REQUIRES_ALSA
aSOFTWARE_REQUIRES_XSERVERXORG
aSOFTWARE_REQUIRES_DESKTOP
aSOFTWARE_REQUIRES_RSYSLOG
aSOFTWARE_REQUIRES_FFMPEG
aSOFTWARE_REQUIRES_JAVA_JRE_JDK
aSOFTWARE_REQUIRES_NODEJS
aSOFTWARE_REQUIRES_BUILDESSENTIAL
aSOFTWARE_REQUIRES_GIT
aSOFTWARE_REQUIRES_WEBSERVER
aSOFTWARE_REQUIRES_PHP
aSOFTWARE_REQUIRES_MYSQL
aSOFTWARE_REQUIRES_SQLITE

For more specific dependencies add a custom entry to the function: Install_Flag_Prereq_Software()

aSOFTWARE_REQUIRES_USERINPUT[$software_id]=1

Define if the installation process requires manual 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_Dietpi_Software() and Install_Linux_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: Install_Apply_Configs()

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.