#!/bin/bash # Initial release date: October 2022 # Authors: @mativ00 & @sudoalx on Telegram # Description: This bash script was created to automate the installation of images hosted on labhub.eu.org # Version: 5.0.0-main # Last Updated: 2026-08-21 # Default ishare2 configuration: this configuration will be overwritten when defined in the configuration file. USE_ARIA2C=false # Set to true to use aria2c for faster downloads. Set to false to use wget instead. SSL_CHECK="true" # Set to true to check SSL certificate. Set to false to disable SSL certificate check. CHANNEL="main" # Set to main to use the stable channel or dev for development builds. JSON_URL=${MIRRORS[0]} # Set to the default mirror AUTO_FIX_PERMISSIONS=false # Set to true to automatically fix image permissions after downloading. # End of ishare2 configuration # Initialize variables ISHARE2_DIR="/opt/ishare2/cli" # ishare2 directory # Log file. Prefer the standard /var/log when available and writable, otherwise # fall back to the ishare2 state directory. Override with ISHARE2_LOG_FILE. if [[ -n "${ISHARE2_LOG_FILE:-}" ]]; then LOG_FILE="$ISHARE2_LOG_FILE" elif [[ -d /var/log && -w /var/log ]]; then LOG_FILE="/var/log/ishare2.log" else LOG_FILE="$ISHARE2_DIR/ishare2.log" fi TEMP_JSON="$ISHARE2_DIR/labhub.json" # Temporary JSON file VERSION="5.0.0-main" # Current version of ishare2 SOURCES_URL="https://raw.githubusercontent.com/ishare2-org/ishare2-cli/$CHANNEL/sources.list" # Sources.list URL MOTD_FILE="$ISHARE2_DIR/motd.json" # MOTD file REMOTE_MOTD_URL="https://raw.githubusercontent.com/ishare2-org/ishare2-cli/$CHANNEL/motd.json" # Remote MOTD URL # Colors RED='\033[31m' YELLOW='\033[1;33m' GREEN='\033[32m' BLUE='\033[34m' NO_COLOR='\033[0m' # Script name SCR_NAME_EXEC=$0 SCR_NAME_EXEC_FP=$(realpath "$0") SCR_NAME=$(basename "$SCR_NAME_EXEC") SCR_NAME=${SCR_NAME%.*} # Configuration file and drop-in directory ISHARE2_CONF_FILE=/etc/ishare2.conf ISHARE2_CONF_DIR=/etc/ishare2.d ISHARE2_SCRIPT_DIR=$(dirname "$SCR_NAME_EXEC_FP") ISHARE2_MODULES=( logger.sh sources.sh motd.sh ui.sh config.sh downloads.sh auth.sh labs.sh docker.sh upgrade_gui.sh search.sh license.sh help.sh qemu_handlers.sh pull.sh logs.sh maintenance.sh selector.sh ) if [[ -z "$ISHARE2_LIB_DIR" ]]; then if [[ -d "$ISHARE2_SCRIPT_DIR/lib" ]]; then ISHARE2_LIB_DIR="$ISHARE2_SCRIPT_DIR/lib" else ISHARE2_LIB_DIR="$ISHARE2_DIR/lib" fi fi source_ishare2_module() { local module=$1 local module_path="$ISHARE2_LIB_DIR/$module" if [[ ! -f "$module_path" ]]; then echo -e "${RED}[-] Missing ishare2 module: $module_path${NO_COLOR}" >&2 exit 1 fi # shellcheck source=/dev/null source "$module_path" } for module in "${ISHARE2_MODULES[@]}"; do source_ishare2_module "$module" done main() { if [[ "$1" = "test" ]]; then # Tests without checking if user is root connection_tests exit 0 fi check_user_is_root check_ishare2_dir check_config "$1" ishare2_sources ishare2_version check_updates check_motd set_max_log_lines selector "$1" "$2" "$3" "$4" } main "$@"