diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 17ac3d731..dd7724900 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -382,17 +382,17 @@ Outputs: --cmd SWAG04 - SWAG purge with data folder HomeAutomation - Home Automation for control home appliances --cmd HAB001 - openHAB empowering the smart home - --cmd HAB002 - openHAB remove (http://10.1.0.35:8080) + --cmd HAB002 - openHAB remove (http://10.1.0.216:8080) --cmd HAB003 - openHAB purge with data folder --cmd HAS001 - Home Assistant open source home automation - --cmd HAS002 - Home Assistant remove (http://10.1.0.35:8123) + --cmd HAS002 - Home Assistant remove (http://10.1.0.216:8123) --cmd HAS003 - Home Assistant purge with data folder --cmd DOM001 - Domoticz open source home automation - --cmd DOM002 - Domoticz remove (http://10.1.0.35:8080) + --cmd DOM002 - Domoticz remove (http://10.1.0.216:8080) --cmd DOM003 - Domoticz purge with data folder DNS - Network-wide ad blockers servers --cmd DNS001 - Pi-hole DNS ad blocker - --cmd DNS003 - Pi-hole remove (http://10.1.0.35:80) + --cmd DNS003 - Pi-hole remove (http://10.1.0.216:80) --cmd DNS002 - Pi-hole change web admin password --cmd DNS004 - Pi-hole purge with data folder Music - Music servers and streamers @@ -401,47 +401,47 @@ Outputs: --cmd NAV003 - Navidrome purge with data folder Downloaders - Download apps for movies, TV shows, music and subtitles --cmd DOW001 - qBittorrent BitTorrent client - --cmd DOW002 - qBittorrent remove (http://10.1.0.35:8090) + --cmd DOW002 - qBittorrent remove (http://10.1.0.216:8090) --cmd DOW003 - qBittorrent purge with data folder --cmd DEL001 - Deluge BitTorrent client - --cmd DEL002 - Deluge remove (http://10.1.0.35:8112) + --cmd DEL002 - Deluge remove (http://10.1.0.216:8112) --cmd DEL003 - Deluge purge with data folder --cmd TRA001 - Transmission BitTorrent client - --cmd TRA002 - Transmission remove (http://10.1.0.35:9091) + --cmd TRA002 - Transmission remove (http://10.1.0.216:9091) --cmd TRA003 - Transmission purge with data folder --cmd SABN01 - SABnzbd newsgroup downloader - --cmd SABN02 - SABnzbd remove (http://10.1.0.35:8080) + --cmd SABN02 - SABnzbd remove (http://10.1.0.216:8080) --cmd SABN03 - SABnzbd purge with data folder --cmd MDS001 - Medusa automatic downloader for TV shows - --cmd MDS002 - Medusa TV shows downloader remove (http://10.1.0.35:8081) + --cmd MDS002 - Medusa TV shows downloader remove (http://10.1.0.216:8081) --cmd MDS003 - Medusa TV shows downloader purge --cmd SON001 - Sonarr automatic downloader for TV shows - --cmd SON002 - Sonarr remove (http://10.1.0.35:8989) + --cmd SON002 - Sonarr remove (http://10.1.0.216:8989) --cmd SON003 - Sonarr purge with data folder --cmd RAD001 - Radarr automatic downloader for movies - --cmd RAD002 - Radarr remove (http://10.1.0.35:7878) + --cmd RAD002 - Radarr remove (http://10.1.0.216:7878) --cmd RAD003 - Radarr purge with data folder --cmd BAZ001 - Bazarr automatic subtitles downloader for Sonarr and Radarr - --cmd BAZ002 - Bazarr remove (http://10.1.0.35:6767) + --cmd BAZ002 - Bazarr remove (http://10.1.0.216:6767) --cmd BAZ003 - Bazarr purge with data folder --cmd LID001 - Lidarr automatic music downloader - --cmd LID002 - Lidarr remove (http://10.1.0.35:8686) + --cmd LID002 - Lidarr remove (http://10.1.0.216:8686) --cmd LID003 - Lidarr purge with data folder --cmd RDR001 - Readarr automatic downloader for Ebooks - --cmd RDR002 - Readarr remove (http://10.1.0.35:8787) + --cmd RDR002 - Readarr remove (http://10.1.0.216:8787) --cmd RDR003 - Readarr purge with data folder --cmd DOW025 - Prowlarr index manager and proxy for PVR - --cmd DOW026 - Prowlarr remove (http://10.1.0.35:9696) + --cmd DOW026 - Prowlarr remove (http://10.1.0.216:9696) --cmd DOW027 - Prowlarr purge with data folder --cmd JEL001 - Jellyseerr Jellyfin/Emby/Plex integration install - --cmd JEL002 - Jellyseerr remove (http://10.1.0.35:5055) + --cmd JEL002 - Jellyseerr remove (http://10.1.0.216:5055) --cmd JEL003 - Jellyseerr purge with data folder Database - SQL database servers and web interface managers --cmd DAT001 - Mariadb SQL database server - --cmd DAT002 - Mariadb remove (Server: 10.1.0.35) + --cmd DAT002 - Mariadb remove (Server: 10.1.0.216) --cmd DAT003 - Mariadb purge with data folder --cmd DAT005 - phpMyAdmin web interface manager - --cmd DAT006 - phpMyAdmin remove (http://10.1.0.35:8071) + --cmd DAT006 - phpMyAdmin remove (http://10.1.0.216:8071) --cmd DAT007 - phpMyAdmin purge with data folder DevTools - Applications and tools for development --cmd DEV001 - Install tools for cloning and managing repositories (git) @@ -452,40 +452,40 @@ Outputs: --cmd CON003 - Docker remove --cmd CON004 - Docker purge with all images, containers, and volumes --cmd CON005 - Portainer container management platform - --cmd CON006 - Portainer remove (http://10.1.0.35:9000) + --cmd CON006 - Portainer remove (http://10.1.0.216:9000) --cmd CON007 - Portainer purge with with data folder Media - Media servers, organizers and editors --cmd MED003 - Emby organizes video, music, live TV, and photos - --cmd MED004 - Emby server remove (http://10.1.0.35:8096) + --cmd MED004 - Emby server remove (http://10.1.0.216:8096) --cmd MED005 - Emby server purge with data folder --cmd MED010 - Stirling PDF tools for viewing and editing PDF files - --cmd MED011 - Stirling PDF remove (http://10.1.0.35:8077) + --cmd MED011 - Stirling PDF remove (http://10.1.0.216:8077) --cmd MED012 - Stirling PDF purge with data folder --cmd MED015 - Syncthing continuous file synchronization - --cmd MED016 - Syncthing remove (http://10.1.0.35:8884) + --cmd MED016 - Syncthing remove (http://10.1.0.216:8884) --cmd MED017 - Syncthing purge with data folder --cmd MED020 - Nextcloud content collaboration platform - --cmd MED021 - Nextcloud remove (https://10.1.0.35:443) + --cmd MED021 - Nextcloud remove (https://10.1.0.216:443) --cmd MED022 - Nextcloud purge with data folder --cmd MED025 - Owncloud share files and folders, easy and secure - --cmd MED026 - Owncloud remove (http://10.1.0.35:7787) + --cmd MED026 - Owncloud remove (http://10.1.0.216:7787) --cmd MED027 - Owncloud purge with data folder Monitoring - Real-time monitoring, collecting metrics, up-time status --cmd MON001 - Uptime Kuma self-hosted monitoring tool - --cmd MON002 - Uptime Kuma remove (http://10.1.0.35:3001) + --cmd MON002 - Uptime Kuma remove (http://10.1.0.216:3001) --cmd MON003 - Uptime Kuma purge with data folder --cmd MON005 - Netdata - monitoring real-time metrics - --cmd MON006 - Netdata remove (http://10.1.0.35:19999) + --cmd MON006 - Netdata remove (http://10.1.0.216:19999) --cmd MON007 - Netdata purge with data folder --cmd GRA001 - Grafana data analytics - --cmd GRA002 - Grafana remove (http://10.1.0.35:3000) + --cmd GRA002 - Grafana remove (http://10.1.0.216:3000) --cmd GRA003 - Grafana purge with data folder Management - Remote Management tools - --cmd MAN001 - Cockpit web-based management tool (http://10.1.0.35:9090) + --cmd MAN001 - Cockpit web-based management tool (http://10.1.0.216:9090) --cmd MAN005 - Webmin web-based management tool Printing - Tools for printing and 3D printing --cmd OCT001 - OctoPrint web-based 3D printers management tool - --cmd OCT002 - OctoPrint remove (http://10.1.0.35:7981) + --cmd OCT002 - OctoPrint remove (http://10.1.0.216:7981) --cmd OCT003 - OctoPrint purge with data folder Netconfig - Console network tools for measuring load and bandwidth --cmd NET001 - nload -realtime console network usage monitor @@ -863,6 +863,7 @@ These helper functions facilitate various operations related to job management, | Toggle SSH lastlog | toggle_ssh_lastlog | @Tearran | Generate this markdown table of all module_options | see_function_table_md | @Tearran | Netplan wrapper | simple advanced type stations select store restore dhcp static help | @igorpecovnik +| Exit with error code 1, optionally printing a message to stderr | run_critical_function || die 'The world is about to end' | @dimitry-ishenko | Webmin setup and service setting. | help install remove start stop enable disable status check | @Tearran | Install HA supervised container | install remove purge status help | @igorpecovnik | Display a menu from pipe | show_menu <<< armbianmonitor -h ; | @Tearran @@ -898,7 +899,6 @@ These helper functions facilitate various operations related to job management, | Install zfs filesystem support | install remove status kernel_max zfs_version zfs_installed_version help | @igorpecovnik | Check if package is installed | pkg_installed mc | @dimitry-ishenko | Update submenu descriptions based on conditions | update_submenu_data | @Tearran -| sanitize input cli | sanitize_input | @Tearran | Install openssh-server container | install remove purge status help | @armbian | Upgrade installed packages | pkg_upgrade | @dimitry-ishenko | Install lidarr container | install remove purge status help | @armbian @@ -957,6 +957,7 @@ These helper functions facilitate various operations related to job management, | Install prowlarr container | install remove purge status help | @Prowlarr | Install nfsd server | install remove manage add status clients servers help | @igorpecovnik | Check the internet connection with fallback DNS | see_ping | @Tearran +| Make sure param contains only valid chars | sanitize 'foo_bar_42' | @Tearran | Install docker from a repo using apt | install remove purge status help | @schwar3kat | Upgrade to next stable or rolling release | release_upgrade stable verify | @igorpecovnik | Update the /etc/skel files in users directories | update_skel | @igorpecovnik diff --git a/README.md b/README.md index fee422d3f..a142d4d3b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ GitHub Workflow Status GitHub Workflow Status GitHub Workflow Status

-**armbian-config** provides configuration and installation routines for customizing and automating tasks within Armbian Linux environment. These utilties help streamline setup processes for various use cases. +**armbian-config** provides configuration and installation routines for customizing and automating tasks within Armbian Linux environment. These utilities help streamline setup processes for various use cases. @@ -15,19 +15,19 @@ - **Lightweight**: Minimal dependencies for optimal performance. - **Flexible**: Supports JSON, TUI, CLI, and API interfaces. - **Modern**: A fresh approach to configuration. -- **Low entropy**: Byte clean uninstall for most targets +- **Low entropy**: Byte clean uninstall for most targets. ## Features - **System Configuration**: - - kernel manamenent, headers, hardware tweaks. + - Kernel management, headers, hardware tweaks. - NFS and ZFS storage management. - SSH user access tweaks. - - system updates, rolling / stable, containers update. + - System updates, rolling / stable, containers update. - **Network Management**: - - fixed / dynamic IP configuration. - - connecting to wireless network. - - access point management. + - Fixed / dynamic IP configuration. + - Connecting to wireless network. + - Access point management. - **Localization Settings**: - Configure time zone. - Set language and locales. @@ -61,9 +61,13 @@ Add Armbian key + repository and install the tool: ```bash wget -qO - https://apt.armbian.com/armbian.key | gpg --dearmor | \ sudo tee /usr/share/keyrings/armbian.gpg > /dev/null -echo "deb [signed-by=/usr/share/keyrings/armbian.gpg] \ -https://github.armbian.com/configng stable main" | \ -sudo tee /etc/apt/sources.list.d/armbian-config.list > /dev/null +cat << EOF | sudo tee /etc/apt/sources.list.d/armbian-config.sources > /dev/null +Types: deb +URIs: https://github.armbian.com/configng +Suites: stable +Components: main +Signed-By: /usr/share/keyrings/armbian.gpg +EOF sudo apt update sudo apt -y install armbian-config ``` diff --git a/bin/armbian-config b/bin/armbian-config index 80339d8cb..20ec1b157 100755 --- a/bin/armbian-config +++ b/bin/armbian-config @@ -32,7 +32,7 @@ set_checkpoint start set_checkpoint mark "Initializing script" true [[ -d "$script_dir/../tools" ]] && tools_dir="$script_dir/../tools" -[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && echo -e "Please run\nbash "$tools_dir/config-assemble.sh" to build the lib directory\n" && exit 1 +[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && die -e "Please run\nbash "$tools_dir/config-assemble.sh" to build the lib directory\n" # 'whiptail' is a simple dialog box utility that works well with Bash. It doesn't have all the features of some other dialog box utilities, but it does everything we need for this script. [[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail" @@ -70,8 +70,6 @@ set_checkpoint mark "Loaded Software helpers..." true source "$lib_dir/config.runtime.sh" echo "Loaded Runtime conditions..." true -clear - case "$1" in "--help") if [[ -n "$2" ]]; then diff --git a/debian.conf b/debian.conf index 5d09b11b5..565693cd3 100644 --- a/debian.conf +++ b/debian.conf @@ -1,4 +1,4 @@ lib:/usr/ bin:/usr/ share:/usr/ -tools/repository/armbian-config.list:/etc/apt/sources.list.d/ +tools/repository/armbian-config.sources:/etc/apt/sources.list.d/ diff --git a/tests/CON005.conf b/tests/CON005.conf index 31331da59..0ebb906cb 100644 --- a/tests/CON005.conf +++ b/tests/CON005.conf @@ -1,8 +1,8 @@ ENABLED=true RELEASE="bookworm:noble" -function testcase { - ./bin/armbian-config --api module_portainer remove +testcase() {( + set -e + ./bin/armbian-config --api module_portainer install ./bin/armbian-config --api module_portainer status - echo $? -} +)} diff --git a/tests/DAT001.conf b/tests/DAT001.conf index 478655ea4..58f13f49e 100644 --- a/tests/DAT001.conf +++ b/tests/DAT001.conf @@ -1,7 +1,8 @@ ENABLED=false -function testcase { +testcase() {( + set -e ./bin/armbian-config --api module_mariadb install ./bin/armbian-config --api module_mariadb status docker container ls -a -} +)} diff --git a/tests/HAB001.conf b/tests/HAB001.conf index 3825313c1..7be416748 100644 --- a/tests/HAB001.conf +++ b/tests/HAB001.conf @@ -1,7 +1,8 @@ ENABLED=true RELEASE="bookworm" -function testcase { +function testcase {( + set -e ./bin/armbian-config --api module_openhab install systemctl is-active --quiet openhab.service -} +)} diff --git a/tests/HAS001.conf b/tests/HAS001.conf index ca200ad91..8469dec2d 100644 --- a/tests/HAS001.conf +++ b/tests/HAS001.conf @@ -1,6 +1,8 @@ ENABLED=false RELEASE="bookworm" -function testcase { +testcase() {( + set -e ./bin/armbian-config --api module_haos install -} + ./bin/armbian-config --api module_haos status +)} diff --git a/tests/MAN001.conf b/tests/MAN001.conf index a7bbbe90b..578cfd0af 100644 --- a/tests/MAN001.conf +++ b/tests/MAN001.conf @@ -1,9 +1,9 @@ ENABLED=true RELEASE="bookworm:noble" # run on specific or leave empty to run on all -function testcase { - ./bin/armbian-config --api module_cockpit remove +testcase() {( + set -e + ./bin/armbian-config --api module_cockpit remove || true ./bin/armbian-config --api module_cockpit install - [ -f /usr/bin/cockpit-bridge ] -} - + [[ -f /usr/bin/cockpit-bridge ]] +)} diff --git a/tests/MON001.conf b/tests/MON001.conf index 92b1f676e..ff7959cab 100644 --- a/tests/MON001.conf +++ b/tests/MON001.conf @@ -1,10 +1,11 @@ ENABLED=true RELEASE="bookworm:noble" -function testcase { - ./bin/armbian-config --api module_uptimekuma remove +testcase() {( + set -e + ./bin/armbian-config --api module_uptimekuma remove || true ./bin/armbian-config --api module_uptimekuma install ./bin/armbian-config --api module_uptimekuma status ./bin/armbian-config --api module_uptimekuma remove - ./bin/armbian-config --api module_uptimekuma status -} + ! ./bin/armbian-config --api module_uptimekuma status +)} diff --git a/tests/NAV001.conf b/tests/NAV001.conf index 22180852d..a3d9d4d15 100644 --- a/tests/NAV001.conf +++ b/tests/NAV001.conf @@ -1,11 +1,10 @@ ENABLED=true RELEASE="bookworm:noble" -function testcase { +testcase() {( + set -e ./bin/armbian-config --api module_navidrome remove ./bin/armbian-config --api module_navidrome install container=$(docker container ls -a | mawk '/navidrome?( |$)/{print $1}') - if [[ -z "${container}" ]]; then - exit 1 - fi -} + [[ -n "$container" ]] +)} diff --git a/tests/README.md b/tests/README.md index d35c10654..dacc30bdc 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,6 +1,6 @@ # Unit tests -If function testcase returns 0, test is succesful. Put the code there. +If the function `testcase()` returns 0, the test is succesful. Put the code there. - name of the the file is function ID.conf - ENABLED=false|true @@ -8,12 +8,29 @@ If function testcase returns 0, test is succesful. Put the code there. Example: -``` +```sh ENABLED=true RELEASE="bookworm:noble" -function testcase { - ./bin/armbian-config --api module_cockpit install - [ -f /usr/bin/cockpit-bridge ] +testcase() { + ./bin/armbian-config --api module_cockpit install + [ -f /usr/bin/cockpit-bridge ] } ``` + +If you have multiple test conditions inside `testcase()` and you want the test +to exit on the first failed statement, you can use the following technique: + +```sh +testcase() {( + set -e + ./bin/armbian-config --api pkg_install neovim + ./bin/armbian-config --api pkg_installed neovim + ./bin/armbian-config --api pkg_remove neovim + ! ./bin/armbian-config --api pkg_installed neovim +)} +``` + +Note the additional pair of `()` and the `set -e` command inside function body. +These will cause test conditions to run inside a subshell with the -e option +enabled (exit immediately if a pipeline returns non-zero status). diff --git a/tools/modules/functions/config_interface.sh b/tools/modules/functions/config_interface.sh index 4fd2e2052..003f75b7f 100644 --- a/tools/modules/functions/config_interface.sh +++ b/tools/modules/functions/config_interface.sh @@ -489,27 +489,27 @@ see_current_apt() { fi } +module_options+=( + ["sanitize,author"]="@Tearran" + ["sanitize,desc"]="Make sure param contains only valid chars" + ["sanitize,example"]="sanitize 'foo_bar_42'" + ["sanitize,feature"]="sanitize" + ["sanitize,status"]="Interface" +) + +sanitize() { + [[ "$1" =~ ^[a-zA-Z0-9_=]+$ ]] && echo "$1" || die "Invalid argument: $1" +} module_options+=( - ["sanitize_input,author"]="@Tearran" - ["sanitize_input,ref_link"]="" - ["sanitize_input,feature"]="sanitize_input" - ["sanitize_input,desc"]="sanitize input cli" - ["sanitize_input,example"]="sanitize_input" - ["sanitize_input,status"]="Review" + ["die,author"]="@dimitry-ishenko" + ["die,desc"]="Exit with error code 1, optionally printing a message to stderr" + ["die,example"]="run_critical_function || die 'The world is about to end'" + ["die,feature"]="die" + ["die,status"]="Interface" ) -# -# sanitize input cli -# -sanitize_input() { - local sanitized_input=() - for arg in "$@"; do - if [[ $arg =~ ^[a-zA-Z0-9_=]+$ ]]; then - sanitized_input+=("$arg") - else - echo "Invalid argument: $arg" - exit 1 - fi - done - echo "${sanitized_input[@]}" + +die() { + (( $# )) && echo "$@" >&2 + exit 1 } diff --git a/tools/modules/network/module_network_simple.sh b/tools/modules/network/module_network_simple.sh index 2ab067ddc..1c6d55f15 100644 --- a/tools/modules/network/module_network_simple.sh +++ b/tools/modules/network/module_network_simple.sh @@ -235,7 +235,7 @@ function module_simple_network() { $((${#list[@]}/2 + 10 )) 50 $((${#list[@]}/2 + 1)) "${list[@]}" 3>&1 1>&2 2>&3) if [[ $? -eq 0 ]]; then if $DIALOG --title "Action for ${adapter}" --yes-button "Configure" --no-button "Drop" --yesno "$1" 5 60; then - : + ip link set ${adapter} up else sed -i -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' \ -e 's/.*//;x;/'${adapter}'/{s/^\( *\).*/ \1/;x;d;}' /etc/netplan/${yamlfile}.yaml diff --git a/tools/modules/system/module_zfs.sh b/tools/modules/system/module_zfs.sh index 1d7c26e95..39b0b2ca0 100644 --- a/tools/modules/system/module_zfs.sh +++ b/tools/modules/system/module_zfs.sh @@ -5,7 +5,7 @@ module_options+=( ["module_zfs,example"]="install remove status kernel_max zfs_version zfs_installed_version help" ["module_zfs,port"]="" ["module_zfs,status"]="Active" - ["module_zfs,arch"]="" + ["module_zfs,arch"]="x86-64 arm64" ) # # Module OpenZFS diff --git a/tools/repository/armbian-config.list b/tools/repository/armbian-config.list deleted file mode 100644 index eb01b105f..000000000 --- a/tools/repository/armbian-config.list +++ /dev/null @@ -1 +0,0 @@ -deb [signed-by=/usr/share/keyrings/armbian.gpg] https://github.armbian.com/configng stable main diff --git a/tools/repository/armbian-config.sources b/tools/repository/armbian-config.sources new file mode 100644 index 000000000..32d0b34c7 --- /dev/null +++ b/tools/repository/armbian-config.sources @@ -0,0 +1,5 @@ +Types: deb +URIs: https://github.armbian.com/configng +Suites: stable +Components: main +Signed-By: /usr/share/keyrings/armbian.gpg