|
Parsing dietpi-survey
|
AST not printed.
|
|
Parsing dietpi-morsecode
|
AST not printed.
|
|
Parsing dietpi-cpuinfo
|
AST not printed.
|
|
Parsing dietpi-cpu_set
|
AST not printed.
|
|
Parsing dietpi-obtain_hw_model
|
AST not printed.
|
|
Parsing dietpi-drive_manager
|
AST not printed.
|
|
Parsing dietpi-cloudshell
|
AST not printed.
|
|
Parsing dietpi-process_tool
|
AST not printed.
|
|
Parsing dietpi-bugreport
|
AST not printed.
|
|
Parsing dietpi-services
|
AST not printed.
|
|
Parsing dietpi-backup
|
AST not printed.
|
|
Parsing dietpi-logclear
|
AST not printed.
|
|
Parsing dietpi-sync
|
AST not printed.
|
|
Parsing dietpi-cleaner
|
AST not printed.
|
|
Parsing dietpi-launcher
|
AST not printed.
|
|
Parsing dietpi-banner
|
AST not printed.
|
|
Parsing dietpi-update
|
AST not printed.
|
|
Parsing dietpi-software
|
G_DIETPI-NOTIFY 2 "Setting Keyboard $AUTOINSTALL_KEYBOARD. Please wait...\n"
sed -i '/XKBLAYOUT=/c XKBLAYOUT="'"$AUTOINSTALL_KEYBOARD"'"' /etc/default/keyboard
#systemctl restart keyboard-setup
fi
#Apply & Mount Network drives if installed
if (( ${aSOFTWARE_INSTALL_STATE[1]} == 2 )); then
/DietPi/dietpi/func/dietpi-set_smbclient 1
fi
if (( ${aSOFTWARE_INSTALL_STATE[2]} == 2 )); then
/DietPi/dietpi/func/dietpi-set_curlftpfs 1
fi
#Custom 1st run Script (Local file)
local run_custom_script=0
if [ -f /boot/Automation_Custom_Script.sh ]; then
INSTALL_DESCRIPTION='Automation - Local Custom Script'
Banner_Installing
cp /boot/Automation_Custom_Script.sh /root/AUTO_CustomScript.sh
run_custom_script=1
#Custom 1st run Script (Online file)
elif [ "$AUTOINSTALL_CUSTOMSCRIPTURL" != "0" ]; then
INSTALL_DESCRIPTION='Automation - Online Custom Script'
Banner_Installing
INSTALL_URL_ADDRESS=$AUTOINSTALL_CUSTOMSCRIPTURL
G_CHECK_URL "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
#Get script and execute
wget "$INSTALL_URL_ADDRESS" -O /root/AUTO_CustomScript.sh
run_custom_script=1
else
echo -e "Automated Custom Script URL Error:\n $AUTOINSTALL_CUSTOMSCRIPTURL is offline and/or unreachable" >> "$FP_DIETPIAUTOMATION_LOG"
fi
fi
if (( $run_custom_script )); then
chmod +x /root/AUTO_CustomScript.sh
/root/AUTO_CustomScript.sh
local result=$?
if (( $result == 0 )); then
echo -e "Automated custom script executed succesfully:\n - Filepath = /root/AUTO_CustomScript.sh\n - URL = $AUTOINSTALL_CUSTOMSCRIPTURL" >> "$FP_DIETPIAUTOMATION_LOG"
else
echo -e "Automated Custom Script Error:\n - Exit code = $result\n - Filepath = /root/AUTO_CustomScript.sh\n - URL = $AUTOINSTALL_CUSTOMSCRIPTURL" >> "$FP_DIETPIAUTOMATION_LOG"
fi
fi
#Apply AutoStart
/DietPi/dietpi/dietpi-autostart $AUTOINSTALL_AUTOSTARTTARGET
fi
#Set Install Stage to Finished
echo 1 > /DietPi/dietpi/.install_stage
}
#/////////////////////////////////////////////////////////////////////////////////////
# First Run / Automation functions Vars (eg: on a fresh install)
#/////////////////////////////////////////////////////////////////////////////////////
AUTOINSTALL_ENABLED=0
AUTOINSTALL_SSHINDEX=0
AUTOINSTALL_FILESERVERINDEX=0
AUTOINSTALL_LOGGINGINDEX=0
AUTOINSTALL_WEBSERVERINDEX=0
AUTOINSTALL_AUTOSTARTTARGET=0
AUTOINSTALL_TIMEZONE=0
AUTOINSTALL_LANGUAGE=0
AUTOINSTALL_KEYBOARD=0
AUTOINSTALL_CUSTOMSCRIPTURL=0
FirstRun_Automation_Init(){
#Get settings
AUTOINSTALL_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_AUTOMATED=' | sed 's/.*=//')
AUTOINSTALL_AUTOSTARTTARGET=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_AUTOSTART_TARGET_INDEX=' | sed 's/.*=//' )
AUTOINSTALL_SSHINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_SSH_SERVER_INDEX=' | sed 's/.*=//')
AUTOINSTALL_FILESERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_FILE_SERVER_INDEX=' | sed 's/.*=//')
AUTOINSTALL_LOGGINGINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_LOGGING_INDEX=' | sed 's/.*=//')
AUTOINSTALL_WEBSERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_WEB_SERVER_INDEX=' | sed 's/.*=//')
AUTOINSTALL_TIMEZONE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_TIMEZONE=' | sed 's/.*=//' )
AUTOINSTALL_LANGUAGE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_LOCALE=' | sed 's/.*=//' )
AUTOINSTALL_KEYBOARD=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_KEYBOARD_LAYOUT=' | sed 's/.*=//' )
AUTOINSTALL_CUSTOMSCRIPTURL=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_CUSTOM_SCRIPT_EXEC=' | sed 's/AUTO_SETUP_CUSTOM_SCRIPT_EXEC=//')
}
FirstRun_Automation_Set(){
#Automated install
if (( $AUTOINSTALL_ENABLED >= 1 )); then
G_DIETPI-NOTIFY 3 DietPi-Software "Running automated installation"
#Skip dietpi-software menu
TARGETMENUID=-1
#Set start install
GOSTARTINSTALL=1
#Find all software entires of AUTO_SETUP_INSTALL_SOFTWARE_ID= in dietpi.txt. Then set to state 1 for installation.
while read -r line
do
local index=$( echo -e "$line" | grep '^AUTO_SETUP_INSTALL_SOFTWARE_ID=' | sed 's/[^0-9]*//g' )
# - Flag for installation
if [[ $index =~ ^-?[0-9]+$ ]]; then
aSOFTWARE_INSTALL_STATE[$index]=1
G_DIETPI-NOTIFY 2 "Automation: ${aSOFTWARE_WHIP_NAME[$index]}. Flagged for installation."
fi
done < /DietPi/dietpi.txt
fi
#Further Automated options. (Applied regardless of AUTOINSTALL_ENABLED)
INDEX_SSHSERVER_TARGET=$AUTOINSTALL_SSHINDEX
INDEX_FILESERVER_TARGET=$AUTOINSTALL_FILESERVERINDEX
INDEX_LOGGING_TARGET=$AUTOINSTALL_LOGGINGINDEX
INDEX_WEBSERVER_TARGET=$AUTOINSTALL_WEBSERVERINDEX
# - IPversion preference: https://github.com/Fourdee/DietPi/issues/472
/DietPi/dietpi/func/dietpi-set_hardware preferipversion "$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PREFER_IPVERSION=' | sed 's/.*=//')"
}
FirstRun_DietPi_Update(){
#Disable powersaving on main screen
setterm -blank 0 -powersave off 2> /dev/null
#-1 = 1st run | 0 = Reboot, updates applied | 1 = Idle, No updates
#Update .update_stage file to completed
echo 1 > /DietPi/dietpi/.update_stage
#Update APT
G_AGUP
#Check for updates and apply if needed (1=force apply updates).
/DietPi/dietpi/dietpi-update 1
#Check update stage file again (dietpi-update will set to 0 if an update was applied and requires a reboot)
if (( $(cat /DietPi/dietpi/.update_stage) == 0 )); then
#Update .update_stage file to completed
echo 1 > /DietPi/dietpi/.update_stage
#Prompt user for reboot
if (( $G_USER_INPUTS )); then
WHIP_TITLE='DietPi Update Completed'
whiptail --title "$WHIP_TITLE" --msgbox "DietPi has been updated to the latest version.\nYour system will now reboot. Once completed, simply login to resume DietPi Setup. \n\nPress Enter to Continue." 13 65
fi
#Reboot required NOW
reboot
Exit_Destroy
fi
}
#/////////////////////////////////////////////////////////////////////////////////////
# Internet Connection Test Vars
#/////////////////////////////////////////////////////////////////////////////////////
#Use /etc/apt/sources.list for connection test
INTERNET_URL_TEST=$(grep -m1 'deb ' /etc/apt/sources.list | awk '{print $2}')
Check_Internet_Connection(){
G_CHECK_URL "$INTERNET_URL_TEST" #will exit on failure here
}
#/////////////////////////////////////////////////////////////////////////////////////
# Globals
#/////////////////////////////////////////////////////////////////////////////////////
Input_Modes(){
# - Skip menu
TARGETMENUID=-1
DISABLE_REBOOT=1
local ainput=("$@")
#Install software and exit.
if [ "$1" = "install" ] || [ "$1" = "reinstall" ] || [ "$1" = "uninstall" ] ; then
G_DIETPI-NOTIFY 3 DietPi-Software "Automated $1"
sleep 1
# - Make sure we have at least one entry
if [ -z "$2" ]; then
G_DIETPI-NOTIFY 1 "Please enter a software index ID, or, choice system INDEX_*_TARGET=-?"
else
# - Uninstall | Stop services prior
if [ "$1" = "uninstall" ]; then
# - stop services
/DietPi/dietpi/dietpi-services stop
fi
# - Process inputs
for i in "${ainput[@]}"
do
#Valid int means input is unique ID for software index to be installed
if [[ $i =~ ^-?[0-9]+$ ]]; then
if [ "$1" = "uninstall" ]; then
Uninstall_Software "$i"
elif [ "$1" = "reinstall" ]; then
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 2 )); then
# - We cant uninstall, may remove additional packages. eg: remove Xserver = Remove every Xserver depandant program like Kodi.
#Uninstall_Software $i
# - So lets flag to be installed
aSOFTWARE_INSTALL_STATE[$i]=1
GOSTARTINSTALL=1
G_DIETPI-NOTIFY 0 "Reinstalling ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}"
sleep 1
else
G_DIETPI-NOTIFY 2 "$i: ${aSOFTWARE_WHIP_NAME[$i]} is not currently installed"
G_DIETPI-NOTIFY 2 "The program must be installed, before reinstall can be used"
G_DIETPI-NOTIFY 0 "No changes applied for: ${aSOFTWARE_WHIP_NAME[$i]}"
fi
elif [ "$1" = "install" ]; then
if (( ${aSOFTWARE_INSTALL_STATE[$i]} != 2 )); then
aSOFTWARE_INSTALL_STATE[$i]=1
GOSTARTINSTALL=1
G_DIETPI-NOTIFY 0 "Installing ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}"
sleep 0.5
else
G_DIETPI-NOTIFY 2 "$i: ${aSOFTWARE_WHIP_NAME[$i]} is already installed"
G_DIETPI-NOTIFY 0 "No changes applied for: ${aSOFTWARE_WHIP_NAME[$i]}"
fi
fi
fi
done
# - Uninstall | Finish up and clear non-required packages
if [ "$1" = "uninstall" ]; then
Uninstall_Software_Finalize
#Save
Write_InstallFileList
# - Start services
/DietPi/dietpi/dietpi-services start
fi
fi
#Apply permissions
elif [ "$1" = "setpermissions" ]; then
Install_Apply_Permissions &> /dev/null
G_DIETPI-NOTIFY 0 "Set permissions completed"
#List unique software names and ID's
elif [ "$1" = "list" ]; then
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
local string=''
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 2 )); then
string="\e[32mID $i | "
else
string="\e[0mID $i | "
fi
string+="=${aSOFTWARE_INSTALL_STATE[$i]} | ${aSOFTWARE_WHIP_NAME[$i]}: \e[90m${aSOFTWARE_WHIP_DESC[$i]}\e[0m |"
if (( ${aSOFTWARE_REQUIRES_ALSA[$i]} == 1 )); then
string+=' +ALSA'
fi
if (( ${aSOFTWARE_REQUIRES_XSERVERXORG[$i]} == 1 )); then
string+=' +XSERVER'
fi
if (( ${aSOFTWARE_REQUIRES_DESKTOP[$i]} == 1 )); then
string+=' +DESKTOP'
fi
if (( ${aSOFTWARE_REQUIRES_RSYSLOG[$i]} == 1 )); then
string+=' +RSYSLOG'
fi
if (( ${aSOFTWARE_REQUIRES_FFMPEG[$i]} == 1 )); then
string+=' +FFMPEG'
fi
if (( ${aSOFTWARE_REQUIRES_ORACLEJAVA[$i]} == 1 )); then
string+=' +ORACLEJAVA'
fi
if (( ${aSOFTWARE_REQUIRES_NODEJS[$i]} == 1 )); then
string+=' +NODEJS'
fi
if (( ${aSOFTWARE_REQUIRES_BUILDESSENTIAL[$i]} == 1 )); then
string+=' +BUILDESSENTIAL'
fi
if (( ${aSOFTWARE_REQUIRES_GIT[$i]} == 1 )); then
string+=' +GIT'
fi
if (( ${aSOFTWARE_REQUIRES_WEBSERVER[$i]} == 1 )); then
string+=' +WEBSERVER'
fi
if (( ${aSOFTWARE_REQUIRES_MYSQL[$i]} == 1 )); then
string+=' +MYSQL'
fi
if (( ${aSOFTWARE_REQUIRES_SQLITE[$i]} == 1 )); then
string+=' +SQLITE'
fi
# - Available for G_HW_ARCH?
if (( ! ${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$G_HW_ARCH]} )); then
string+=" \e[31mDISABLED for G_HW_ARCH\e[0m"
fi
# - Available for G_HW_MODEL?
if (( ! ${aSOFTWARE_AVAIL_G_HW_MODEL[$i,$G_HW_MODEL]} )); then
string+=" \e[31mDISABLED for G_HW_MODEL\e[0m"
fi
# - Online docs
if [ -n "${aSOFTWARE_ONLINEDOC_URL[$i]}" ]; then
string+=" | \e[90m$FP_ONLINEDOC_URL${aSOFTWARE_ONLINEDOC_URL[$i]}\e[0m"
fi
#Convert string to lowercase (easier to | grep stuff)
echo -e "${string,,}" #Much faster than echo -e $(echo -e "$string" | tr '[:upper:]' '[:lower:]')
done
echo -e "Total Software index HARD limit : $TOTAL_SOFTWARE_INDEXS_HARDLIMIT"
echo -e "Total Software index Current : $TOTAL_SOFTWARE_INDEXS"
#List unique software names and ID's
elif [ "$1" = "weblist_export" ]; then
local fp_export_dir='/tmp/dietpi-software/weblist_export'
rm -R "$fp_export_dir"
mkdir -p "$fp_export_dir"
# - Category desc | Remove '─' before saving.
local fp_target="$fp_export_dir/category_dietpi_total"
echo -e "$MAX_SOFTWARE_CATEGORIES_DIETPI" > "$fp_target"
local fp_target="$fp_export_dir/category_linux_total"
echo -e "$MAX_SOFTWARE_CATEGORIES_LINUX" > "$fp_target"
fp_target="$fp_export_dir/category_dietpi_desc"
for ((i=0; i<$MAX_SOFTWARE_CATEGORIES_DIETPI; i++))
do
local output=
echo -e "$( echo ${aSOFTWARE_CATEGORIES_DIETPI[$i]} | sed 's/─//g')" >> "$fp_target"
done
fp_target="$fp_export_dir/category_linux_desc"
for ((i=0; i<$MAX_SOFTWARE_CATEGORIES_LINUX; i++))
do
echo -e "$( echo ${aSOFTWARE_CATEGORIES_LINUX[$i]} | sed 's/─//g')" >> "$fp_target"
done
# - Software list
local fp_target="$fp_export_dir/total_software_index"
echo -e "$TOTAL_SOFTWARE_INDEXS" > "$fp_target"
fp_target="$fp_export_dir/software_installed_state"
printf "%i\n" "${aSOFTWARE_INSTALL_STATE[@]}" > "$fp_target"
fp_target="$fp_export_dir/software_name"
printf "%s\n" "${aSOFTWARE_WHIP_NAME[@]}" > "$fp_target"
fp_target="$fp_export_dir/software_desc"
printf "%s\n" "${aSOFTWARE_WHIP_DESC[@]}" > "$fp_target"
fp_target="$fp_export_dir/category_index"
printf "%i\n" "${aSOFTWARE_CATEGORY_INDEX[@]}" > "$fp_target"
fp_target="$fp_export_dir/software_urldocs"
printf "%s\n" "${aSOFTWARE_ONLINEDOC_URL[@]}" > "$fp_target"
# - Available for device?
fp_target="$fp_export_dir/software_available_hw_model"
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
printf "%i\n" "${aSOFTWARE_AVAIL_G_HW_MODEL[$i,$G_HW_MODEL]}" >> "$fp_target"
done
fp_target="$fp_export_dir/software_available_hw_arch"
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
printf "%i\n" "${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$G_HW_ARCH]}" >> "$fp_target"
done
# - Flagged Prereqs for installation
# fp_target="$fp_export_dir/installs_alsa"
# printf "%s\n" "${aSOFTWARE_REQUIRES_ALSA[@]}" > "$fp_target"
# fp_target="$fp_export_dir/installs_xserver"
# printf "%s\n" "${aSOFTWARE_REQUIRES_XSERVERXORG[@]}" > "$fp_target"
# fp_target="$fp_export_dir/installs_desktop"
# printf "%s\n" "${aSOFTWARE_REQUIRES_DESKTOP[@]}" > "$fp_target"
else
G_DIETPI-NOTIFY 2 "Unknown command $1"
fi
unset ainput
}
Exit_Destroy(){
Software_Arrays_Destroy
exit
}
#/////////////////////////////////////////////////////////////////////////////////////
# Error Functions
#/////////////////////////////////////////////////////////////////////////////////////
ERROR_TEXT=""
Error_Display(){
#Automation | Save to logfile
if (( $G_USER_INPUTS )); then
whiptail --title "Error" --msgbox "$ERROR_TEXT" 18 70
else
echo -e "Error: $ERROR_TEXT" >> "$FP_DIETPIAUTOMATION_LOG"
fi
}
#/////////////////////////////////////////////////////////////////////////////////////
# Whip menus
#/////////////////////////////////////////////////////////////////////////////////////
WHIP_BACKTITLE='DietPi-Software'
WHIP_TITLE=0
WHIP_QUESTION=0
MENU_MAIN_LASTITEM='Help!'
TARGETMENUID=0
Menu_CreateSoftwareList(){
#software type for this menu
local software_type=$1 #0=dietpi 1=linux
local max_categories=$MAX_SOFTWARE_CATEGORIES_DIETPI
if (( $1 == 1 )); then
max_categories=$MAX_SOFTWARE_CATEGORIES_LINUX
fi
#-----------------------------------------------------------------------------
#Generate Whiptail menu list based on category
local whiptail_list=()
for ((i=0; i<$max_categories; i++))
do
#Only add the category if we have software for it.
local category_enabled=0
#Now run through all available software
for ((j=0; j<$TOTAL_SOFTWARE_INDEXS; j++))
do
#Check if this software matches the current category and sofware type for this menu.
# - I originally had "aSOFTWARE_AVAIL_G_HW_MODEL" and "aSOFTWARE_AVAIL_G_HW_ARCH" in one 'if' statement below, however, this seems to takes 4x longer to process in bash.
if (( ${aSOFTWARE_CATEGORY_INDEX[$j]} == $i && ${aSOFTWARE_TYPE[$j]} == $software_type )); then
# + is available for hardware?
# + is available for distro?
if (( ${aSOFTWARE_AVAIL_G_HW_MODEL[$j,$G_HW_MODEL]} &&
${aSOFTWARE_AVAIL_G_HW_ARCH[$j,$G_HW_ARCH]} )); then
local selected="off"
if (( ${aSOFTWARE_INSTALL_STATE[$j]} > 0 )); then
selected="on"
if (( ${aSOFTWARE_INSTALL_STATE[$j]} == 1 )); then
#Reset to 0. Menu checklists will apply back to 1
aSOFTWARE_INSTALL_STATE[$j]=0
fi
fi
#Add category
if (( $category_enabled == 0 )); then
# - dietpi
if (( $1 == 0 )); then
whiptail_list+=("" "${aSOFTWARE_CATEGORIES_DIETPI[$i]}" "off")
# - linux
elif (( $1 == 1 )); then
whiptail_list+=("" "${aSOFTWARE_CATEGORIES_LINUX[$i]}" "off")
fi
category_enabled=1
fi
#Add this option to whiptail list
whiptail_list+=("$j" "${aSOFTWARE_WHIP_NAME[$j]}: ${aSOFTWARE_WHIP_DESC[$j]}" "$selected")
fi
fi
done
done
#-----------------------------------------------------------------------------
WHIP_TITLE='DietPi Software Selection'
whiptail --title "$WHIP_TITLE" --checklist --separate-output "Please use the spacebar to select the software you wish to install.\nSoftware details: http://dietpi.com/software" --backtitle "$WHIP_BACKTITLE" 22 78 14 "${whiptail_list[@]}" 2>/tmp/dietpi-software_results
#delete[]
unset whiptail_list
#Reset Choices made flag
# - dietpi
if (( $1 == 0 )); then
INSTALL_DIETPI_CHOICESMADE=0
# - linux
elif (( $1 == 1 )); then
INSTALL_LINUX_CHOICESMADE=0
fi
#Check for matching results (selected items)
while read choice
do
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
#enable
if (( $choice == $i &&
${aSOFTWARE_INSTALL_STATE[$i]} == 0 )); then
# - dietpi
if (( $1 == 0 )); then
INSTALL_DIETPI_CHOICESMADE=1
# - linux
elif (( $1 == 1 )); then
INSTALL_LINUX_CHOICESMADE=1
fi
aSOFTWARE_INSTALL_STATE[$i]=1
break
fi
done
done < /tmp/dietpi-software_results
rm /tmp/dietpi-software_results &> /dev/null
}
Menu_Main(){
#Data for storing SSH server index info
local index_sshserver_text="None"
if (( $INDEX_SSHSERVER_TARGET == -1 )); then
index_sshserver_text="Dropbear"
elif (( $INDEX_SSHSERVER_TARGET == -2 )); then
index_sshserver_text="OpenSSH"
fi
#Data for storing Fileserver index info
local index_fileserver_text="None"
if (( $INDEX_FILESERVER_TARGET == -1 )); then
index_fileserver_text="ProFTP"
elif (( $INDEX_FILESERVER_TARGET == -2 )); then
index_fileserver_text="Samba"
fi
#Data for storing Logging index info
local index_logging_text="None"
if (( $INDEX_LOGGING_TARGET == -1 )); then
index_logging_text="DietPi-Ramlog #1"
elif (( $INDEX_LOGGING_TARGET == -2 )); then
index_logging_text="DietPi-Ramlog #2"
elif (( $INDEX_LOGGING_TARGET == -3 )); then
index_logging_text="Full"
fi
#Hold our string that tells the user what software will be removed when using Index based choice systems
local toberemoved_text=''
#Check status of USB drive
Check_USB_Drive_Installed
#Where is userdata stored?
local user_data_location_current=$(readlink -f $G_FP_DIETPI_USERDATA)
local user_data_location_description=''
if [ "$user_data_location_current" = "$FP_DIETPI_DEDICATED_USBDRIVE" ]; then
user_data_location_description="USB Drive | $user_data_location_current"
elif [ "$user_data_location_current" = "$G_FP_DIETPI_USERDATA" ]; then
user_data_location_description="SD/EMMC | $user_data_location_current"
else
user_data_location_description="Custom | $user_data_location_current"
fi
# - Webserver preference system
local index_webserver_text='Apache2'
if (( $INDEX_WEBSERVER_TARGET == -1 )); then
index_webserver_text='Nginx'
elif (( $INDEX_WEBSERVER_TARGET == -2 )); then
index_webserver_text='Lighttpd'
fi
WHIP_TITLE='DietPi-Software'
WHIP_BACKTITLE="DietPi-Software | IP: $(sed -n 4p /DietPi/dietpi/.network) | Device: $G_HW_MODEL_DESCRIPTION"
OPTION=$(whiptail --title "$WHIP_TITLE" --backtitle "$WHIP_BACKTITLE" --menu "" --default-item "$MENU_MAIN_LASTITEM" --cancel-button "Exit" 20 100 13 \
"Help!" "Links to online guides, docs and information" \
"DietPi-Config" "Feature-rich configuration tool for your device" \
"" "─── Select Software ─────────────────────────" \
"Software Optimized" "Select DietPi optimized software for installation" \
"Software Additional" "Select additional Linux software for installation" \
"SSH Server" ": $index_sshserver_text" \
"File Server" ": $index_fileserver_text" \
"Log System" ": $index_logging_text" \
"Webserver Preference" ": $index_webserver_text" \
"User Data Location" ": $user_data_location_description" \
"" "─── Install or Remove Software ──────────────" \
"Uninstall" "Select installed software for removal" \
"Install" "Go >> Start installation for selected software" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
MENU_MAIN_LASTITEM="$OPTION"
case "$OPTION" in
"Uninstall")
TARGETMENUID=3
;;
"Software Optimized")
TARGETMENUID=1
;;
"Software Additional"*)
TARGETMENUID=2
;;
"SSH Server")
WHIP_TITLE='SSH Server Choices'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "> None\nSelecting this option will uninstall all SSH servers. This reduces system resources and improves performance. Useful for users who do NOT require networked/remote terminal access.\n\n> Dropbear (Recommended)\nLightweight SSH server, installed by default on DietPi systems.\n\n> OpenSSH\nA feature rich SSH server with SFTP/SCP support, at the cost of increased resource usage." --cancel-button "Back" --default-item "$index_sshserver_text" 21 75 3 \
"None" "Not required / manual setup." \
"Dropbear" "Lightweight SSH Server (Recommended)." \
"OpenSSH" "Feature Rich SSH Server with SFTP/SCP support." 3>&1 1>&2 2>&3)
#Assign target index
if [ "$OPTION" = "None" ]; then
INDEX_SSHSERVER_TARGET=0
toberemoved_text="Dropbear and OpenSSH Server"
elif [ "$OPTION" = "Dropbear" ]; then
INDEX_SSHSERVER_TARGET=-1
toberemoved_text="OpenSSH Server"
elif [ "$OPTION" = "OpenSSH" ]; then
INDEX_SSHSERVER_TARGET=-2
toberemoved_text="Dropbear"
#Reset to current
else
INDEX_SSHSERVER_TARGET=$INDEX_SSHSERVER_CURRENT
fi
#Check for changes
INSTALL_SSHSERVER_CHOICESMADE=0
if (( $INDEX_SSHSERVER_TARGET != $INDEX_SSHSERVER_CURRENT )); then
INSTALL_SSHSERVER_CHOICESMADE=1
#Inform user
WHIP_TITLE="SSH Server Change"
WHIP_QUESTION="$OPTION has been selected:\n- Your choice will be applied when 'Install Go >> Start installation' is selected.\n- $toberemoved_text installations will be automatically uninstalled."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
fi
;;
"File Server")
WHIP_TITLE='Fileserver Choices'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "> None\nSelect this option if you do NOT require a method of accessing files and folders on this device, over a network.\n\n> ProFTP (Recommended for RPi v1)\nAllows you to access/share files on this device efficiently with minimal cpu usage. Uses FTP protocol.\n\n> Samba (Recommended for RPi v2)\nAllows you to easily access/share files on this device, at the cost of higher cpu usage.\n\nMore info: http://dietpi.com/phpbb/viewtopic.php?f=8&t=15#p19" --cancel-button "Back" --default-item "$index_fileserver_text" 23 75 3 \
"None" "Not required / manual setup." \
"ProFTP" "Efficient, lightweight fileserver (recommended)." \
"Samba" "Feature-rich fileserver." 3>&1 1>&2 2>&3)
#Assign target index
if [ "$OPTION" = "None" ]; then
INDEX_FILESERVER_TARGET=0
toberemoved_text="ProFTP and Samba Server"
elif [ "$OPTION" = "ProFTP" ]; then
INDEX_FILESERVER_TARGET=-1
toberemoved_text="Samba Server"
elif [ "$OPTION" = "Samba" ]; then
INDEX_FILESERVER_TARGET=-2
toberemoved_text="ProFTP"
#Reset to current
else
INDEX_FILESERVER_TARGET=$INDEX_FILESERVER_CURRENT
fi
#Check for changes
INSTALL_FILESERVER_CHOICESMADE=0
if (( $INDEX_FILESERVER_TARGET != $INDEX_FILESERVER_CURRENT )); then
INSTALL_FILESERVER_CHOICESMADE=1
#Inform user
WHIP_TITLE="Fileserver Choice Change"
WHIP_QUESTION="$OPTION has been selected:\n- Your choice will be applied when 'Install Go >> Start installation' is selected.\n- $toberemoved_text installations will be automatically uninstalled."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
fi
;;
"Log System")
WHIP_TITLE='Logging System Choices'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "> None\nSelecting this option will uninstall DietPi-Ramlog, Logrotate, Rsyslog.\n\n> DietPi-Ramlog #1 (Max performance)\nMounts /var/log to RAM, reducing filesystem IO. Logfiles are cleared every hour. Does NOT save logfiles to disk.\n\n> DietPi-Ramlog #2\nSame as #1, with the added feature of saving logfile contents to disk ($HOME/logfile_storage/*), before being cleared.\n\n> Full (Reduces performance)\nMounts /var/log to DISK, reduces SDcard lifespan. Full logging system with Logrotate and Rsyslog." --cancel-button "Back" --default-item "$index_logging_text" 25 75 4 \
"None" " Not required / manual setup." \
"DietPi-Ramlog #1" " Hourly clear (recommended)." \
"DietPi-Ramlog #2" " Hourly save, then clear." \
"Full" " Logrotate and Rsyslog." 3>&1 1>&2 2>&3)
#Assign target index
if [ "$OPTION" = "None" ]; then
INDEX_LOGGING_TARGET=0
toberemoved_text="DietPi-Ramlog, Logrotate, Rsyslog"
elif [ "$OPTION" = "DietPi-Ramlog #1" ]; then
INDEX_LOGGING_TARGET=-1
toberemoved_text="Logrotate, Rsyslog"
elif [ "$OPTION" = "DietPi-Ramlog #2" ]; then
INDEX_LOGGING_TARGET=-2
toberemoved_text="Logrotate, Rsyslog"
elif [ "$OPTION" = "Full" ]; then
INDEX_LOGGING_TARGET=-3
toberemoved_text="DietPi-Ramlog"
#Reset to current
else
INDEX_LOGGING_TARGET=$INDEX_LOGGING_CURRENT
fi
#Check for changes
INSTALL_LOGGING_CHOICESMADE=0
if (( $INDEX_LOGGING_TARGET != $INDEX_LOGGING_CURRENT )); then
INSTALL_LOGGING_CHOICESMADE=1
#Inform user
WHIP_TITLE="Logging System Change"
WHIP_QUESTION="$OPTION has been selected:\n- Your choice will be applied when 'Install Go >> Start installation' is selected.\n- $toberemoved_text installations will be automatically uninstalled."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
fi
;;
"User Data Location")
WHIP_TITLE='User Data Location'
# - Vars if we need to move data.
local move_data_target=$user_data_location_current
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Choose where to store your user data. User data includes software such as Owncloud data store, BitTorrent downloads etc\n\nMore information on user data in DietPi:\n - http://dietpi.com/phpbb/viewtopic.php?f=8&t=478&p=2087\n\n> DietPi-Drive Manager\nLaunch DietPi-Drive Manager to setup external drives, and, move user data to different locations." --cancel-button "Back" 20 85 3 \
"Drive Manager" "Launches DietPi-Drive Manager" \
"List" "Select from a list of available mounts/drives, to move user data" \
"Custom" "Input a manual location to move user data" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
# - DriveMan
if [ "$OPTION" = "Drive Manager" ]; then
/DietPi/dietpi/dietpi-drive_manager
# - List
elif [ "$OPTION" = "List" ]; then
/DietPi/dietpi/dietpi-drive_manager 1
local return_value="$(cat /tmp/dietpi-drive_manager_selmnt)"
if [ -n "$return_value" ]; then
if [ "$return_value" = "/" ]; then
return_value='/mnt'
fi
move_data_target="$return_value"
move_data_target+='/dietpi_userdata'
fi
# - Manual filepath entry
elif [ "$OPTION" = "Custom" ]; then
OPTION=$(whiptail --inputbox "Please input a location. Your user data will be stored inside this location.\n - eg: /mnt/MyDrive/MyData" 11 60 "$user_data_location_current" --title "User/Personal Data Directory" --backtitle "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
move_data_target=$OPTION
fi
fi
# - Move data if the new entry has changed
if [ "$user_data_location_current" != "$move_data_target" ]; then
# - Ask before we begin
whiptail --title "User data transfer" --yesno "DietPi will now attempt to transfer your existing user data to the new location:\n\n - From: $user_data_location_current\n - To: $move_data_target\n\nWould you like to begin?" --backtitle "$WHIP_BACKTITLE" --defaultno 14 70
CHOICE=$?
if (( $CHOICE == 0 )); then
# - Move data, setup symlinks
/DietPi/dietpi/func/dietpi-set_userdata "$user_data_location_current" "$move_data_target"
if (( $? == 0 )); then
whiptail --title "User data transfer: Completed" --msgbox "Your user data has been sucessfuly moved:\n\n - From: $user_data_location_current\n - To: $move_data_target" 12 70
else
whiptail --title "User data transfer: Failed" --msgbox "$(cat /var/log/dietpi-move_userdata.log)\nNo changes have been applied." 12 70
fi
fi
fi
fi
;;
"Webserver Preference")
WHIP_TITLE='Webserver Preference'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "More Info: http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=1549#p1549\n\n> Apache2\nFeature-rich and popular. Recommended for beginners and users who are looking to follow Apache2 based guides.\n\n> Nginx\nLightweight alternative to Apache2. Nginx claims faster webserver performance compared to Apache2.\n\n> Lighttpd\nExtremely lightweight and is generally considered to offer the \"best\" webserver performance for SBC's. Recommended for users who expect low webserver traffic." --cancel-button "Back" --default-item "$index_webserver_text" 24 75 3 \
"Apache2" "Popular webserver." \
"Nginx" "Lightweight webserver." \
"Lighttpd" "Extremely lightweight webserver." 3>&1 1>&2 2>&3)
#Assign target index
if [ "$OPTION" = "Apache2" ]; then
INDEX_WEBSERVER_TARGET=0
elif [ "$OPTION" = "Nginx" ]; then
INDEX_WEBSERVER_TARGET=-1
elif [ "$OPTION" = "Lighttpd" ]; then
INDEX_WEBSERVER_TARGET=-2
#Reset to current
else
INDEX_WEBSERVER_TARGET=$INDEX_WEBSERVER_CURRENT
fi
#Check for changes
if (( $INDEX_WEBSERVER_TARGET != $INDEX_WEBSERVER_CURRENT )); then
# - Check for existing and compatible installed stacks before allowing the change
local incompatible_webserver_preference=0
local info_currently_installed_webserver='None'
if (( $(dpkg -l | awk '{print $2}' | grep -ci -m1 'apache2'))); then
INDEX_WEBSERVER_CURRENT=0
info_currently_installed_webserver='Apache2'
if (( $INDEX_WEBSERVER_TARGET != 0 )); then
incompatible_webserver_preference=1
fi
elif (( $(dpkg -l | awk '{print $2}' | grep -ci -m1 'nginx') )); then
INDEX_WEBSERVER_CURRENT=-1
info_currently_installed_webserver='Nginx'
if (( $INDEX_WEBSERVER_TARGET != -1 )); then
incompatible_webserver_preference=1
fi
elif (( $(dpkg -l | awk '{print $2}' | grep -ci -m1 'lighttpd') )); then
INDEX_WEBSERVER_CURRENT=-2
info_currently_installed_webserver='Lighttpd'
if (( $INDEX_WEBSERVER_TARGET != -2 )); then
incompatible_webserver_preference=1
fi
fi
# - Reset preference selection
if (( $incompatible_webserver_preference == 1 )); then
INDEX_WEBSERVER_TARGET=$INDEX_WEBSERVER_CURRENT
# - inform user
WHIP_TITLE="Error: Incompatible Webserver Preference"
WHIP_QUESTION="Unable to change your webserver preference to $OPTION.\n\nThis is due to an existing and incompatible webserver installation on your system ($info_currently_installed_webserver). Please remove all webserver based software (using dietpi-software > uninstall), before trying again."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
# - Apply preference selection
else
# - Inform user
WHIP_TITLE="Webserver Preference Changed"
WHIP_QUESTION="$OPTION has been selected as your webserver preference.\n\nWhen you select any software for install that requires a webserver, DietPi will automatically install your prefered choice ($OPTION)."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
# - NB: INDEX_WEBSERVER_CURRENT=$INDEX_WEBSERVER_TARGET | is applied during installation with func Apply_Webserver_Preference().
fi
fi
;;
"DietPi-Config")
/DietPi/dietpi/dietpi-config
;;
"Help!")
#Populate help to text file so we can read it back to whiptail, as a scrollbox.
cat << _EOF_ > /tmp/dietpi-software_help_onlinedoc_url_list
───────────────────────────────────────────────────────────────
Welcome to DietPi:
───────────────────────────────────────────────────────────────
Use PageUp/Down or Arrow Up/Down to scroll this help screen.
Press ESC, or TAB then enter to exit this help screen.
Easy to follow, step by step guides for installing DietPi:
http://dietpi.com/phpbb/viewtopic.php?f=8&t=9
For a list of all installation options and their details:
http://dietpi.com/software
───────────────────────────────────────────────────────────────
List of installed software and their URL links for online docs:
───────────────────────────────────────────────────────────────
_EOF_
# - Installed software
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
if (( ${aSOFTWARE_INSTALL_STATE[$i]} > 0 )); then
if [ -n "${aSOFTWARE_ONLINEDOC_URL[$i]}" ]; then
cat << _EOF_ >> /tmp/dietpi-software_help_onlinedoc_url_list
${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_NAME[$i]}
$FP_ONLINEDOC_URL${aSOFTWARE_ONLINEDOC_URL[$i]}
_EOF_
fi
fi
done
whiptail --title "DietPi - Help" --backtitle "$WHIP_BACKTITLE" --textbox /tmp/dietpi-software_help_onlinedoc_url_list $(( $(tput lines) - 3 )) $(( $(tput cols) - 3 )) --scrolltext
;;
Install)
Menu_StartInstall
;;
esac
#Exit/Abort Setup
else
Menu_Exit
fi
}
Menu_Exit(){
#1st run install
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
WHIP_TITLE='Exit Setup?'
WHIP_QUESTION=' DietPi has not fully been installed.\n This must be completed prior to using DietPi by selecting:\n - Go Start Install. \n \n Would you like to exit and abort the installation?'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" --yes-button "Ok" --no-button "Back" --defaultno 13 65
CHOICE=$?
if (( $CHOICE == 0 )); then
Banner_Aborted
#Exit script NOW
Exit_Destroy
else
#Return to Main Menu
TARGETMENUID=0
fi
#Standard exit
elif (( $G_DIETPI_INSTALL_STAGE == 1 )); then
WHIP_TITLE='Exit DietPi-Software?'
WHIP_QUESTION='Do you wish to exit DietPi-Software?\n\nAll changes to software selections will be cleared.'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" --yes-button "Ok" --no-button "Back" --defaultno 11 65
CHOICE=$?
if (( $CHOICE == 0 )); then
Banner_Aborted
#Exit script NOW
Exit_Destroy
else
#Return to Main Menu
TARGETMENUID=0
fi
fi
}
Menu_ConfirmInstall(){
#Obtain list of pending software installation:
local string_output=''
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 1 )); then
string_output+="\n - ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}"
fi
done
#Confirm Software install
WHIP_TITLE='DietPi - Start Installation?'
WHIP_QUESTION="DietPi is now ready to install your software choices: $string_output\n\nSoftware details, usernames, passwords etc:\n - http://dietpi.com/software\n\nWould you like to begin?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 20 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#exit menu system
TARGETMENUID=-1
#Enable installation start flag
GOSTARTINSTALL=1
else
#Return to Main Menu
TARGETMENUID=0
fi
}
Menu_StartInstall(){
#Check if the user has made changes to their software selections.
if (( $INSTALL_DIETPI_CHOICESMADE ||
$INSTALL_LINUX_CHOICESMADE ||
$INSTALL_SSHSERVER_CHOICESMADE ||
$INSTALL_FILESERVER_CHOICESMADE ||
$INSTALL_LOGGING_CHOICESMADE )); then
# Confirm install with user
Menu_ConfirmInstall
else
#1st run install
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
WHIP_TITLE='No Software Selected. Continue?'
WHIP_QUESTION='DietPi was unable to detect any software selections for install. Do you wish to continue?\n\nBy selecting Ok: \n- DietPi optimized software will NOT be installed.\nYou can use dietpi-software at a later date if you change your mind. \n\n- You want a Minimal Raspbian/Debian Server Install.\nDietPi is a minimal image. A great OS base to use with your projects.'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" --yes-button "Ok" --no-button "Back" --defaultno 16 75
CHOICE=$?
if (( $CHOICE == 0 )); then
#exit menu system
TARGETMENUID=-1
#Enable installation start flag
GOSTARTINSTALL=1
else
#Return to Main Menu
TARGETMENUID=0
fi
#Not 1st run
elif (( $G_DIETPI_INSTALL_STAGE == 1 )); then
WHIP_TITLE='No Changes to Software Selection'
whiptail --title "$WHIP_TITLE" --msgbox "No changes have been detected. Unable to start installation." 8 65
fi
fi
}
#TARGETMENUID=1
Menu_Dietpi_Software(){
#-----------------------------------------------------------------------------
#Generate Whiptail menu and store results into our software arrays
Menu_CreateSoftwareList 0
#Return to Main Menu
TARGETMENUID=0
#-----------------------------------------------------------------------------
#Install Info/Warnings
#OMV, .deb package has Nginx as a dependancy. Not compatible with other webservers
if (( ${aSOFTWARE_INSTALL_STATE[126]} == 1 &&
( ${aSOFTWARE_INSTALL_STATE[77]} == 0 && ${aSOFTWARE_INSTALL_STATE[78]} == 0 && ${aSOFTWARE_INSTALL_STATE[79]} == 0 && $INDEX_WEBSERVER_TARGET != -1 ) )); then
WHIP_TITLE='OMV: Requires Nginx'
WHIP_QUESTION="Open Media Vault (OMV) requires Nginx webserver and is not compatible with other web servers (eg: Lighttpd/Apache2). This is due to the OMV package listing Nginx as a dependency.\n\nOptions:\n - Change 'web server choice' to 'Nginx'\n - Uninstall current web server, then, select any Nginx web stack for install (eg: LESP)\n\nOpen Media Vault has been deselected and will not be installed."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 19 70
aSOFTWARE_INSTALL_STATE[126]=0
fi
#SickRage, setup for Transmission, install it aswell?
if (( ${aSOFTWARE_INSTALL_STATE[116]} == 1 &&
${aSOFTWARE_INSTALL_STATE[44]} == 0 )); then
WHIP_TITLE='SickRage - Install Transmission?'
WHIP_QUESTION="The DietPi SickRage installation is pre-configured to work with Transmission BitTorrent Server. This will allow SickRage to automatically download TV shows for you.\n\nNB: If you have another BitTorrent server installed, or prefer manual setup, please select No.\n\nWould you like DietPi to also install Transmission (recommended)?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --defaultno --backtitle "$WHIP_BACKTITLE" 14 72
CHOICE=$?
if (( $CHOICE == 0 )); then
aSOFTWARE_INSTALL_STATE[44]=1
fi
fi
#Gogs: Requires OpenSSH for ssh-keygen binary: https://github.com/Fourdee/DietPi/issues/442
if (( ${aSOFTWARE_INSTALL_STATE[49]} == 1 && $INDEX_SSHSERVER_TARGET != -2 )); then
WHIP_TITLE='Gogs: Requires OpenSSH'
WHIP_QUESTION="Gogs requires OpenSSH server to function.\nIf you continue, OpenSSH will be selected for install on your system. OpenSSH will also replace Dropbear (if currently installed).\n\nWould you like to continue with the Gogs installation?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --defaultno --backtitle "$WHIP_BACKTITLE" 13 65
CHOICE=$?
if (( $CHOICE == 0 )); then
# - Use SSH target index to ensure Dropbear gets removed if installed.
INDEX_SSHSERVER_TARGET=-2
else
aSOFTWARE_INSTALL_STATE[49]=0
fi
fi
#Webserver stacks
for ((i=74; i<=82; i++))
do
#Please let DietPi install them for you...
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 1 )); then
WHIP_TITLE='Info: Webserver Stack'
WHIP_QUESTION="DietPi will automatically install a webserver stack (based on your Webserver Preference) when any software that requires a webserver is selected for installation (eg: Owncloud, PiHole etc).\n\nIt is highly recommended that you allow DietPi to do this for you, ensuring compatibility and stability across DietPi installed programs.\n\nPlease only select a webserver stack if you specifically need it, and, no other webserver stack is installed.\n\nTLDR: You do NOT need to select a webserver stack for installation with DietPi. Its all automatic."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 19 70
break
fi
done
#phpmyadmin + Lighttpd | broken apt-get installation. User must have a fully installed LLM* stack before phpmyadmin can be selected:
#https://github.com/Fourdee/DietPi/issues/316#issuecomment-219474664
if (( ${aSOFTWARE_INSTALL_STATE[90]} == 1 &&
$INDEX_WEBSERVER_TARGET == -2 &&
( ${aSOFTWARE_INSTALL_STATE[80]} < 2 && ${aSOFTWARE_INSTALL_STATE[82]} < 2 ) )); then
WHIP_TITLE='PhpMyAdmin'
WHIP_QUESTION="Due to a apt-get installation issue with PhpMyAdmin, you must have a fully installed Lighttpd + MaridaDB webserver stack, before PhpMyAdmin can be selected for install.\n\nYour selection for PhpMyAdmin has been removed."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 13 70
aSOFTWARE_INSTALL_STATE[90]=0
fi
#DietPiCam - warn user of locking out camera: https://github.com/Fourdee/DietPi/issues/249
if (( ${aSOFTWARE_INSTALL_STATE[59]} == 1 )); then
WHIP_TITLE='DietPi Cam - Camera'
WHIP_QUESTION="DietPi Cam will automatically start and activate the camera during boot. This will prevent other programs (eg: raspistill) from using the camera.\n\nYou can free up the camera by selecting \"Stop Camera\" from the web interface:\nhttp://myip/dietpicam"
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 15 70
fi
#EmonHUB/EmonPi
if (( ${aSOFTWARE_INSTALL_STATE[99]} == 1 )); then
# - Enter API KEY
# - Grab key from dietpi.txt
USER_EMONHUB_APIKEY_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_EMONHUB_APIKEY=' | sed 's/.*=//')
while (( $USER_EMONHUB_APIKEY_COMPLETED == 0 )); do
WHIP_TITLE='EmonPi/Hub - API KEY'
WHIP_QUESTION="Please enter your \"Write API KEY\":\n - Goto http://emoncms.org and register an account and login.\n - Select \"Setup\" from the top right of screen, then select \"My Account\"\n - Enter the \"Write API Key\" into the box below."
OPTION=$(whiptail --inputbox "$WHIP_QUESTION" 14 75 "$USER_EMONHUB_APIKEY_CURRENT" --title "$WHIP_TITLE" --backtitle "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
USER_EMONHUB_APIKEY_CURRENT=$OPTION
WHIP_TITLE='EmonPi/Hub - API KEY'
WHIP_QUESTION="The following \"Write API KEY\" will be applied during installation:\n$USER_EMONHUB_APIKEY_CURRENT\n\nIs this key correct?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 70
CHOICE=$?
if (( $CHOICE == 0 )); then
# - update dietpi.txt so the value will be applied during installation.
sed -i "/^SOFTWARE_EMONHUB_APIKEY=/c\SOFTWARE_EMONHUB_APIKEY=$USER_EMONHUB_APIKEY_CURRENT" /DietPi/dietpi.txt
USER_EMONHUB_APIKEY_COMPLETED=1
fi
fi
done
fi
#Pi-hole.
if (( ${aSOFTWARE_INSTALL_STATE[93]} == 1 )); then
# - prompt for static ip.
WHIP_TITLE=' Pi-hole - Setup Static IP Now?'
WHIP_QUESTION='A static IP address is essential for Pi-hole installations. DietPi-Config can be used to quickly setup your static IP address.\n\nIf you have already setup your static IP, please ignore this message.\n\nWould you like to setup your static IP address now?'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --defaultno --backtitle "$WHIP_BACKTITLE" 15 70
CHOICE=$?
if (( $CHOICE == 0 )); then
WHIP_TITLE=' Pi-hole - Setup Static IP'
WHIP_QUESTION='DietPi-Config will now be launched. Simply select your Ethernet or Wifi connection from the menu to access the IP address settings.\n\nThe "copy current address to STATIC" menu option can be used to quickly setup your static IP. Please ensure you change the mode "DHCP" to "STATIC".\n\nWhen you are done, select "Apply, Save Changes", then exit DietPi-Config to resume setup.'
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 15 70
#Launch DietPi-config networking menu
/DietPi/dietpi/dietpi-config 8 1
fi
fi
#Wifi Hotspot Criteria
if (( ${aSOFTWARE_INSTALL_STATE[60]} == 1 )) ||
(( ${aSOFTWARE_INSTALL_STATE[61]} == 1 )); then
#Enable wifi modules
/DietPi/dietpi/func/dietpi-set_hardware wifimodules enable
local check_criteria=1
while (( $check_criteria == 1 )); do
local criteria_passed=1
WHIP_TITLE="WiFi Hotspot Criteria"
WHIP_QUESTION="The following criteria must be met for this installation to succeed:"
local ethernet_active_state=$(ip r | grep -ci -m1 "eth$(sed -n 1p /DietPi/dietpi/.network)")
if (( $ethernet_active_state == 1 )); then
WHIP_QUESTION+="\n\n - Ethernet online: PASSED"
else
criteria_passed=0
WHIP_QUESTION+="\n\n - Ethernet online: FAILED.\nUse dietpi-config to connect and configure ethernet."
fi
if [ -d /sys/class/net/wlan$(sed -n 2p /DietPi/dietpi/.network) ]; then
WHIP_QUESTION+="\n\n - Wifi adapter detected: PASSED"
else
criteria_passed=0
WHIP_QUESTION+="\n\n - Wifi adapter detected: FAILED.\nPlease connect a WiFi adapter and try again."
fi
#Passed
if (( $criteria_passed == 1 )); then
WHIP_QUESTION+="\n\nPASSED: Criteria met. Good to go."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 14 75
check_criteria=0
#Failed, retry?
else
WHIP_QUESTION+="\n\nFAILED: Criteria not met. Would you like to check again?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 16 75
CHOICE=$?
if (( $CHOICE == 0 )); then
echo "retry" &> /dev/null
else
# - Disable user selection
check_criteria=0
aSOFTWARE_INSTALL_STATE[60]=0
aSOFTWARE_INSTALL_STATE[61]=0
whiptail --title "WiFi Hotspot Failed" --msgbox "WiFi Hotspot criteria was not met. Your selection has been removed." --backtitle "$WHIP_BACKTITLE" 10 65
fi
fi
done
fi
#Weaved
if (( ${aSOFTWARE_INSTALL_STATE[68]} == 1 )); then
WHIP_TITLE='Remot3.it - 1st run setup'
WHIP_QUESTION='Remot3.it requires you to create an online account, and, link it this device.\n\nOnce DietPi has completed your software installations, and rebooted, please follow the First Run tutorial here:\nhttp://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=188#p188'
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 14 70
fi
#LetsEncrypt
if (( ${aSOFTWARE_INSTALL_STATE[92]} == 1 )); then
WHIP_TITLE='Lets Encrypt Info'
WHIP_QUESTION='Currently, the DietPi installation of CertBot supports Apache2 & Lighttpd only.\n\nOnce the installation has finished, you can setup your free SSL cert with:\n - DietPi-LetsEncrypt\n\nThis is a easy to use frontend for CertBot and allows intergration into DietPi systems.\n\nMore information:\n - http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=1061#p1062'
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 18 70
fi
#-----------------------------------------------------------------------------
#dietpi-config can be used to install/configure the following software. Ask user.
#NoIp
if (( ${aSOFTWARE_INSTALL_STATE[67]} == 1 )); then
WHIP_TITLE='NoIp - Setup Now?'
WHIP_QUESTION='NoIp can be setup and configured by using DietPi-Config. Would you like to go there now? \n\n- Once completed, exit DietPi-Config to resume setup. \n\n- More information:\nhttp://dietpi.com/phpbb/viewtopic.php?f=8&t=5&start=10#p58'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Cancel" --defaultno --backtitle "$WHIP_BACKTITLE" 15 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Write installed states to temp
Write_InstallFileList temp
#Launch DietPi-config
/DietPi/dietpi/dietpi-config 16 1
#Read installed states from temp
Read_InstallFileList temp
fi
fi
#-----------------------------------------------------------------------------
#Boot Choices
if (( ${aSOFTWARE_INSTALL_STATE[23]} == 1 ||
${aSOFTWARE_INSTALL_STATE[24]} == 1 ||
${aSOFTWARE_INSTALL_STATE[25]} == 1 ||
${aSOFTWARE_INSTALL_STATE[26]} == 1 ||
${aSOFTWARE_INSTALL_STATE[31]} == 1 ||
${aSOFTWARE_INSTALL_STATE[51]} == 1 ||
${aSOFTWARE_INSTALL_STATE[108]} == 1 ||
${aSOFTWARE_INSTALL_STATE[112]} == 1 ||
${aSOFTWARE_INSTALL_STATE[119]} == 1 ||
${aSOFTWARE_INSTALL_STATE[155]} == 1 )); then
# Set Boot Order
WHIP_TITLE=' DietPi - Boot Options'
WHIP_QUESTION='Would you like to configure the auto boot options for DietPi?\n\nThis will allow you to choose which program loads automatically after booting eg:\n - Console\n - Desktop\n - Kodi'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --defaultno --backtitle "$WHIP_BACKTITLE" 14 70
CHOICE=$?
if (( $CHOICE == 0 )); then
/DietPi/dietpi/dietpi-autostart
fi
fi
}
#TARGETMENUID=2
Menu_Linux_Software(){
#Inform User that DietPi software will automatically install additional linux software when required.
if (( ! $USER_LINUX_AUTOINSTALL_PROMPT_DISPLAYED )); then
WHIP_TITLE='Additional Linux Software'
WHIP_QUESTION='DietPi will automatically install additional Linux software on the next screen, when required (eg: Desktop LXDE will install ALSA + Xserver).\n\nThis means you only need to select the software you actually require.'
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 12 70
USER_LINUX_AUTOINSTALL_PROMPT_DISPLAYED=1
fi
#-----------------------------------------------------------------------------
#Generate Whiptail menu and store results into our software arrays
Menu_CreateSoftwareList 1
#Return to Main Menu
TARGETMENUID=0
#-----------------------------------------------------------------------------
#dietpi-config can be used to install/configure the following software. Ask user.
#CurlFTPfs -
if (( ${aSOFTWARE_INSTALL_STATE[2]} == 1 )); then
WHIP_TITLE='FTP Client - Setup Now?'
WHIP_QUESTION='FTP Client as a filesystem mount (CurlFTPfs) can be setup and configured by using DietPi-Config. Would you like to go there now? \n\n- Once completed, exit DietPi-Config to resume setup.'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Cancel" --defaultno --backtitle "$WHIP_BACKTITLE" 13 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Write installed states to temp
Write_InstallFileList temp
#Launch DietPi-config
/DietPi/dietpi/dietpi-config 16 1
#Read installed states from temp
Read_InstallFileList temp
fi
fi
#SMBCLIENT -
if (( ${aSOFTWARE_INSTALL_STATE[1]} == 1 )); then
WHIP_TITLE='Samba Client - Setup Now?'
WHIP_QUESTION='Samba Client can be setup and configured by using DietPi-Config. Would you like to go there now? \n\n- Once completed, exit DietPi-Config to resume setup.'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Cancel" --defaultno --backtitle "$WHIP_BACKTITLE" 13 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Write installed states to temp
Write_InstallFileList temp
#Launch DietPi-config
/DietPi/dietpi/dietpi-config 16 1
#Read installed states from temp
Read_InstallFileList temp
fi
fi
#-----------------------------------------------------------------------------
}
#TARGETMENUID=3
Menu_Uninstall_Software(){
#Return to main menu
TARGETMENUID=0
#Array which will hold all software indexs to be removed.
local asoftware_for_uninstall=()
local software_installed_count=0
#Obtain list of installed software
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 2 &&
${aSOFTWARE_TYPE[$i]} >= -1 )); then
whiptail_list_array+=("$i" "${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}" "off")
((software_installed_count++))
fi
done
# - Hide specific software (eg: stacks) in for loop ?
if (( $software_installed_count == 0 )); then
whiptail --title "Uninstall Software" --msgbox "No software is currently installed, or, available for removal." --backtitle "$WHIP_BACKTITLE" 9 60
#Run menu
else
whiptail --title "Uninstall Software" --checklist --separate-output "Use the spacebar to select the software you would like to remove." --cancel-button "Cancel" --backtitle "$WHIP_BACKTITLE" 18 75 10 "${whiptail_list_array[@]}" 2>/tmp/dietpi-software_uninstall_results
while read choice
do
case $choice in
*)
#Convert lined list into a 1 line string.
asoftware_for_uninstall+=("$choice")
;;
esac
done < /tmp/dietpi-software_uninstall_results
rm /tmp/dietpi-software_uninstall_results &> /dev/null
unset whiptail_list_array
#Prompt user with list of their selected software for removal
if (( ${#asoftware_for_uninstall[@]} > 0 )); then
# - Create list
WHIP_QUESTION='The following software will be REMOVED from your system:\n'
for ((i=0; i<${#asoftware_for_uninstall[@]}; i++))
do
for ((j=0; j<$TOTAL_SOFTWARE_INDEXS; j++))
do
if (( ${asoftware_for_uninstall[$i]} == $j )); then
WHIP_QUESTION+=" - ${aSOFTWARE_WHIP_NAME[$j]}: ${aSOFTWARE_WHIP_DESC[$j]}\n"
break
fi
done
done
#Ask for confirmation
whiptail --title "Uninstall Software?" --yesno "$WHIP_QUESTION \nDo you wish to continue?" --yes-button "Ok" --no-button "Cancel" --defaultno --backtitle "$WHIP_TITLE" 20 70
CHOICE=$?
#Run uninstall
if (( $CHOICE == 0 )); then
# - stop services
/DietPi/dietpi/dietpi-services stop
for ((i=0; i<${#asoftware_for_uninstall[@]}; i++))
do
Uninstall_Software ${asoftware_for_uninstall[$i]}
done
#Finish up and clear non-required packages
Uninstall_Software_Finalize
#Save
Write_InstallFileList
# - start services
/DietPi/dietpi/dietpi-services start
#inform user
whiptail --title "Uninstall Software" --msgbox "Uninstall completed." --backtitle "$WHIP_BACKTITLE" 9 60
fi
fi
fi
#delete[] arrays
unset whiptail_list_array
unset asoftware_for_uninstall
}
#/////////////////////////////////////////////////////////////////////////////////////
# Banner Print
#/////////////////////////////////////////////////////////////////////////////////////
Banner_Setup(){
/DietPi/dietpi/dietpi-banner 0
echo -e "\n Welcome to DietPi-Software \n"
}
Banner_Installing(){
G_DIETPI-NOTIFY 3 DietPi-Software "Installing ${aSOFTWARE_WHIP_NAME[$INSTALLING_INDEX]}: ${aSOFTWARE_WHIP_DESC[$INSTALLING_INDEX]}"
}
Banner_Configuration(){
G_DIETPI-NOTIFY 3 DietPi-Software "Configuring ${aSOFTWARE_WHIP_NAME[$INSTALLING_INDEX]}: ${aSOFTWARE_WHIP_DESC[$INSTALLING_INDEX]}"
}
Banner_Apt_Update(){
G_DIETPI-NOTIFY 3 DietPi-Software "Update & upgrade APT"
sleep 1
}
Banner_Reboot(){
if (( ! $DISABLE_REBOOT )); then
G_DIETPI-NOTIFY 3 DietPi-Software "Installation completed"
G_DIETPI-NOTIFY 0 "The system will now reboot. \n This completes the DietPi-Software installation.\n"
sleep 3
else
G_DIETPI-NOTIFY 0 "DietPi-Software installation completed."
fi
}
Banner_Configs(){
G_DIETPI-NOTIFY 3 DietPi-Software "Optimize and configure software"
G_DIETPI-NOTIFY 2 "Applying DietPi optimizations and configurations for $G_HW_MODEL_DESCRIPTION, please wait...\n"
}
Banner_Aborted(){
#1st run abort
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
/DietPi/dietpi/dietpi-banner 0
G_DIETPI-NOTIFY 1 "\n Installation Aborted by User \n Installation must be completed prior to using DietPi \n Please run dietpi-software to restart the installation \n"
#Standard abort
else
/DietPi/dietpi/dietpi-banner 1
fi
}
#/////////////////////////////////////////////////////////////////////////////////////
# Main Loop
#/////////////////////////////////////////////////////////////////////////////////////
#--------------------------------------------------------------------------------------
G_DIETPI-NOTIFY 2 "Initializing database, please wait..."
#--------------------------------------------------------------------------------------
#Init software arrays
Software_Arrays_Init
#--------------------------------------------------------------------------------------
#load .installed file, update vars, if it exists
Read_InstallFileList
#--------------------------------------------------------------------------------------
# - CLi input mode
if [ -n "$1" ]; then
# - Run input mode
Input_Modes "$@"
#--------------------------------------------------------------------------------------
#Standard launch
else
#Check if we are setting no user inputs and prompts
# - Load all automation vars
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
FirstRun_Automation_Init
fi
#GPL compliance prompt
if (( $G_DIETPI_INSTALL_STAGE == 0 && $G_USER_INPUTS )); then
whiptail --title "DietPi - GPLv2 License" --msgbox "This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see http://www.gnu.org/licenses/" --backtitle "DietPi - GPLv2 Compliance" 18 70
fi
Banner_Setup
#Prevent continue if NTPD is not completed: https://github.com/Fourdee/DietPi/issues/786
Check_NTPD_Status
#1st run Connection test and DietPi updates
#NB: Contains EXIT path
if (( $(cat /DietPi/dietpi/.update_stage) == -1 )); then
Check_Internet_Connection
FirstRun_DietPi_Update
fi
#Apply 1st run automation
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
#Activate automation settings from dietpi.txt, if set.
FirstRun_Automation_Set
fi
#Start DietPi Menu
while (( $TARGETMENUID > -1 )); do
clear
if (( $TARGETMENUID == 0 )); then
Menu_Main
elif (( $TARGETMENUID == 1 )); then
Menu_Dietpi_Software
elif (( $TARGETMENUID == 2 )); then
Menu_Linux_Software
elif (( $TARGETMENUID == 3 )); then
Menu_Uninstall_Software
fi
done
fi
#--------------------------------------------------------------------------------------
#Start DietPi-Software installs
if (( $GOSTARTINSTALL )); then
#Insufficient free space
/DietPi/dietpi/dietpi-drive_manager 2
if (( $? != 0 )); then
Exit_Destroy
fi
Check_Internet_Connection
#Start installations for software
Run_Installations
#Upload DietPi-Survey Data
/DietPi/dietpi/dietpi-survey &> /dev/null
#Reboot
Banner_Reboot
if (( $DISABLE_REBOOT )); then
# - Start services
/DietPi/dietpi/dietpi-services start
else
sync
reboot
fi
fi
#-----------------------------------------------------------------------------------
Exit_Destroy
#-----------------------------------------------------------------------------------
}
^~
../oil_DEPS/wild/src/distro/DietPi/dietpi/dietpi-software:13866: Couldn't find terminator for here doc that starts here
|
|
Translating dietpi-software
|
G_DIETPI-NOTIFY 2 "Setting Keyboard $AUTOINSTALL_KEYBOARD. Please wait...\n"
sed -i '/XKBLAYOUT=/c XKBLAYOUT="'"$AUTOINSTALL_KEYBOARD"'"' /etc/default/keyboard
#systemctl restart keyboard-setup
fi
#Apply & Mount Network drives if installed
if (( ${aSOFTWARE_INSTALL_STATE[1]} == 2 )); then
/DietPi/dietpi/func/dietpi-set_smbclient 1
fi
if (( ${aSOFTWARE_INSTALL_STATE[2]} == 2 )); then
/DietPi/dietpi/func/dietpi-set_curlftpfs 1
fi
#Custom 1st run Script (Local file)
local run_custom_script=0
if [ -f /boot/Automation_Custom_Script.sh ]; then
INSTALL_DESCRIPTION='Automation - Local Custom Script'
Banner_Installing
cp /boot/Automation_Custom_Script.sh /root/AUTO_CustomScript.sh
run_custom_script=1
#Custom 1st run Script (Online file)
elif [ "$AUTOINSTALL_CUSTOMSCRIPTURL" != "0" ]; then
INSTALL_DESCRIPTION='Automation - Online Custom Script'
Banner_Installing
INSTALL_URL_ADDRESS=$AUTOINSTALL_CUSTOMSCRIPTURL
G_CHECK_URL "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
#Get script and execute
wget "$INSTALL_URL_ADDRESS" -O /root/AUTO_CustomScript.sh
run_custom_script=1
else
echo -e "Automated Custom Script URL Error:\n $AUTOINSTALL_CUSTOMSCRIPTURL is offline and/or unreachable" >> "$FP_DIETPIAUTOMATION_LOG"
fi
fi
if (( $run_custom_script )); then
chmod +x /root/AUTO_CustomScript.sh
/root/AUTO_CustomScript.sh
local result=$?
if (( $result == 0 )); then
echo -e "Automated custom script executed succesfully:\n - Filepath = /root/AUTO_CustomScript.sh\n - URL = $AUTOINSTALL_CUSTOMSCRIPTURL" >> "$FP_DIETPIAUTOMATION_LOG"
else
echo -e "Automated Custom Script Error:\n - Exit code = $result\n - Filepath = /root/AUTO_CustomScript.sh\n - URL = $AUTOINSTALL_CUSTOMSCRIPTURL" >> "$FP_DIETPIAUTOMATION_LOG"
fi
fi
#Apply AutoStart
/DietPi/dietpi/dietpi-autostart $AUTOINSTALL_AUTOSTARTTARGET
fi
#Set Install Stage to Finished
echo 1 > /DietPi/dietpi/.install_stage
}
#/////////////////////////////////////////////////////////////////////////////////////
# First Run / Automation functions Vars (eg: on a fresh install)
#/////////////////////////////////////////////////////////////////////////////////////
AUTOINSTALL_ENABLED=0
AUTOINSTALL_SSHINDEX=0
AUTOINSTALL_FILESERVERINDEX=0
AUTOINSTALL_LOGGINGINDEX=0
AUTOINSTALL_WEBSERVERINDEX=0
AUTOINSTALL_AUTOSTARTTARGET=0
AUTOINSTALL_TIMEZONE=0
AUTOINSTALL_LANGUAGE=0
AUTOINSTALL_KEYBOARD=0
AUTOINSTALL_CUSTOMSCRIPTURL=0
FirstRun_Automation_Init(){
#Get settings
AUTOINSTALL_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_AUTOMATED=' | sed 's/.*=//')
AUTOINSTALL_AUTOSTARTTARGET=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_AUTOSTART_TARGET_INDEX=' | sed 's/.*=//' )
AUTOINSTALL_SSHINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_SSH_SERVER_INDEX=' | sed 's/.*=//')
AUTOINSTALL_FILESERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_FILE_SERVER_INDEX=' | sed 's/.*=//')
AUTOINSTALL_LOGGINGINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_LOGGING_INDEX=' | sed 's/.*=//')
AUTOINSTALL_WEBSERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_WEB_SERVER_INDEX=' | sed 's/.*=//')
AUTOINSTALL_TIMEZONE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_TIMEZONE=' | sed 's/.*=//' )
AUTOINSTALL_LANGUAGE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_LOCALE=' | sed 's/.*=//' )
AUTOINSTALL_KEYBOARD=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_KEYBOARD_LAYOUT=' | sed 's/.*=//' )
AUTOINSTALL_CUSTOMSCRIPTURL=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_CUSTOM_SCRIPT_EXEC=' | sed 's/AUTO_SETUP_CUSTOM_SCRIPT_EXEC=//')
}
FirstRun_Automation_Set(){
#Automated install
if (( $AUTOINSTALL_ENABLED >= 1 )); then
G_DIETPI-NOTIFY 3 DietPi-Software "Running automated installation"
#Skip dietpi-software menu
TARGETMENUID=-1
#Set start install
GOSTARTINSTALL=1
#Find all software entires of AUTO_SETUP_INSTALL_SOFTWARE_ID= in dietpi.txt. Then set to state 1 for installation.
while read -r line
do
local index=$( echo -e "$line" | grep '^AUTO_SETUP_INSTALL_SOFTWARE_ID=' | sed 's/[^0-9]*//g' )
# - Flag for installation
if [[ $index =~ ^-?[0-9]+$ ]]; then
aSOFTWARE_INSTALL_STATE[$index]=1
G_DIETPI-NOTIFY 2 "Automation: ${aSOFTWARE_WHIP_NAME[$index]}. Flagged for installation."
fi
done < /DietPi/dietpi.txt
fi
#Further Automated options. (Applied regardless of AUTOINSTALL_ENABLED)
INDEX_SSHSERVER_TARGET=$AUTOINSTALL_SSHINDEX
INDEX_FILESERVER_TARGET=$AUTOINSTALL_FILESERVERINDEX
INDEX_LOGGING_TARGET=$AUTOINSTALL_LOGGINGINDEX
INDEX_WEBSERVER_TARGET=$AUTOINSTALL_WEBSERVERINDEX
# - IPversion preference: https://github.com/Fourdee/DietPi/issues/472
/DietPi/dietpi/func/dietpi-set_hardware preferipversion "$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PREFER_IPVERSION=' | sed 's/.*=//')"
}
FirstRun_DietPi_Update(){
#Disable powersaving on main screen
setterm -blank 0 -powersave off 2> /dev/null
#-1 = 1st run | 0 = Reboot, updates applied | 1 = Idle, No updates
#Update .update_stage file to completed
echo 1 > /DietPi/dietpi/.update_stage
#Update APT
G_AGUP
#Check for updates and apply if needed (1=force apply updates).
/DietPi/dietpi/dietpi-update 1
#Check update stage file again (dietpi-update will set to 0 if an update was applied and requires a reboot)
if (( $(cat /DietPi/dietpi/.update_stage) == 0 )); then
#Update .update_stage file to completed
echo 1 > /DietPi/dietpi/.update_stage
#Prompt user for reboot
if (( $G_USER_INPUTS )); then
WHIP_TITLE='DietPi Update Completed'
whiptail --title "$WHIP_TITLE" --msgbox "DietPi has been updated to the latest version.\nYour system will now reboot. Once completed, simply login to resume DietPi Setup. \n\nPress Enter to Continue." 13 65
fi
#Reboot required NOW
reboot
Exit_Destroy
fi
}
#/////////////////////////////////////////////////////////////////////////////////////
# Internet Connection Test Vars
#/////////////////////////////////////////////////////////////////////////////////////
#Use /etc/apt/sources.list for connection test
INTERNET_URL_TEST=$(grep -m1 'deb ' /etc/apt/sources.list | awk '{print $2}')
Check_Internet_Connection(){
G_CHECK_URL "$INTERNET_URL_TEST" #will exit on failure here
}
#/////////////////////////////////////////////////////////////////////////////////////
# Globals
#/////////////////////////////////////////////////////////////////////////////////////
Input_Modes(){
# - Skip menu
TARGETMENUID=-1
DISABLE_REBOOT=1
local ainput=("$@")
#Install software and exit.
if [ "$1" = "install" ] || [ "$1" = "reinstall" ] || [ "$1" = "uninstall" ] ; then
G_DIETPI-NOTIFY 3 DietPi-Software "Automated $1"
sleep 1
# - Make sure we have at least one entry
if [ -z "$2" ]; then
G_DIETPI-NOTIFY 1 "Please enter a software index ID, or, choice system INDEX_*_TARGET=-?"
else
# - Uninstall | Stop services prior
if [ "$1" = "uninstall" ]; then
# - stop services
/DietPi/dietpi/dietpi-services stop
fi
# - Process inputs
for i in "${ainput[@]}"
do
#Valid int means input is unique ID for software index to be installed
if [[ $i =~ ^-?[0-9]+$ ]]; then
if [ "$1" = "uninstall" ]; then
Uninstall_Software "$i"
elif [ "$1" = "reinstall" ]; then
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 2 )); then
# - We cant uninstall, may remove additional packages. eg: remove Xserver = Remove every Xserver depandant program like Kodi.
#Uninstall_Software $i
# - So lets flag to be installed
aSOFTWARE_INSTALL_STATE[$i]=1
GOSTARTINSTALL=1
G_DIETPI-NOTIFY 0 "Reinstalling ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}"
sleep 1
else
G_DIETPI-NOTIFY 2 "$i: ${aSOFTWARE_WHIP_NAME[$i]} is not currently installed"
G_DIETPI-NOTIFY 2 "The program must be installed, before reinstall can be used"
G_DIETPI-NOTIFY 0 "No changes applied for: ${aSOFTWARE_WHIP_NAME[$i]}"
fi
elif [ "$1" = "install" ]; then
if (( ${aSOFTWARE_INSTALL_STATE[$i]} != 2 )); then
aSOFTWARE_INSTALL_STATE[$i]=1
GOSTARTINSTALL=1
G_DIETPI-NOTIFY 0 "Installing ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}"
sleep 0.5
else
G_DIETPI-NOTIFY 2 "$i: ${aSOFTWARE_WHIP_NAME[$i]} is already installed"
G_DIETPI-NOTIFY 0 "No changes applied for: ${aSOFTWARE_WHIP_NAME[$i]}"
fi
fi
fi
done
# - Uninstall | Finish up and clear non-required packages
if [ "$1" = "uninstall" ]; then
Uninstall_Software_Finalize
#Save
Write_InstallFileList
# - Start services
/DietPi/dietpi/dietpi-services start
fi
fi
#Apply permissions
elif [ "$1" = "setpermissions" ]; then
Install_Apply_Permissions &> /dev/null
G_DIETPI-NOTIFY 0 "Set permissions completed"
#List unique software names and ID's
elif [ "$1" = "list" ]; then
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
local string=''
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 2 )); then
string="\e[32mID $i | "
else
string="\e[0mID $i | "
fi
string+="=${aSOFTWARE_INSTALL_STATE[$i]} | ${aSOFTWARE_WHIP_NAME[$i]}: \e[90m${aSOFTWARE_WHIP_DESC[$i]}\e[0m |"
if (( ${aSOFTWARE_REQUIRES_ALSA[$i]} == 1 )); then
string+=' +ALSA'
fi
if (( ${aSOFTWARE_REQUIRES_XSERVERXORG[$i]} == 1 )); then
string+=' +XSERVER'
fi
if (( ${aSOFTWARE_REQUIRES_DESKTOP[$i]} == 1 )); then
string+=' +DESKTOP'
fi
if (( ${aSOFTWARE_REQUIRES_RSYSLOG[$i]} == 1 )); then
string+=' +RSYSLOG'
fi
if (( ${aSOFTWARE_REQUIRES_FFMPEG[$i]} == 1 )); then
string+=' +FFMPEG'
fi
if (( ${aSOFTWARE_REQUIRES_ORACLEJAVA[$i]} == 1 )); then
string+=' +ORACLEJAVA'
fi
if (( ${aSOFTWARE_REQUIRES_NODEJS[$i]} == 1 )); then
string+=' +NODEJS'
fi
if (( ${aSOFTWARE_REQUIRES_BUILDESSENTIAL[$i]} == 1 )); then
string+=' +BUILDESSENTIAL'
fi
if (( ${aSOFTWARE_REQUIRES_GIT[$i]} == 1 )); then
string+=' +GIT'
fi
if (( ${aSOFTWARE_REQUIRES_WEBSERVER[$i]} == 1 )); then
string+=' +WEBSERVER'
fi
if (( ${aSOFTWARE_REQUIRES_MYSQL[$i]} == 1 )); then
string+=' +MYSQL'
fi
if (( ${aSOFTWARE_REQUIRES_SQLITE[$i]} == 1 )); then
string+=' +SQLITE'
fi
# - Available for G_HW_ARCH?
if (( ! ${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$G_HW_ARCH]} )); then
string+=" \e[31mDISABLED for G_HW_ARCH\e[0m"
fi
# - Available for G_HW_MODEL?
if (( ! ${aSOFTWARE_AVAIL_G_HW_MODEL[$i,$G_HW_MODEL]} )); then
string+=" \e[31mDISABLED for G_HW_MODEL\e[0m"
fi
# - Online docs
if [ -n "${aSOFTWARE_ONLINEDOC_URL[$i]}" ]; then
string+=" | \e[90m$FP_ONLINEDOC_URL${aSOFTWARE_ONLINEDOC_URL[$i]}\e[0m"
fi
#Convert string to lowercase (easier to | grep stuff)
echo -e "${string,,}" #Much faster than echo -e $(echo -e "$string" | tr '[:upper:]' '[:lower:]')
done
echo -e "Total Software index HARD limit : $TOTAL_SOFTWARE_INDEXS_HARDLIMIT"
echo -e "Total Software index Current : $TOTAL_SOFTWARE_INDEXS"
#List unique software names and ID's
elif [ "$1" = "weblist_export" ]; then
local fp_export_dir='/tmp/dietpi-software/weblist_export'
rm -R "$fp_export_dir"
mkdir -p "$fp_export_dir"
# - Category desc | Remove '─' before saving.
local fp_target="$fp_export_dir/category_dietpi_total"
echo -e "$MAX_SOFTWARE_CATEGORIES_DIETPI" > "$fp_target"
local fp_target="$fp_export_dir/category_linux_total"
echo -e "$MAX_SOFTWARE_CATEGORIES_LINUX" > "$fp_target"
fp_target="$fp_export_dir/category_dietpi_desc"
for ((i=0; i<$MAX_SOFTWARE_CATEGORIES_DIETPI; i++))
do
local output=
echo -e "$( echo ${aSOFTWARE_CATEGORIES_DIETPI[$i]} | sed 's/─//g')" >> "$fp_target"
done
fp_target="$fp_export_dir/category_linux_desc"
for ((i=0; i<$MAX_SOFTWARE_CATEGORIES_LINUX; i++))
do
echo -e "$( echo ${aSOFTWARE_CATEGORIES_LINUX[$i]} | sed 's/─//g')" >> "$fp_target"
done
# - Software list
local fp_target="$fp_export_dir/total_software_index"
echo -e "$TOTAL_SOFTWARE_INDEXS" > "$fp_target"
fp_target="$fp_export_dir/software_installed_state"
printf "%i\n" "${aSOFTWARE_INSTALL_STATE[@]}" > "$fp_target"
fp_target="$fp_export_dir/software_name"
printf "%s\n" "${aSOFTWARE_WHIP_NAME[@]}" > "$fp_target"
fp_target="$fp_export_dir/software_desc"
printf "%s\n" "${aSOFTWARE_WHIP_DESC[@]}" > "$fp_target"
fp_target="$fp_export_dir/category_index"
printf "%i\n" "${aSOFTWARE_CATEGORY_INDEX[@]}" > "$fp_target"
fp_target="$fp_export_dir/software_urldocs"
printf "%s\n" "${aSOFTWARE_ONLINEDOC_URL[@]}" > "$fp_target"
# - Available for device?
fp_target="$fp_export_dir/software_available_hw_model"
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
printf "%i\n" "${aSOFTWARE_AVAIL_G_HW_MODEL[$i,$G_HW_MODEL]}" >> "$fp_target"
done
fp_target="$fp_export_dir/software_available_hw_arch"
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
printf "%i\n" "${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$G_HW_ARCH]}" >> "$fp_target"
done
# - Flagged Prereqs for installation
# fp_target="$fp_export_dir/installs_alsa"
# printf "%s\n" "${aSOFTWARE_REQUIRES_ALSA[@]}" > "$fp_target"
# fp_target="$fp_export_dir/installs_xserver"
# printf "%s\n" "${aSOFTWARE_REQUIRES_XSERVERXORG[@]}" > "$fp_target"
# fp_target="$fp_export_dir/installs_desktop"
# printf "%s\n" "${aSOFTWARE_REQUIRES_DESKTOP[@]}" > "$fp_target"
else
G_DIETPI-NOTIFY 2 "Unknown command $1"
fi
unset ainput
}
Exit_Destroy(){
Software_Arrays_Destroy
exit
}
#/////////////////////////////////////////////////////////////////////////////////////
# Error Functions
#/////////////////////////////////////////////////////////////////////////////////////
ERROR_TEXT=""
Error_Display(){
#Automation | Save to logfile
if (( $G_USER_INPUTS )); then
whiptail --title "Error" --msgbox "$ERROR_TEXT" 18 70
else
echo -e "Error: $ERROR_TEXT" >> "$FP_DIETPIAUTOMATION_LOG"
fi
}
#/////////////////////////////////////////////////////////////////////////////////////
# Whip menus
#/////////////////////////////////////////////////////////////////////////////////////
WHIP_BACKTITLE='DietPi-Software'
WHIP_TITLE=0
WHIP_QUESTION=0
MENU_MAIN_LASTITEM='Help!'
TARGETMENUID=0
Menu_CreateSoftwareList(){
#software type for this menu
local software_type=$1 #0=dietpi 1=linux
local max_categories=$MAX_SOFTWARE_CATEGORIES_DIETPI
if (( $1 == 1 )); then
max_categories=$MAX_SOFTWARE_CATEGORIES_LINUX
fi
#-----------------------------------------------------------------------------
#Generate Whiptail menu list based on category
local whiptail_list=()
for ((i=0; i<$max_categories; i++))
do
#Only add the category if we have software for it.
local category_enabled=0
#Now run through all available software
for ((j=0; j<$TOTAL_SOFTWARE_INDEXS; j++))
do
#Check if this software matches the current category and sofware type for this menu.
# - I originally had "aSOFTWARE_AVAIL_G_HW_MODEL" and "aSOFTWARE_AVAIL_G_HW_ARCH" in one 'if' statement below, however, this seems to takes 4x longer to process in bash.
if (( ${aSOFTWARE_CATEGORY_INDEX[$j]} == $i && ${aSOFTWARE_TYPE[$j]} == $software_type )); then
# + is available for hardware?
# + is available for distro?
if (( ${aSOFTWARE_AVAIL_G_HW_MODEL[$j,$G_HW_MODEL]} &&
${aSOFTWARE_AVAIL_G_HW_ARCH[$j,$G_HW_ARCH]} )); then
local selected="off"
if (( ${aSOFTWARE_INSTALL_STATE[$j]} > 0 )); then
selected="on"
if (( ${aSOFTWARE_INSTALL_STATE[$j]} == 1 )); then
#Reset to 0. Menu checklists will apply back to 1
aSOFTWARE_INSTALL_STATE[$j]=0
fi
fi
#Add category
if (( $category_enabled == 0 )); then
# - dietpi
if (( $1 == 0 )); then
whiptail_list+=("" "${aSOFTWARE_CATEGORIES_DIETPI[$i]}" "off")
# - linux
elif (( $1 == 1 )); then
whiptail_list+=("" "${aSOFTWARE_CATEGORIES_LINUX[$i]}" "off")
fi
category_enabled=1
fi
#Add this option to whiptail list
whiptail_list+=("$j" "${aSOFTWARE_WHIP_NAME[$j]}: ${aSOFTWARE_WHIP_DESC[$j]}" "$selected")
fi
fi
done
done
#-----------------------------------------------------------------------------
WHIP_TITLE='DietPi Software Selection'
whiptail --title "$WHIP_TITLE" --checklist --separate-output "Please use the spacebar to select the software you wish to install.\nSoftware details: http://dietpi.com/software" --backtitle "$WHIP_BACKTITLE" 22 78 14 "${whiptail_list[@]}" 2>/tmp/dietpi-software_results
#delete[]
unset whiptail_list
#Reset Choices made flag
# - dietpi
if (( $1 == 0 )); then
INSTALL_DIETPI_CHOICESMADE=0
# - linux
elif (( $1 == 1 )); then
INSTALL_LINUX_CHOICESMADE=0
fi
#Check for matching results (selected items)
while read choice
do
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
#enable
if (( $choice == $i &&
${aSOFTWARE_INSTALL_STATE[$i]} == 0 )); then
# - dietpi
if (( $1 == 0 )); then
INSTALL_DIETPI_CHOICESMADE=1
# - linux
elif (( $1 == 1 )); then
INSTALL_LINUX_CHOICESMADE=1
fi
aSOFTWARE_INSTALL_STATE[$i]=1
break
fi
done
done < /tmp/dietpi-software_results
rm /tmp/dietpi-software_results &> /dev/null
}
Menu_Main(){
#Data for storing SSH server index info
local index_sshserver_text="None"
if (( $INDEX_SSHSERVER_TARGET == -1 )); then
index_sshserver_text="Dropbear"
elif (( $INDEX_SSHSERVER_TARGET == -2 )); then
index_sshserver_text="OpenSSH"
fi
#Data for storing Fileserver index info
local index_fileserver_text="None"
if (( $INDEX_FILESERVER_TARGET == -1 )); then
index_fileserver_text="ProFTP"
elif (( $INDEX_FILESERVER_TARGET == -2 )); then
index_fileserver_text="Samba"
fi
#Data for storing Logging index info
local index_logging_text="None"
if (( $INDEX_LOGGING_TARGET == -1 )); then
index_logging_text="DietPi-Ramlog #1"
elif (( $INDEX_LOGGING_TARGET == -2 )); then
index_logging_text="DietPi-Ramlog #2"
elif (( $INDEX_LOGGING_TARGET == -3 )); then
index_logging_text="Full"
fi
#Hold our string that tells the user what software will be removed when using Index based choice systems
local toberemoved_text=''
#Check status of USB drive
Check_USB_Drive_Installed
#Where is userdata stored?
local user_data_location_current=$(readlink -f $G_FP_DIETPI_USERDATA)
local user_data_location_description=''
if [ "$user_data_location_current" = "$FP_DIETPI_DEDICATED_USBDRIVE" ]; then
user_data_location_description="USB Drive | $user_data_location_current"
elif [ "$user_data_location_current" = "$G_FP_DIETPI_USERDATA" ]; then
user_data_location_description="SD/EMMC | $user_data_location_current"
else
user_data_location_description="Custom | $user_data_location_current"
fi
# - Webserver preference system
local index_webserver_text='Apache2'
if (( $INDEX_WEBSERVER_TARGET == -1 )); then
index_webserver_text='Nginx'
elif (( $INDEX_WEBSERVER_TARGET == -2 )); then
index_webserver_text='Lighttpd'
fi
WHIP_TITLE='DietPi-Software'
WHIP_BACKTITLE="DietPi-Software | IP: $(sed -n 4p /DietPi/dietpi/.network) | Device: $G_HW_MODEL_DESCRIPTION"
OPTION=$(whiptail --title "$WHIP_TITLE" --backtitle "$WHIP_BACKTITLE" --menu "" --default-item "$MENU_MAIN_LASTITEM" --cancel-button "Exit" 20 100 13 \
"Help!" "Links to online guides, docs and information" \
"DietPi-Config" "Feature-rich configuration tool for your device" \
"" "─── Select Software ─────────────────────────" \
"Software Optimized" "Select DietPi optimized software for installation" \
"Software Additional" "Select additional Linux software for installation" \
"SSH Server" ": $index_sshserver_text" \
"File Server" ": $index_fileserver_text" \
"Log System" ": $index_logging_text" \
"Webserver Preference" ": $index_webserver_text" \
"User Data Location" ": $user_data_location_description" \
"" "─── Install or Remove Software ──────────────" \
"Uninstall" "Select installed software for removal" \
"Install" "Go >> Start installation for selected software" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
MENU_MAIN_LASTITEM="$OPTION"
case "$OPTION" in
"Uninstall")
TARGETMENUID=3
;;
"Software Optimized")
TARGETMENUID=1
;;
"Software Additional"*)
TARGETMENUID=2
;;
"SSH Server")
WHIP_TITLE='SSH Server Choices'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "> None\nSelecting this option will uninstall all SSH servers. This reduces system resources and improves performance. Useful for users who do NOT require networked/remote terminal access.\n\n> Dropbear (Recommended)\nLightweight SSH server, installed by default on DietPi systems.\n\n> OpenSSH\nA feature rich SSH server with SFTP/SCP support, at the cost of increased resource usage." --cancel-button "Back" --default-item "$index_sshserver_text" 21 75 3 \
"None" "Not required / manual setup." \
"Dropbear" "Lightweight SSH Server (Recommended)." \
"OpenSSH" "Feature Rich SSH Server with SFTP/SCP support." 3>&1 1>&2 2>&3)
#Assign target index
if [ "$OPTION" = "None" ]; then
INDEX_SSHSERVER_TARGET=0
toberemoved_text="Dropbear and OpenSSH Server"
elif [ "$OPTION" = "Dropbear" ]; then
INDEX_SSHSERVER_TARGET=-1
toberemoved_text="OpenSSH Server"
elif [ "$OPTION" = "OpenSSH" ]; then
INDEX_SSHSERVER_TARGET=-2
toberemoved_text="Dropbear"
#Reset to current
else
INDEX_SSHSERVER_TARGET=$INDEX_SSHSERVER_CURRENT
fi
#Check for changes
INSTALL_SSHSERVER_CHOICESMADE=0
if (( $INDEX_SSHSERVER_TARGET != $INDEX_SSHSERVER_CURRENT )); then
INSTALL_SSHSERVER_CHOICESMADE=1
#Inform user
WHIP_TITLE="SSH Server Change"
WHIP_QUESTION="$OPTION has been selected:\n- Your choice will be applied when 'Install Go >> Start installation' is selected.\n- $toberemoved_text installations will be automatically uninstalled."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
fi
;;
"File Server")
WHIP_TITLE='Fileserver Choices'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "> None\nSelect this option if you do NOT require a method of accessing files and folders on this device, over a network.\n\n> ProFTP (Recommended for RPi v1)\nAllows you to access/share files on this device efficiently with minimal cpu usage. Uses FTP protocol.\n\n> Samba (Recommended for RPi v2)\nAllows you to easily access/share files on this device, at the cost of higher cpu usage.\n\nMore info: http://dietpi.com/phpbb/viewtopic.php?f=8&t=15#p19" --cancel-button "Back" --default-item "$index_fileserver_text" 23 75 3 \
"None" "Not required / manual setup." \
"ProFTP" "Efficient, lightweight fileserver (recommended)." \
"Samba" "Feature-rich fileserver." 3>&1 1>&2 2>&3)
#Assign target index
if [ "$OPTION" = "None" ]; then
INDEX_FILESERVER_TARGET=0
toberemoved_text="ProFTP and Samba Server"
elif [ "$OPTION" = "ProFTP" ]; then
INDEX_FILESERVER_TARGET=-1
toberemoved_text="Samba Server"
elif [ "$OPTION" = "Samba" ]; then
INDEX_FILESERVER_TARGET=-2
toberemoved_text="ProFTP"
#Reset to current
else
INDEX_FILESERVER_TARGET=$INDEX_FILESERVER_CURRENT
fi
#Check for changes
INSTALL_FILESERVER_CHOICESMADE=0
if (( $INDEX_FILESERVER_TARGET != $INDEX_FILESERVER_CURRENT )); then
INSTALL_FILESERVER_CHOICESMADE=1
#Inform user
WHIP_TITLE="Fileserver Choice Change"
WHIP_QUESTION="$OPTION has been selected:\n- Your choice will be applied when 'Install Go >> Start installation' is selected.\n- $toberemoved_text installations will be automatically uninstalled."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
fi
;;
"Log System")
WHIP_TITLE='Logging System Choices'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "> None\nSelecting this option will uninstall DietPi-Ramlog, Logrotate, Rsyslog.\n\n> DietPi-Ramlog #1 (Max performance)\nMounts /var/log to RAM, reducing filesystem IO. Logfiles are cleared every hour. Does NOT save logfiles to disk.\n\n> DietPi-Ramlog #2\nSame as #1, with the added feature of saving logfile contents to disk ($HOME/logfile_storage/*), before being cleared.\n\n> Full (Reduces performance)\nMounts /var/log to DISK, reduces SDcard lifespan. Full logging system with Logrotate and Rsyslog." --cancel-button "Back" --default-item "$index_logging_text" 25 75 4 \
"None" " Not required / manual setup." \
"DietPi-Ramlog #1" " Hourly clear (recommended)." \
"DietPi-Ramlog #2" " Hourly save, then clear." \
"Full" " Logrotate and Rsyslog." 3>&1 1>&2 2>&3)
#Assign target index
if [ "$OPTION" = "None" ]; then
INDEX_LOGGING_TARGET=0
toberemoved_text="DietPi-Ramlog, Logrotate, Rsyslog"
elif [ "$OPTION" = "DietPi-Ramlog #1" ]; then
INDEX_LOGGING_TARGET=-1
toberemoved_text="Logrotate, Rsyslog"
elif [ "$OPTION" = "DietPi-Ramlog #2" ]; then
INDEX_LOGGING_TARGET=-2
toberemoved_text="Logrotate, Rsyslog"
elif [ "$OPTION" = "Full" ]; then
INDEX_LOGGING_TARGET=-3
toberemoved_text="DietPi-Ramlog"
#Reset to current
else
INDEX_LOGGING_TARGET=$INDEX_LOGGING_CURRENT
fi
#Check for changes
INSTALL_LOGGING_CHOICESMADE=0
if (( $INDEX_LOGGING_TARGET != $INDEX_LOGGING_CURRENT )); then
INSTALL_LOGGING_CHOICESMADE=1
#Inform user
WHIP_TITLE="Logging System Change"
WHIP_QUESTION="$OPTION has been selected:\n- Your choice will be applied when 'Install Go >> Start installation' is selected.\n- $toberemoved_text installations will be automatically uninstalled."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
fi
;;
"User Data Location")
WHIP_TITLE='User Data Location'
# - Vars if we need to move data.
local move_data_target=$user_data_location_current
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Choose where to store your user data. User data includes software such as Owncloud data store, BitTorrent downloads etc\n\nMore information on user data in DietPi:\n - http://dietpi.com/phpbb/viewtopic.php?f=8&t=478&p=2087\n\n> DietPi-Drive Manager\nLaunch DietPi-Drive Manager to setup external drives, and, move user data to different locations." --cancel-button "Back" 20 85 3 \
"Drive Manager" "Launches DietPi-Drive Manager" \
"List" "Select from a list of available mounts/drives, to move user data" \
"Custom" "Input a manual location to move user data" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
# - DriveMan
if [ "$OPTION" = "Drive Manager" ]; then
/DietPi/dietpi/dietpi-drive_manager
# - List
elif [ "$OPTION" = "List" ]; then
/DietPi/dietpi/dietpi-drive_manager 1
local return_value="$(cat /tmp/dietpi-drive_manager_selmnt)"
if [ -n "$return_value" ]; then
if [ "$return_value" = "/" ]; then
return_value='/mnt'
fi
move_data_target="$return_value"
move_data_target+='/dietpi_userdata'
fi
# - Manual filepath entry
elif [ "$OPTION" = "Custom" ]; then
OPTION=$(whiptail --inputbox "Please input a location. Your user data will be stored inside this location.\n - eg: /mnt/MyDrive/MyData" 11 60 "$user_data_location_current" --title "User/Personal Data Directory" --backtitle "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
move_data_target=$OPTION
fi
fi
# - Move data if the new entry has changed
if [ "$user_data_location_current" != "$move_data_target" ]; then
# - Ask before we begin
whiptail --title "User data transfer" --yesno "DietPi will now attempt to transfer your existing user data to the new location:\n\n - From: $user_data_location_current\n - To: $move_data_target\n\nWould you like to begin?" --backtitle "$WHIP_BACKTITLE" --defaultno 14 70
CHOICE=$?
if (( $CHOICE == 0 )); then
# - Move data, setup symlinks
/DietPi/dietpi/func/dietpi-set_userdata "$user_data_location_current" "$move_data_target"
if (( $? == 0 )); then
whiptail --title "User data transfer: Completed" --msgbox "Your user data has been sucessfuly moved:\n\n - From: $user_data_location_current\n - To: $move_data_target" 12 70
else
whiptail --title "User data transfer: Failed" --msgbox "$(cat /var/log/dietpi-move_userdata.log)\nNo changes have been applied." 12 70
fi
fi
fi
fi
;;
"Webserver Preference")
WHIP_TITLE='Webserver Preference'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "More Info: http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=1549#p1549\n\n> Apache2\nFeature-rich and popular. Recommended for beginners and users who are looking to follow Apache2 based guides.\n\n> Nginx\nLightweight alternative to Apache2. Nginx claims faster webserver performance compared to Apache2.\n\n> Lighttpd\nExtremely lightweight and is generally considered to offer the \"best\" webserver performance for SBC's. Recommended for users who expect low webserver traffic." --cancel-button "Back" --default-item "$index_webserver_text" 24 75 3 \
"Apache2" "Popular webserver." \
"Nginx" "Lightweight webserver." \
"Lighttpd" "Extremely lightweight webserver." 3>&1 1>&2 2>&3)
#Assign target index
if [ "$OPTION" = "Apache2" ]; then
INDEX_WEBSERVER_TARGET=0
elif [ "$OPTION" = "Nginx" ]; then
INDEX_WEBSERVER_TARGET=-1
elif [ "$OPTION" = "Lighttpd" ]; then
INDEX_WEBSERVER_TARGET=-2
#Reset to current
else
INDEX_WEBSERVER_TARGET=$INDEX_WEBSERVER_CURRENT
fi
#Check for changes
if (( $INDEX_WEBSERVER_TARGET != $INDEX_WEBSERVER_CURRENT )); then
# - Check for existing and compatible installed stacks before allowing the change
local incompatible_webserver_preference=0
local info_currently_installed_webserver='None'
if (( $(dpkg -l | awk '{print $2}' | grep -ci -m1 'apache2'))); then
INDEX_WEBSERVER_CURRENT=0
info_currently_installed_webserver='Apache2'
if (( $INDEX_WEBSERVER_TARGET != 0 )); then
incompatible_webserver_preference=1
fi
elif (( $(dpkg -l | awk '{print $2}' | grep -ci -m1 'nginx') )); then
INDEX_WEBSERVER_CURRENT=-1
info_currently_installed_webserver='Nginx'
if (( $INDEX_WEBSERVER_TARGET != -1 )); then
incompatible_webserver_preference=1
fi
elif (( $(dpkg -l | awk '{print $2}' | grep -ci -m1 'lighttpd') )); then
INDEX_WEBSERVER_CURRENT=-2
info_currently_installed_webserver='Lighttpd'
if (( $INDEX_WEBSERVER_TARGET != -2 )); then
incompatible_webserver_preference=1
fi
fi
# - Reset preference selection
if (( $incompatible_webserver_preference == 1 )); then
INDEX_WEBSERVER_TARGET=$INDEX_WEBSERVER_CURRENT
# - inform user
WHIP_TITLE="Error: Incompatible Webserver Preference"
WHIP_QUESTION="Unable to change your webserver preference to $OPTION.\n\nThis is due to an existing and incompatible webserver installation on your system ($info_currently_installed_webserver). Please remove all webserver based software (using dietpi-software > uninstall), before trying again."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
# - Apply preference selection
else
# - Inform user
WHIP_TITLE="Webserver Preference Changed"
WHIP_QUESTION="$OPTION has been selected as your webserver preference.\n\nWhen you select any software for install that requires a webserver, DietPi will automatically install your prefered choice ($OPTION)."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 75
# - NB: INDEX_WEBSERVER_CURRENT=$INDEX_WEBSERVER_TARGET | is applied during installation with func Apply_Webserver_Preference().
fi
fi
;;
"DietPi-Config")
/DietPi/dietpi/dietpi-config
;;
"Help!")
#Populate help to text file so we can read it back to whiptail, as a scrollbox.
cat << _EOF_ > /tmp/dietpi-software_help_onlinedoc_url_list
───────────────────────────────────────────────────────────────
Welcome to DietPi:
───────────────────────────────────────────────────────────────
Use PageUp/Down or Arrow Up/Down to scroll this help screen.
Press ESC, or TAB then enter to exit this help screen.
Easy to follow, step by step guides for installing DietPi:
http://dietpi.com/phpbb/viewtopic.php?f=8&t=9
For a list of all installation options and their details:
http://dietpi.com/software
───────────────────────────────────────────────────────────────
List of installed software and their URL links for online docs:
───────────────────────────────────────────────────────────────
_EOF_
# - Installed software
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
if (( ${aSOFTWARE_INSTALL_STATE[$i]} > 0 )); then
if [ -n "${aSOFTWARE_ONLINEDOC_URL[$i]}" ]; then
cat << _EOF_ >> /tmp/dietpi-software_help_onlinedoc_url_list
${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_NAME[$i]}
$FP_ONLINEDOC_URL${aSOFTWARE_ONLINEDOC_URL[$i]}
_EOF_
fi
fi
done
whiptail --title "DietPi - Help" --backtitle "$WHIP_BACKTITLE" --textbox /tmp/dietpi-software_help_onlinedoc_url_list $(( $(tput lines) - 3 )) $(( $(tput cols) - 3 )) --scrolltext
;;
Install)
Menu_StartInstall
;;
esac
#Exit/Abort Setup
else
Menu_Exit
fi
}
Menu_Exit(){
#1st run install
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
WHIP_TITLE='Exit Setup?'
WHIP_QUESTION=' DietPi has not fully been installed.\n This must be completed prior to using DietPi by selecting:\n - Go Start Install. \n \n Would you like to exit and abort the installation?'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" --yes-button "Ok" --no-button "Back" --defaultno 13 65
CHOICE=$?
if (( $CHOICE == 0 )); then
Banner_Aborted
#Exit script NOW
Exit_Destroy
else
#Return to Main Menu
TARGETMENUID=0
fi
#Standard exit
elif (( $G_DIETPI_INSTALL_STAGE == 1 )); then
WHIP_TITLE='Exit DietPi-Software?'
WHIP_QUESTION='Do you wish to exit DietPi-Software?\n\nAll changes to software selections will be cleared.'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" --yes-button "Ok" --no-button "Back" --defaultno 11 65
CHOICE=$?
if (( $CHOICE == 0 )); then
Banner_Aborted
#Exit script NOW
Exit_Destroy
else
#Return to Main Menu
TARGETMENUID=0
fi
fi
}
Menu_ConfirmInstall(){
#Obtain list of pending software installation:
local string_output=''
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 1 )); then
string_output+="\n - ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}"
fi
done
#Confirm Software install
WHIP_TITLE='DietPi - Start Installation?'
WHIP_QUESTION="DietPi is now ready to install your software choices: $string_output\n\nSoftware details, usernames, passwords etc:\n - http://dietpi.com/software\n\nWould you like to begin?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 20 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#exit menu system
TARGETMENUID=-1
#Enable installation start flag
GOSTARTINSTALL=1
else
#Return to Main Menu
TARGETMENUID=0
fi
}
Menu_StartInstall(){
#Check if the user has made changes to their software selections.
if (( $INSTALL_DIETPI_CHOICESMADE ||
$INSTALL_LINUX_CHOICESMADE ||
$INSTALL_SSHSERVER_CHOICESMADE ||
$INSTALL_FILESERVER_CHOICESMADE ||
$INSTALL_LOGGING_CHOICESMADE )); then
# Confirm install with user
Menu_ConfirmInstall
else
#1st run install
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
WHIP_TITLE='No Software Selected. Continue?'
WHIP_QUESTION='DietPi was unable to detect any software selections for install. Do you wish to continue?\n\nBy selecting Ok: \n- DietPi optimized software will NOT be installed.\nYou can use dietpi-software at a later date if you change your mind. \n\n- You want a Minimal Raspbian/Debian Server Install.\nDietPi is a minimal image. A great OS base to use with your projects.'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" --yes-button "Ok" --no-button "Back" --defaultno 16 75
CHOICE=$?
if (( $CHOICE == 0 )); then
#exit menu system
TARGETMENUID=-1
#Enable installation start flag
GOSTARTINSTALL=1
else
#Return to Main Menu
TARGETMENUID=0
fi
#Not 1st run
elif (( $G_DIETPI_INSTALL_STAGE == 1 )); then
WHIP_TITLE='No Changes to Software Selection'
whiptail --title "$WHIP_TITLE" --msgbox "No changes have been detected. Unable to start installation." 8 65
fi
fi
}
#TARGETMENUID=1
Menu_Dietpi_Software(){
#-----------------------------------------------------------------------------
#Generate Whiptail menu and store results into our software arrays
Menu_CreateSoftwareList 0
#Return to Main Menu
TARGETMENUID=0
#-----------------------------------------------------------------------------
#Install Info/Warnings
#OMV, .deb package has Nginx as a dependancy. Not compatible with other webservers
if (( ${aSOFTWARE_INSTALL_STATE[126]} == 1 &&
( ${aSOFTWARE_INSTALL_STATE[77]} == 0 && ${aSOFTWARE_INSTALL_STATE[78]} == 0 && ${aSOFTWARE_INSTALL_STATE[79]} == 0 && $INDEX_WEBSERVER_TARGET != -1 ) )); then
WHIP_TITLE='OMV: Requires Nginx'
WHIP_QUESTION="Open Media Vault (OMV) requires Nginx webserver and is not compatible with other web servers (eg: Lighttpd/Apache2). This is due to the OMV package listing Nginx as a dependency.\n\nOptions:\n - Change 'web server choice' to 'Nginx'\n - Uninstall current web server, then, select any Nginx web stack for install (eg: LESP)\n\nOpen Media Vault has been deselected and will not be installed."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 19 70
aSOFTWARE_INSTALL_STATE[126]=0
fi
#SickRage, setup for Transmission, install it aswell?
if (( ${aSOFTWARE_INSTALL_STATE[116]} == 1 &&
${aSOFTWARE_INSTALL_STATE[44]} == 0 )); then
WHIP_TITLE='SickRage - Install Transmission?'
WHIP_QUESTION="The DietPi SickRage installation is pre-configured to work with Transmission BitTorrent Server. This will allow SickRage to automatically download TV shows for you.\n\nNB: If you have another BitTorrent server installed, or prefer manual setup, please select No.\n\nWould you like DietPi to also install Transmission (recommended)?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --defaultno --backtitle "$WHIP_BACKTITLE" 14 72
CHOICE=$?
if (( $CHOICE == 0 )); then
aSOFTWARE_INSTALL_STATE[44]=1
fi
fi
#Gogs: Requires OpenSSH for ssh-keygen binary: https://github.com/Fourdee/DietPi/issues/442
if (( ${aSOFTWARE_INSTALL_STATE[49]} == 1 && $INDEX_SSHSERVER_TARGET != -2 )); then
WHIP_TITLE='Gogs: Requires OpenSSH'
WHIP_QUESTION="Gogs requires OpenSSH server to function.\nIf you continue, OpenSSH will be selected for install on your system. OpenSSH will also replace Dropbear (if currently installed).\n\nWould you like to continue with the Gogs installation?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --defaultno --backtitle "$WHIP_BACKTITLE" 13 65
CHOICE=$?
if (( $CHOICE == 0 )); then
# - Use SSH target index to ensure Dropbear gets removed if installed.
INDEX_SSHSERVER_TARGET=-2
else
aSOFTWARE_INSTALL_STATE[49]=0
fi
fi
#Webserver stacks
for ((i=74; i<=82; i++))
do
#Please let DietPi install them for you...
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 1 )); then
WHIP_TITLE='Info: Webserver Stack'
WHIP_QUESTION="DietPi will automatically install a webserver stack (based on your Webserver Preference) when any software that requires a webserver is selected for installation (eg: Owncloud, PiHole etc).\n\nIt is highly recommended that you allow DietPi to do this for you, ensuring compatibility and stability across DietPi installed programs.\n\nPlease only select a webserver stack if you specifically need it, and, no other webserver stack is installed.\n\nTLDR: You do NOT need to select a webserver stack for installation with DietPi. Its all automatic."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 19 70
break
fi
done
#phpmyadmin + Lighttpd | broken apt-get installation. User must have a fully installed LLM* stack before phpmyadmin can be selected:
#https://github.com/Fourdee/DietPi/issues/316#issuecomment-219474664
if (( ${aSOFTWARE_INSTALL_STATE[90]} == 1 &&
$INDEX_WEBSERVER_TARGET == -2 &&
( ${aSOFTWARE_INSTALL_STATE[80]} < 2 && ${aSOFTWARE_INSTALL_STATE[82]} < 2 ) )); then
WHIP_TITLE='PhpMyAdmin'
WHIP_QUESTION="Due to a apt-get installation issue with PhpMyAdmin, you must have a fully installed Lighttpd + MaridaDB webserver stack, before PhpMyAdmin can be selected for install.\n\nYour selection for PhpMyAdmin has been removed."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 13 70
aSOFTWARE_INSTALL_STATE[90]=0
fi
#DietPiCam - warn user of locking out camera: https://github.com/Fourdee/DietPi/issues/249
if (( ${aSOFTWARE_INSTALL_STATE[59]} == 1 )); then
WHIP_TITLE='DietPi Cam - Camera'
WHIP_QUESTION="DietPi Cam will automatically start and activate the camera during boot. This will prevent other programs (eg: raspistill) from using the camera.\n\nYou can free up the camera by selecting \"Stop Camera\" from the web interface:\nhttp://myip/dietpicam"
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 15 70
fi
#EmonHUB/EmonPi
if (( ${aSOFTWARE_INSTALL_STATE[99]} == 1 )); then
# - Enter API KEY
# - Grab key from dietpi.txt
USER_EMONHUB_APIKEY_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_EMONHUB_APIKEY=' | sed 's/.*=//')
while (( $USER_EMONHUB_APIKEY_COMPLETED == 0 )); do
WHIP_TITLE='EmonPi/Hub - API KEY'
WHIP_QUESTION="Please enter your \"Write API KEY\":\n - Goto http://emoncms.org and register an account and login.\n - Select \"Setup\" from the top right of screen, then select \"My Account\"\n - Enter the \"Write API Key\" into the box below."
OPTION=$(whiptail --inputbox "$WHIP_QUESTION" 14 75 "$USER_EMONHUB_APIKEY_CURRENT" --title "$WHIP_TITLE" --backtitle "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
USER_EMONHUB_APIKEY_CURRENT=$OPTION
WHIP_TITLE='EmonPi/Hub - API KEY'
WHIP_QUESTION="The following \"Write API KEY\" will be applied during installation:\n$USER_EMONHUB_APIKEY_CURRENT\n\nIs this key correct?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 11 70
CHOICE=$?
if (( $CHOICE == 0 )); then
# - update dietpi.txt so the value will be applied during installation.
sed -i "/^SOFTWARE_EMONHUB_APIKEY=/c\SOFTWARE_EMONHUB_APIKEY=$USER_EMONHUB_APIKEY_CURRENT" /DietPi/dietpi.txt
USER_EMONHUB_APIKEY_COMPLETED=1
fi
fi
done
fi
#Pi-hole.
if (( ${aSOFTWARE_INSTALL_STATE[93]} == 1 )); then
# - prompt for static ip.
WHIP_TITLE=' Pi-hole - Setup Static IP Now?'
WHIP_QUESTION='A static IP address is essential for Pi-hole installations. DietPi-Config can be used to quickly setup your static IP address.\n\nIf you have already setup your static IP, please ignore this message.\n\nWould you like to setup your static IP address now?'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --defaultno --backtitle "$WHIP_BACKTITLE" 15 70
CHOICE=$?
if (( $CHOICE == 0 )); then
WHIP_TITLE=' Pi-hole - Setup Static IP'
WHIP_QUESTION='DietPi-Config will now be launched. Simply select your Ethernet or Wifi connection from the menu to access the IP address settings.\n\nThe "copy current address to STATIC" menu option can be used to quickly setup your static IP. Please ensure you change the mode "DHCP" to "STATIC".\n\nWhen you are done, select "Apply, Save Changes", then exit DietPi-Config to resume setup.'
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 15 70
#Launch DietPi-config networking menu
/DietPi/dietpi/dietpi-config 8 1
fi
fi
#Wifi Hotspot Criteria
if (( ${aSOFTWARE_INSTALL_STATE[60]} == 1 )) ||
(( ${aSOFTWARE_INSTALL_STATE[61]} == 1 )); then
#Enable wifi modules
/DietPi/dietpi/func/dietpi-set_hardware wifimodules enable
local check_criteria=1
while (( $check_criteria == 1 )); do
local criteria_passed=1
WHIP_TITLE="WiFi Hotspot Criteria"
WHIP_QUESTION="The following criteria must be met for this installation to succeed:"
local ethernet_active_state=$(ip r | grep -ci -m1 "eth$(sed -n 1p /DietPi/dietpi/.network)")
if (( $ethernet_active_state == 1 )); then
WHIP_QUESTION+="\n\n - Ethernet online: PASSED"
else
criteria_passed=0
WHIP_QUESTION+="\n\n - Ethernet online: FAILED.\nUse dietpi-config to connect and configure ethernet."
fi
if [ -d /sys/class/net/wlan$(sed -n 2p /DietPi/dietpi/.network) ]; then
WHIP_QUESTION+="\n\n - Wifi adapter detected: PASSED"
else
criteria_passed=0
WHIP_QUESTION+="\n\n - Wifi adapter detected: FAILED.\nPlease connect a WiFi adapter and try again."
fi
#Passed
if (( $criteria_passed == 1 )); then
WHIP_QUESTION+="\n\nPASSED: Criteria met. Good to go."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 14 75
check_criteria=0
#Failed, retry?
else
WHIP_QUESTION+="\n\nFAILED: Criteria not met. Would you like to check again?"
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 16 75
CHOICE=$?
if (( $CHOICE == 0 )); then
echo "retry" &> /dev/null
else
# - Disable user selection
check_criteria=0
aSOFTWARE_INSTALL_STATE[60]=0
aSOFTWARE_INSTALL_STATE[61]=0
whiptail --title "WiFi Hotspot Failed" --msgbox "WiFi Hotspot criteria was not met. Your selection has been removed." --backtitle "$WHIP_BACKTITLE" 10 65
fi
fi
done
fi
#Weaved
if (( ${aSOFTWARE_INSTALL_STATE[68]} == 1 )); then
WHIP_TITLE='Remot3.it - 1st run setup'
WHIP_QUESTION='Remot3.it requires you to create an online account, and, link it this device.\n\nOnce DietPi has completed your software installations, and rebooted, please follow the First Run tutorial here:\nhttp://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=188#p188'
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 14 70
fi
#LetsEncrypt
if (( ${aSOFTWARE_INSTALL_STATE[92]} == 1 )); then
WHIP_TITLE='Lets Encrypt Info'
WHIP_QUESTION='Currently, the DietPi installation of CertBot supports Apache2 & Lighttpd only.\n\nOnce the installation has finished, you can setup your free SSL cert with:\n - DietPi-LetsEncrypt\n\nThis is a easy to use frontend for CertBot and allows intergration into DietPi systems.\n\nMore information:\n - http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=1061#p1062'
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 18 70
fi
#-----------------------------------------------------------------------------
#dietpi-config can be used to install/configure the following software. Ask user.
#NoIp
if (( ${aSOFTWARE_INSTALL_STATE[67]} == 1 )); then
WHIP_TITLE='NoIp - Setup Now?'
WHIP_QUESTION='NoIp can be setup and configured by using DietPi-Config. Would you like to go there now? \n\n- Once completed, exit DietPi-Config to resume setup. \n\n- More information:\nhttp://dietpi.com/phpbb/viewtopic.php?f=8&t=5&start=10#p58'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Cancel" --defaultno --backtitle "$WHIP_BACKTITLE" 15 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Write installed states to temp
Write_InstallFileList temp
#Launch DietPi-config
/DietPi/dietpi/dietpi-config 16 1
#Read installed states from temp
Read_InstallFileList temp
fi
fi
#-----------------------------------------------------------------------------
#Boot Choices
if (( ${aSOFTWARE_INSTALL_STATE[23]} == 1 ||
${aSOFTWARE_INSTALL_STATE[24]} == 1 ||
${aSOFTWARE_INSTALL_STATE[25]} == 1 ||
${aSOFTWARE_INSTALL_STATE[26]} == 1 ||
${aSOFTWARE_INSTALL_STATE[31]} == 1 ||
${aSOFTWARE_INSTALL_STATE[51]} == 1 ||
${aSOFTWARE_INSTALL_STATE[108]} == 1 ||
${aSOFTWARE_INSTALL_STATE[112]} == 1 ||
${aSOFTWARE_INSTALL_STATE[119]} == 1 ||
${aSOFTWARE_INSTALL_STATE[155]} == 1 )); then
# Set Boot Order
WHIP_TITLE=' DietPi - Boot Options'
WHIP_QUESTION='Would you like to configure the auto boot options for DietPi?\n\nThis will allow you to choose which program loads automatically after booting eg:\n - Console\n - Desktop\n - Kodi'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --defaultno --backtitle "$WHIP_BACKTITLE" 14 70
CHOICE=$?
if (( $CHOICE == 0 )); then
/DietPi/dietpi/dietpi-autostart
fi
fi
}
#TARGETMENUID=2
Menu_Linux_Software(){
#Inform User that DietPi software will automatically install additional linux software when required.
if (( ! $USER_LINUX_AUTOINSTALL_PROMPT_DISPLAYED )); then
WHIP_TITLE='Additional Linux Software'
WHIP_QUESTION='DietPi will automatically install additional Linux software on the next screen, when required (eg: Desktop LXDE will install ALSA + Xserver).\n\nThis means you only need to select the software you actually require.'
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 12 70
USER_LINUX_AUTOINSTALL_PROMPT_DISPLAYED=1
fi
#-----------------------------------------------------------------------------
#Generate Whiptail menu and store results into our software arrays
Menu_CreateSoftwareList 1
#Return to Main Menu
TARGETMENUID=0
#-----------------------------------------------------------------------------
#dietpi-config can be used to install/configure the following software. Ask user.
#CurlFTPfs -
if (( ${aSOFTWARE_INSTALL_STATE[2]} == 1 )); then
WHIP_TITLE='FTP Client - Setup Now?'
WHIP_QUESTION='FTP Client as a filesystem mount (CurlFTPfs) can be setup and configured by using DietPi-Config. Would you like to go there now? \n\n- Once completed, exit DietPi-Config to resume setup.'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Cancel" --defaultno --backtitle "$WHIP_BACKTITLE" 13 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Write installed states to temp
Write_InstallFileList temp
#Launch DietPi-config
/DietPi/dietpi/dietpi-config 16 1
#Read installed states from temp
Read_InstallFileList temp
fi
fi
#SMBCLIENT -
if (( ${aSOFTWARE_INSTALL_STATE[1]} == 1 )); then
WHIP_TITLE='Samba Client - Setup Now?'
WHIP_QUESTION='Samba Client can be setup and configured by using DietPi-Config. Would you like to go there now? \n\n- Once completed, exit DietPi-Config to resume setup.'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Cancel" --defaultno --backtitle "$WHIP_BACKTITLE" 13 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Write installed states to temp
Write_InstallFileList temp
#Launch DietPi-config
/DietPi/dietpi/dietpi-config 16 1
#Read installed states from temp
Read_InstallFileList temp
fi
fi
#-----------------------------------------------------------------------------
}
#TARGETMENUID=3
Menu_Uninstall_Software(){
#Return to main menu
TARGETMENUID=0
#Array which will hold all software indexs to be removed.
local asoftware_for_uninstall=()
local software_installed_count=0
#Obtain list of installed software
for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++))
do
if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 2 &&
${aSOFTWARE_TYPE[$i]} >= -1 )); then
whiptail_list_array+=("$i" "${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}" "off")
((software_installed_count++))
fi
done
# - Hide specific software (eg: stacks) in for loop ?
if (( $software_installed_count == 0 )); then
whiptail --title "Uninstall Software" --msgbox "No software is currently installed, or, available for removal." --backtitle "$WHIP_BACKTITLE" 9 60
#Run menu
else
whiptail --title "Uninstall Software" --checklist --separate-output "Use the spacebar to select the software you would like to remove." --cancel-button "Cancel" --backtitle "$WHIP_BACKTITLE" 18 75 10 "${whiptail_list_array[@]}" 2>/tmp/dietpi-software_uninstall_results
while read choice
do
case $choice in
*)
#Convert lined list into a 1 line string.
asoftware_for_uninstall+=("$choice")
;;
esac
done < /tmp/dietpi-software_uninstall_results
rm /tmp/dietpi-software_uninstall_results &> /dev/null
unset whiptail_list_array
#Prompt user with list of their selected software for removal
if (( ${#asoftware_for_uninstall[@]} > 0 )); then
# - Create list
WHIP_QUESTION='The following software will be REMOVED from your system:\n'
for ((i=0; i<${#asoftware_for_uninstall[@]}; i++))
do
for ((j=0; j<$TOTAL_SOFTWARE_INDEXS; j++))
do
if (( ${asoftware_for_uninstall[$i]} == $j )); then
WHIP_QUESTION+=" - ${aSOFTWARE_WHIP_NAME[$j]}: ${aSOFTWARE_WHIP_DESC[$j]}\n"
break
fi
done
done
#Ask for confirmation
whiptail --title "Uninstall Software?" --yesno "$WHIP_QUESTION \nDo you wish to continue?" --yes-button "Ok" --no-button "Cancel" --defaultno --backtitle "$WHIP_TITLE" 20 70
CHOICE=$?
#Run uninstall
if (( $CHOICE == 0 )); then
# - stop services
/DietPi/dietpi/dietpi-services stop
for ((i=0; i<${#asoftware_for_uninstall[@]}; i++))
do
Uninstall_Software ${asoftware_for_uninstall[$i]}
done
#Finish up and clear non-required packages
Uninstall_Software_Finalize
#Save
Write_InstallFileList
# - start services
/DietPi/dietpi/dietpi-services start
#inform user
whiptail --title "Uninstall Software" --msgbox "Uninstall completed." --backtitle "$WHIP_BACKTITLE" 9 60
fi
fi
fi
#delete[] arrays
unset whiptail_list_array
unset asoftware_for_uninstall
}
#/////////////////////////////////////////////////////////////////////////////////////
# Banner Print
#/////////////////////////////////////////////////////////////////////////////////////
Banner_Setup(){
/DietPi/dietpi/dietpi-banner 0
echo -e "\n Welcome to DietPi-Software \n"
}
Banner_Installing(){
G_DIETPI-NOTIFY 3 DietPi-Software "Installing ${aSOFTWARE_WHIP_NAME[$INSTALLING_INDEX]}: ${aSOFTWARE_WHIP_DESC[$INSTALLING_INDEX]}"
}
Banner_Configuration(){
G_DIETPI-NOTIFY 3 DietPi-Software "Configuring ${aSOFTWARE_WHIP_NAME[$INSTALLING_INDEX]}: ${aSOFTWARE_WHIP_DESC[$INSTALLING_INDEX]}"
}
Banner_Apt_Update(){
G_DIETPI-NOTIFY 3 DietPi-Software "Update & upgrade APT"
sleep 1
}
Banner_Reboot(){
if (( ! $DISABLE_REBOOT )); then
G_DIETPI-NOTIFY 3 DietPi-Software "Installation completed"
G_DIETPI-NOTIFY 0 "The system will now reboot. \n This completes the DietPi-Software installation.\n"
sleep 3
else
G_DIETPI-NOTIFY 0 "DietPi-Software installation completed."
fi
}
Banner_Configs(){
G_DIETPI-NOTIFY 3 DietPi-Software "Optimize and configure software"
G_DIETPI-NOTIFY 2 "Applying DietPi optimizations and configurations for $G_HW_MODEL_DESCRIPTION, please wait...\n"
}
Banner_Aborted(){
#1st run abort
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
/DietPi/dietpi/dietpi-banner 0
G_DIETPI-NOTIFY 1 "\n Installation Aborted by User \n Installation must be completed prior to using DietPi \n Please run dietpi-software to restart the installation \n"
#Standard abort
else
/DietPi/dietpi/dietpi-banner 1
fi
}
#/////////////////////////////////////////////////////////////////////////////////////
# Main Loop
#/////////////////////////////////////////////////////////////////////////////////////
#--------------------------------------------------------------------------------------
G_DIETPI-NOTIFY 2 "Initializing database, please wait..."
#--------------------------------------------------------------------------------------
#Init software arrays
Software_Arrays_Init
#--------------------------------------------------------------------------------------
#load .installed file, update vars, if it exists
Read_InstallFileList
#--------------------------------------------------------------------------------------
# - CLi input mode
if [ -n "$1" ]; then
# - Run input mode
Input_Modes "$@"
#--------------------------------------------------------------------------------------
#Standard launch
else
#Check if we are setting no user inputs and prompts
# - Load all automation vars
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
FirstRun_Automation_Init
fi
#GPL compliance prompt
if (( $G_DIETPI_INSTALL_STAGE == 0 && $G_USER_INPUTS )); then
whiptail --title "DietPi - GPLv2 License" --msgbox "This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see http://www.gnu.org/licenses/" --backtitle "DietPi - GPLv2 Compliance" 18 70
fi
Banner_Setup
#Prevent continue if NTPD is not completed: https://github.com/Fourdee/DietPi/issues/786
Check_NTPD_Status
#1st run Connection test and DietPi updates
#NB: Contains EXIT path
if (( $(cat /DietPi/dietpi/.update_stage) == -1 )); then
Check_Internet_Connection
FirstRun_DietPi_Update
fi
#Apply 1st run automation
if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
#Activate automation settings from dietpi.txt, if set.
FirstRun_Automation_Set
fi
#Start DietPi Menu
while (( $TARGETMENUID > -1 )); do
clear
if (( $TARGETMENUID == 0 )); then
Menu_Main
elif (( $TARGETMENUID == 1 )); then
Menu_Dietpi_Software
elif (( $TARGETMENUID == 2 )); then
Menu_Linux_Software
elif (( $TARGETMENUID == 3 )); then
Menu_Uninstall_Software
fi
done
fi
#--------------------------------------------------------------------------------------
#Start DietPi-Software installs
if (( $GOSTARTINSTALL )); then
#Insufficient free space
/DietPi/dietpi/dietpi-drive_manager 2
if (( $? != 0 )); then
Exit_Destroy
fi
Check_Internet_Connection
#Start installations for software
Run_Installations
#Upload DietPi-Survey Data
/DietPi/dietpi/dietpi-survey &> /dev/null
#Reboot
Banner_Reboot
if (( $DISABLE_REBOOT )); then
# - Start services
/DietPi/dietpi/dietpi-services start
else
sync
reboot
fi
fi
#-----------------------------------------------------------------------------------
Exit_Destroy
#-----------------------------------------------------------------------------------
}
^~
../oil_DEPS/wild/src/distro/DietPi/dietpi/dietpi-software:13866: Couldn't find terminator for here doc that starts here
|
|
Parsing dietpi-ramlog
|
AST not printed.
|
|
Parsing dietpi-config
|
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select an option:" --cancel-button "$TEXT_MENU_BACK" 12 75 4 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
unset whiptail_menu_array
if (( $CHOICE == 0 )); then
if [ "$OPTION" = "PSU noise reduction" ]; then
if (( ! $psu_noise_reduction_enabled )); then
whiptail --title "PSU noise reduction" --msgbox "This mode attempts to reduce power consumption on your SBC. In turn, this may reduce PSU inflicted noise, that may degrade audio output quality.\n\nThe following has now been set:\n - CPU gov = Powersave\n - HDMI output = Disabled" --backtitle "$WHIP_BACKTITLE" 14 70
sed -i "/CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=powersave" /DietPi/dietpi.txt
/DietPi/dietpi/dietpi-cpu_set
sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=0" /DietPi/dietpi.txt
else
sed -i "/CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=ondemand" /DietPi/dietpi.txt
/DietPi/dietpi/dietpi-cpu_set
sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=1" /DietPi/dietpi.txt
fi
#Return to This Menu
TARGETMENUID=14
elif [ "$OPTION" = "Soundcard" ]; then
WHIP_TITLE='DietPi - Soundcards'
local whiptail_menu_array=()
# - Global:
# RPI, none disables HDMI aswell.
if (( $G_HW_MODEL < 10 )); then
whiptail_menu_array+=("none" "Disables HDMI + 3.5mm Analogue")
# NanoPi M2/M3, BPi Pro, OPi Zero
elif (( $G_HW_MODEL == 32 || $G_HW_MODEL == 51 || $G_HW_MODEL == 61 || $G_HW_MODEL == 62 )); then
whiptail_menu_array+=("default" "3.5mm Analogue")
# Native PC | List available
elif (( $G_HW_MODEL == 21 )); then
whiptail_menu_array+=("default" "HW:0,0")
# Install prereqs to allow for detection
if (( ! $(dpkg --get-selections | grep -ci -m1 '^alsa-utils') )); then
/DietPi/dietpi/func/dietpi-set_hardware soundcard default
fi
for ((i=0; i<10; i++))
do
if [ -f /proc/asound/card$i/id ]; then
for ((j=0; j<10; j++))
do
if [ -f /proc/asound/card$i/pcm${j}p/info ]; then
local card_index=$(cat /proc/asound/card$i/pcm${j}p/info | grep -m1 '^card:' | awk '{print $2}')
local device_index=$(cat /proc/asound/card$i/pcm${j}p/info | grep -m1 '^device:' | awk '{print $2}')
local card_name=$(cat /proc/asound/card$i/id)
card_name+=$(cat /proc/asound/card$i/pcm${j}p/info | grep -m1 '^name:' | sed 's/name://g')
whiptail_menu_array+=( "hw:$card_index,$device_index" "$card_name" )
fi
done
fi
done
else
whiptail_menu_array+=("default" "HDMI")
fi
# - RPI
if (( $G_HW_MODEL < 10 )); then
whiptail_menu_array+=("rpi-bcm2835" "Onboard: HDMI (if plugged in, else 3.5mm)")
whiptail_menu_array+=("rpi-bcm2835-3.5mm" "Onboard: 3.5mm forced output")
whiptail_menu_array+=("rpi-bcm2835-ultrahq" "Onboard HQ: HDMI (if plugged in, else 3.5mm)")
whiptail_menu_array+=("rpi-bcm2835-ultrahq-3.5mm" "Onboard HQ: 3.5mm forced output")
whiptail_menu_array+=("allo-boss-dac-pcm512x-audio" "Allo Boss DAC")
whiptail_menu_array+=("allo-boss-dac-pcm512x-audio" "Allo Mini Boss DAC")
whiptail_menu_array+=("allo-digione" "Allo DigiOne")
whiptail_menu_array+=("allo-piano-dac-pcm512x-audio" "Allo Piano DAC")
whiptail_menu_array+=("allo-piano-dac-pcm512x-audio" "Allo Piano DAC")
whiptail_menu_array+=("dionaudio-loco" "Dion Audio LOCO")
whiptail_menu_array+=("dionaudio-loco-v2" "Dion Audio LOCO V2")
whiptail_menu_array+=("googlevoicehat-soundcard" "Google AIY voice kit")
whiptail_menu_array+=("hifiberry-amp" "HifiBerry AMP / AMP+")
whiptail_menu_array+=("hifiberry-dac" "HifiBerry DAC / MiniAMP")
whiptail_menu_array+=("hifiberry-dacplus" "HifiBerry DAC+ / DAC+ Pro")
whiptail_menu_array+=("hifiberry-digi" "HifiBerry DIGI / DIGI+")
whiptail_menu_array+=("hifiberry-digi-pro" "HifiBerry DIGI Pro")
whiptail_menu_array+=("i-sabre-k2m" "AudioPhonics I-Sabre ES9028 Q2M")
whiptail_menu_array+=("iqaudio-dacplus" "Pi-DAC+, Pi-DACZero, Pi-DAC Pro, Pi-DigiAMP+")
whiptail_menu_array+=("iqaudio-digi-wm8804-audio" "Pi-DIGI+")
whiptail_menu_array+=("iqaudio-dacplus,auto_mute_amp" "Pi-DigiAMP+")
whiptail_menu_array+=("iqaudio-dacplus,unmute_amp" "Pi-DigiAMP+")
whiptail_menu_array+=("justboom-dac" "JustBoom: DAC HAT, Amp HAT, DAC Zero and Amp Zero")
whiptail_menu_array+=("justboom-digi" "JustBoom: Digi HAT and Digi Zero")
whiptail_menu_array+=("rpi-dac" "Soekris DAM1021 (pcm1794a)")
# - C1/C2
elif (( $G_HW_MODEL == 10 || $G_HW_MODEL == 12 )); then
whiptail_menu_array+=("odroid-hifishield-plus" "Odroid HiFi Shield 1/Plus")
whiptail_menu_array+=("odroid-hifishield-2" "Odroid HiFi Shield 2")
# - h2+ | OPi Zero
elif (( $G_HW_MODEL == 32 )); then
whiptail_menu_array+=("h2-hdmi" "HDMI")
# - Rock64
elif (( $G_HW_MODEL == 43 )); then
whiptail_menu_array+=("rock64-analogue" "3.5MM")
# NanoPi M2/M3
elif (( $G_HW_MODEL == 61 || $G_HW_MODEL == 62 )); then
whiptail_menu_array+=("s5pxx18-hdmi" "HDMI")
# - H3
elif (( $G_HW_CPUID == 1 )); then
whiptail_menu_array+=("H3-analogue" "3.5mm analogue")
# - H5
# elif (( $G_HW_CPUID == 2 )); then
# whiptail_menu_array+=("H5-analogue" "3.5mm analogue")
# - Sparky
elif (( $G_HW_MODEL == 70 )); then
whiptail_menu_array+=("snd-soc-allo-piano-dac" "Allo Piano DAC")
whiptail_menu_array+=("snd-soc-allo-piano-dac-plus" "Allo Piano DAC 2.1")
whiptail_menu_array+=("allo-cheapo-analogue" "Allo Cheapo (3.5mm / RCA output)")
whiptail_menu_array+=("allo-cheapo-optical" "Allo Cheapo (Optical output)")
# - Asus tb
elif (( $G_HW_MODEL == 52 )); then
whiptail_menu_array+=("asus-tb-analogue" "3.5mm analogue")
fi
# - Global usb-dac, prefer at bottom of list
whiptail_menu_array+=("usb-dac" "USB Audio DAC (any)")
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Current : $soundcard_current" --default-item "$soundcard_current" --cancel-button "$TEXT_MENU_BACK" 18 90 10 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
unset whiptail_menu_array
if (( $CHOICE == 0 )); then
/DietPi/dietpi/func/dietpi-set_hardware soundcard "$OPTION"
REBOOT_REQUIRED=1
fi
#Return to This Menu
TARGETMENUID=14
elif [ "$OPTION" = "DietPi-JustBoom" ]; then
/DietPi/dietpi/misc/dietpi-justboom
#Return to This Menu
TARGETMENUID=14
fi
fi
}
#TARGETMENUID=15
STRESS_TEST_MODE=0 #0=CPU only | 1=CPU/RAM 2=CPU/RAM/IO
STRESS_TEST_DURATION=60
STRESS_TEST_RESULTS_TEMP_MIN=0
STRESS_TEST_RESULTS_TEMP_MAX=0
Menu_StressTest(){
TARGETMENUID=11
local stress_test_mode_text='CPU Burn: (CPU only)'
if (( $STRESS_TEST_MODE == 1 )); then
stress_test_mode_text='CPU & RAM: (CPU, RAM)'
elif (( $STRESS_TEST_MODE == 2 )); then
stress_test_mode_text='Full: (CPU, DISK, RAM)'
fi
WHIP_TITLE='DietPi - Stress Test'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select an option:" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 11 60 3 \
"Mode" "$stress_test_mode_text" \
"Duration" "$(( $STRESS_TEST_DURATION / 60 )) Minutes" \
"Start" "Launch the stress test" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
if [ "$OPTION" = "Duration" ]; then
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select a duration for the test" --cancel-button "$TEXT_MENU_BACK" --default-item "$STRESS_TEST_DURATION" --backtitle "$WHIP_BACKTITLE" 13 60 5 \
"60" "1 Minute" \
"300" "5 Minutes" \
"1800" "30 Minutes" \
"3600" "1 Hour" \
"21600" "6 Hours" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
STRESS_TEST_DURATION=$OPTION
TARGETMENUID=15
fi
elif [ "$OPTION" = "Mode" ]; then
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select a stress test type" --cancel-button "$TEXT_MENU_BACK" --default-item "$STRESS_TEST_MODE" --backtitle "$WHIP_BACKTITLE" 12 60 3 \
"0" "CPU Burn: (CPU only)" \
"1" "CPU & RAM: (CPU, RAM)" \
"2" "Full: (CPU, DISK, RAM)" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
STRESS_TEST_MODE=$OPTION
TARGETMENUID=15
fi
elif [ "$OPTION" = "Start" ]; then
G_AG_CHECK_INSTALL_PREREQ stress
if (( $? != 0 )); then
exit 1
fi
G_DIETPI-NOTIFY 3 Stress_Test "Running stress test for $STRESS_TEST_DURATION seconds"
G_DIETPI-NOTIFY 2 'To terminate, type: killall -w stress'
local start_time=$(date)
local start_time_epoch=$(date +%s)
local cores=$(nproc --all) # double up cpu threads, maximize overheads.
local memory_per_thread=$(( $(free -m | awk '/^Mem:/{print $2}') / ( $cores * 2 ) ))
local fp_log="$HOME/dietpi-config_stress.log"
rm "$fp_log" &> /dev/null
if (( $STRESS_TEST_MODE == 0 )); then
stress -c $(( $cores * 2 )) -t "$STRESS_TEST_DURATION"s &
elif (( $STRESS_TEST_MODE == 1 )); then
stress -c $(( $cores * 2 )) -i $cores -m $cores --vm-bytes "$memory_per_thread"M -t "$STRESS_TEST_DURATION"s &
elif (( $STRESS_TEST_MODE == 2 )); then
stress -c $(( $cores * 2 )) -i $cores -m $cores --vm-bytes "$memory_per_thread"M -d 2 -t "$STRESS_TEST_DURATION"s &
fi
# - Reset
STRESS_TEST_RESULTS_TEMP_MIN=1000
STRESS_TEST_RESULTS_TEMP_MAX=0
# - Check if system supports temp readouts
local cpu_supports_temp=0
local cpu_temp=$(G_OBTAIN_CPU_TEMP)
if [[ $cpu_temp =~ ^-?[0-9]+$ ]]; then
cpu_supports_temp=1
fi
# - Loop until stress completed
local remaning_time=0
while (( $(ps aux | grep -ci -m1 '[s]tress') == 1 ))
do
cpu_temp=$(G_OBTAIN_CPU_TEMP)
remaning_time=$(( $STRESS_TEST_DURATION + ( $start_time_epoch - $(date +%s) ) ))
echo -e "$(date) | $cpu_temp'c | $remaning_time seconds remaining"
echo -e "$(date) | $cpu_temp'c" >> "$fp_log"
if (( $cpu_supports_temp )); then
if (( $cpu_temp > $STRESS_TEST_RESULTS_TEMP_MAX )); then
STRESS_TEST_RESULTS_TEMP_MAX=$cpu_temp
fi
if (( $cpu_temp < $STRESS_TEST_RESULTS_TEMP_MIN )); then
STRESS_TEST_RESULTS_TEMP_MIN=$cpu_temp
fi
fi
sleep 1
((time_since_start++))
done
local end_time=$(date)
local end_time_epoch=$(date +%s)
local duration_seconds=$(( $end_time_epoch - $start_time_epoch ))
local output_string=" - Start Time: $start_time
- End Time : $end_time
- Duration : $duration_seconds seconds
- Min Temp : $STRESS_TEST_RESULTS_TEMP_MIN 'c
- Max Temp : $STRESS_TEST_RESULTS_TEMP_MAX 'c
- log : $fp_log"
G_DIETPI-NOTIFY 0 'Stress Test Completed'
G_DIETPI-NOTIFY 2 "$output_string"
whiptail --title "$WHIP_TITLE" --msgbox "Stress test results:\n$output_string" --backtitle "$WHIP_BACKTITLE" 14 65
TARGETMENUID=15
fi
fi
}
#TARGETMENUID=16
Menu_Network_Nas_Misc(){
TARGETMENUID=0
#Update installed software
Load_Installed_Software
#Samba Client
local sambaclient_installed=0
local sambaclient_status="Not Installed"
local sambaclient_menutext="Install now to access Windows shares and NAS devices"
local sambaclient_mounted_size="unknown"
local sambaclient_mounted_used="unknown"
local sambaclient_mounted_free="unknown"
if (( ${aSOFTWARE_INSTALL_STATE[1]:=0} == 2 )); then
sambaclient_installed=1
sambaclient_status="Unable to connect and/or incorrect details"
sambaclient_menutext="Input/Modify Details"
#Check if mount exists and is valid
if (( $(df -h | grep -ci -m1 '/mnt/samba') == 1 )); then
#Get stats
sambaclient_mounted_size=$(df -h | grep -m1 '/mnt/samba' | awk '{print $(NF-4)}')
sambaclient_mounted_used=$(df -h | grep -m1 '/mnt/samba' | awk '{print $(NF-3)}')
sambaclient_mounted_free=$(df -h | grep -m1 '/mnt/samba' | awk '{print $(NF-2)}')
sambaclient_status="/mnt/samba | Size $sambaclient_mounted_size | Used $sambaclient_mounted_used | Free $sambaclient_mounted_free"
fi
fi
#ftp Client mount, curlftpfs
local curlftpfs_installed=0
local curlftpfs_status="Not Installed"
local curlftpfs_menutext="Install now to access FTP as filesystem mount"
if (( ${aSOFTWARE_INSTALL_STATE[2]:=0} == 2 )); then
curlftpfs_installed=1
curlftpfs_status="Unable to connect and/or incorrect details"
curlftpfs_menutext="Input/Modify Details"
#Check if mount exists and is valid
if (( $(df -h | grep -ci -m1 '/mnt/ftp_client') == 1 )); then
#Get stats
curlftpfs_status="/mnt/ftp_client | Connected"
fi
fi
#NoIp Client
local noip_installed=0
local noip_status="Not Installed"
local noip_menutext="Install No-Ip now"
if (( ${aSOFTWARE_INSTALL_STATE[67]:=0} == 2 )); then
noip_installed=1
noip_status="Offline - Please Enter No-Ip Details"
noip_menutext="Enter/Setup NoIp Details"
#Check if noip is running (indicates login details are valid)
if (( $(ps aux | grep -ci -m1 '/usr/local/bin/[n]oip2') == 1 )); then
noip_status="Online / Active"
noip_menutext="Change NoIp Details"
fi
fi
#NFS Client
local nfsclient_installed=0
local nfsclient_status="Not Installed"
local nfsclient_menutext="Install now to access NFS shares"
local nfsclient_mounted_size="unknown"
local nfsclient_mounted_used="unknown"
local nfsclient_mounted_free="unknown"
if (( ${aSOFTWARE_INSTALL_STATE[110]:=0} == 2 )); then
nfsclient_installed=1
nfsclient_status="Unable to connect and/or incorrect details"
nfsclient_menutext="Input/Modify Details"
#Check if mount exists and is valid
if (( $(df -h | grep -ci -m1 '/mnt/nfs_client') == 1 )); then
#Get stats
nfsclient_mounted_size=$(df -h | grep -m1 '/mnt/nfs_client' | awk '{ print $2 }')
nfsclient_mounted_used=$(df -h | grep -m1 '/mnt/nfs_client' | awk '{ print $3 }')
nfsclient_mounted_free=$(df -h | grep -m1 '/mnt/nfs_client' | awk '{ print $4 }')
nfsclient_status="/mnt/nfs_client | Size $nfsclient_mounted_size | Used $nfsclient_mounted_used | Free $nfsclient_mounted_free"
fi
fi
#Apt mirror
local apt_mirror_current=$(sed -n 1p /etc/apt/sources.list | awk '{print $2}')
if [ ! -n "$apt_mirror_current" ]; then
apt_mirror_current='Unknown, no string from scrape'
fi
#NTPD mirror
local ntpd_mirror_current=$(grep -m1 '^CONFIG_NTP_MIRROR=' /DietPi/dietpi.txt | sed 's/.*=//')
if [ ! -n "$ntpd_mirror_current" ]; then
ntpd_mirror_current='Unknown, no string from scrape'
fi
#Network boot wait
local boot_wait_for_network=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_BOOT_WAIT_FOR_NETWORK=' | sed 's/.*=//')
local boot_wait_for_network_text=': '
if (( $boot_wait_for_network == 0 )); then
boot_wait_for_network_text+='Disabled'
elif (( $boot_wait_for_network == 1 )); then
boot_wait_for_network_text+='10 Seconds MAX (default)'
elif (( $boot_wait_for_network == 2 )); then
boot_wait_for_network_text+='Infinite wait'
fi
WHIP_TITLE='DietPi - Network Options: NAS/Misc'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "\n Samba client : $sambaclient_status\n FTP client : $curlftpfs_status\n NFS client : $nfsclient_status\n NoIp status : $noip_status\n Apt mirror : $apt_mirror_current\n NTPD mirror : $ntpd_mirror_current" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 21 100 7 \
"Samba Client" "$sambaclient_menutext" \
"FTP Client" "$curlftpfs_menutext" \
"NFS Client" "$nfsclient_menutext" \
"NoIp" "$noip_menutext" \
"Apt Mirror" "Select a different Apt mirror for sources.list" \
"NTPD Mirror" "Select a different NTPD mirror" \
"Boot Net Wait" "$boot_wait_for_network_text" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
case "$OPTION" in
"Boot Net Wait")
#Create Menu List for Whiptail
local whiptail_menu_array=()
whiptail_menu_array+=('0' ': Disabled')
whiptail_menu_array+=('1' ': Wait 10 Seconds MAX for network, before continuing boot (default)')
whiptail_menu_array+=('2' ': Infinite wait for network, before continuing boot')
OPTION=$(whiptail --title "Wait for network during boot" --menu "The following options will allow you to delay boot, until a valid network connection is available:" --default-item "$boot_wait_for_network" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 12 80 3 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
sed -i "/^CONFIG_BOOT_WAIT_FOR_NETWORK=/c CONFIG_BOOT_WAIT_FOR_NETWORK=$OPTION" /DietPi/dietpi.txt
#Return to this Menu
TARGETMENUID=16
fi
#delete []
unset whiptail_menu_array
;;
"Apt Mirror")
#Create Menu List for Whiptail
local whiptail_menu_array=(
"Custom" "Manually enter Apt mirror"
)
# - Raspbian
if (( $G_HW_MODEL < 10 )); then
whiptail_menu_array+=("http://mirrordirector.raspbian.org/raspbian" "Global")
whiptail_menu_array+=("https://www.mirrorservice.org/sites/archive.raspbian.org/raspbian" "Global (https)")
whiptail_menu_array+=("http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian" "UK")
whiptail_menu_array+=("ftp://ftp.fu-berlin.de/linux/raspbian/raspbian" "Germany")
whiptail_menu_array+=("http://mirror.umd.edu/raspbian/raspbian" "US")
whiptail_menu_array+=("http://mirrors.ustc.edu.cn/raspbian/raspbian" "China")
whiptail_menu_array+=("http://raspbian.mirror.digitalpacific.com.au/raspbian" "Australia")
# - Debian
else
whiptail_menu_array+=("http://ftp.debian.org/debian/" "Global")
whiptail_menu_array+=("http://ftp.uk.debian.org/debian/" "UK")
whiptail_menu_array+=("http://ftp.us.debian.org/debian/" "US")
whiptail_menu_array+=("http://ftp.cn.debian.org/debian/" "China")
whiptail_menu_array+=("http://ftp.au.debian.org/debian/" "Australia")
fi
OPTION=$(whiptail --title "Choose Apt Mirror" --menu "Please select a Apt mirror, or choose custom for manual entry." --default-item "$apt_mirror_current" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 15 100 7 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
case $OPTION in
Custom)
OPTION=$(whiptail --inputbox "Enter Your Apt Mirror\n - eg: http://ftp.debian.org/debian" 9 100 "$apt_mirror_current" --title "Set Apt Mirror" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
return_value=$OPTION
fi
;;
*)
return_value=$OPTION
;;
esac
/DietPi/dietpi/func/dietpi-set_software apt-mirror $OPTION
# - test it
G_DIETPI-NOTIFY 2 "Updating Apt, please wait..."
G_AGUP
local exit_code=$?
if (( $exit_code != 0 )); then
whiptail --title "Apt Error:" --msgbox "Failed to update apt, exit code: $exit_code\nPlease try another Apt mirror." --backtitle "$WHIP_BACKTITLE" 8 65
fi
fi
#Return to this Menu
TARGETMENUID=16
#delete []
unset whiptail_menu_array
;;
"NTPD Mirror")
#Create Menu List for Whiptail
local whiptail_menu_array=(
"Custom" "Manually enter NTPD mirror"
)
whiptail_menu_array+=('debian.pool.ntp.org' 'Debian Global')
whiptail_menu_array+=('pool.ntp.org' 'Global')
whiptail_menu_array+=('europe.pool.ntp.org' 'Europe')
whiptail_menu_array+=('north-america.pool.ntp.org' 'North America')
whiptail_menu_array+=('south-america.pool.ntp.org' 'South America')
whiptail_menu_array+=('africa.pool.ntp.org' 'Africa')
whiptail_menu_array+=('asia.pool.ntp.org' 'Asia')
whiptail_menu_array+=('oceania.pool.ntp.org' 'Oceania')
OPTION=$(whiptail --title "Choose NTPD Mirror" --menu "Please select a NTPD mirror, or choose custom for manual entry.\n - Further information: \"http://www.pool.ntp.org/zone/@\"" --default-item "$ntpd_mirror_current" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 16 100 7 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
return_value=$OPTION
case $OPTION in
Custom)
OPTION=$(whiptail --inputbox "Enter Your NTPD Mirror\n - eg: debian.pool.ntp.org" 9 100 "$ntpd_mirror_current" --title "Set NTPD Mirror" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
return_value=$OPTION
fi
;;
esac
sed -i "/CONFIG_NTP_MIRROR=/c\CONFIG_NTP_MIRROR=$OPTION" /DietPi/dietpi.txt
/DietPi/dietpi/func/dietpi-set_software ntpd-mode $(grep -m1 '^CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/.*=//')
#Return to this Menu
TARGETMENUID=16
fi
#delete []
unset whiptail_menu_array
;;
"NFS Client")
#Installed?
if (( ! $nfsclient_installed )); then
whiptail --title "Install NFS Client?" --yesno "NFS Client is not installed, would you like to install it now?\n\nThis will allow you access NFS shares." --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 12 65
CHOICE=$?
if (( $CHOICE == 0 )); then
#install nfsclient
/DietPi/dietpi/dietpi-software install 110
fi
else
/DietPi/dietpi/func/dietpi-set_nfsclient
fi
#Return to this Menu
TARGETMENUID=16
;;
Samba*)
#Installed?
if (( ! $sambaclient_installed )); then
whiptail --title "Install Samba Client?" --yesno "Samba Client is not installed, would you like to install it now?\n\nThis will allow you access Windows shared folders, NAS and CIFS capable devices." --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 12 65
CHOICE=$?
if (( $CHOICE == 0 )); then
#install smbclient
/DietPi/dietpi/dietpi-software install 1
fi
else
/DietPi/dietpi/func/dietpi-set_smbclient
fi
#Return to this Menu
TARGETMENUID=16
;;
FTP*)
#Installed?
if (( ! $curlftpfs_installed )); then
whiptail --title "Install FTP Client?" --yesno "FTP Client (curlftpfs) is not installed, would you like to install it now? \n \n - This is required to mount an FTP connection to filesystem" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 12 65
CHOICE=$?
if (( $CHOICE == 0 )); then
#install curlftpfs
/DietPi/dietpi/dietpi-software install 2
fi
else
/DietPi/dietpi/func/dietpi-set_curlftpfs
fi
#Return to this Menu
TARGETMENUID=16
;;
NoIp)
#Installed?
if (( ! $noip_installed )); then
local noip_url_address=''
whiptail --title "Install NoIp Client?" --yesno "NoIp Client is not installed, would you like to install it now?\n\n- NoIp will allow you to use a fixed web address, regardless of your internet IP\neg: MySuperDooperWebsite.noip2.biz would point to this device!" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 13 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Install
/DietPi/dietpi/dietpi-software install 67
fi
else
clear
service noip2 stop
noip2 -C
read -p "Press any key to continue....."
service noip2 start
fi
#Return to this Menu
TARGETMENUID=16
;;
esac
#Cancel
else
#Exit DietPi-Config on back to previous menu?
if (( $EXITONBACK == 1 )); then
#Return to this menu
TARGETMENUID=16
Menu_Exit
fi
fi
}
PROXY_ENABLED=-1
PROXY_ADDRESS=''
PROXY_PORT=''
PROXY_USERNAME=''
PROXY_PASSWORD=''
#So we can call this in other menus (eg: submenu of this)
Load_Proxy_Vars(){
PROXY_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_ENABLED=' | sed 's/.*=//')
PROXY_ADDRESS=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_ADDRESS=' | sed 's/.*=//')
PROXY_PORT=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_PORT=' | sed 's/.*=//')
PROXY_USERNAME=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_USERNAME=' | sed 's/.*=//')
PROXY_PASSWORD=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_PASSWORD=' | sed 's/.*=//')
}
#TARGETMENUID=17
Menu_NetworkAdapters_Proxy(){
TARGETMENUID=8
#Get current details on first menu init (PROXY_ENABLED=-1)
if (( $PROXY_ENABLED == -1 )); then
Load_Proxy_Vars
proxy_state_text='Disabled'
if (( $PROXY_ENABLED == 1 )); then
proxy_state_text='Enabled'
fi
fi
proxy_state_text_new='No'
if (( $PROXY_ENABLED == 1 )); then
proxy_state_text_new='Yes'
fi
WHIP_TITLE='DietPi - Proxy Network Options'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "\n Current Details:\n - Status: $proxy_state_text\n - Address: $PROXY_ADDRESS\n - Port: $PROXY_PORT\n - Username: $PROXY_USERNAME\n - Password: $PROXY_PASSWORD" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 21 60 6 \
"Toggle" "Use Proxy?: $proxy_state_text_new" \
"Address" "Enter Proxy server IP/URL" \
"Port" "Enter Proxy server port" \
"Username" "Enter Proxy server username" \
"Password" "Enter Proxy server password" \
"Apply" "Save Changes" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
case "$OPTION" in
Toggle)
((PROXY_ENABLED++))
if (( $PROXY_ENABLED >= 2 )); then
PROXY_ENABLED=0
fi
#Return to this menu
TARGETMENUID=17
;;
Address)
OPTION=$(whiptail --inputbox "Please enter the proxy URL or IP address\n - eg: MyProxy.com" 9 65 "$PROXY_ADDRESS" --title "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
PROXY_ADDRESS=$OPTION
fi
#Return to this Menu
TARGETMENUID=17
;;
Port)
OPTION=$(whiptail --inputbox "Please enter the proxy port number\n - eg: 1234" 9 65 "$PROXY_PORT" --title "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
PROXY_PORT=$OPTION
fi
#Return to this Menu
TARGETMENUID=17
;;
Username)
OPTION=$(whiptail --inputbox "Please enter the proxy username\n - eg: JoeBloggs\n - Leave blank if not required" 10 65 "$PROXY_USERNAME" --title "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
PROXY_USERNAME=$OPTION
fi
#Return to this Menu
TARGETMENUID=17
;;
Password)
OPTION=$(whiptail --inputbox "Please enter the proxy password\n - eg: LetMeIn\n - Leave blank if not required" 10 65 "$PROXY_PASSWORD" --title "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
PROXY_PASSWORD=$OPTION
fi
#Return to this Menu
TARGETMENUID=17
;;
Apply)
# - Save settings to dietpi.txt
sed -i "/^CONFIG_PROXY_ENABLED=/c\CONFIG_PROXY_ENABLED=$PROXY_ENABLED" /DietPi/dietpi.txt
sed -i "/^CONFIG_PROXY_ADDRESS=/c\CONFIG_PROXY_ADDRESS=$PROXY_ADDRESS" /DietPi/dietpi.txt
sed -i "/^CONFIG_PROXY_PORT=/c\CONFIG_PROXY_PORT=$PROXY_PORT" /DietPi/dietpi.txt
sed -i "/^CONFIG_PROXY_USERNAME=/c\CONFIG_PROXY_USERNAME=$PROXY_USERNAME" /DietPi/dietpi.txt
sed -i "/^CONFIG_PROXY_PASSWORD=/c\CONFIG_PROXY_PASSWORD=$PROXY_PASSWORD" /DietPi/dietpi.txt
# - Delete active export vars
#unset {http,https,ftp}_proxy #Does not apply to system when running from a bash script.
# - Delete any existing export settings from /etc/bash.bashrc
sed -i '/{http,https,ftp}_proxy=/d' /etc/bash.bashrc
# - Add export settings
if (( $PROXY_ENABLED == 1 )); then
if [ -n "$PROXY_USERNAME" ] && [ -n "$PROXY_PASSWORD" ]; then
cat << _EOF_ >> /etc/bash.bashrc
export {http,https,ftp}_proxy="http://$PROXY_USERNAME:$PROXY_PASSWORD@$PROXY_ADDRESS:$PROXY_PORT"
_EOF_
else
cat << _EOF_ >> /etc/bash.bashrc
export {http,https,ftp}_proxy="http://$PROXY_ADDRESS:$PROXY_PORT"
_EOF_
fi
fi
# - Ask user for reboot now to activate/disable proxy
REBOOT_REQUIRED=1
WHIP_TITLE='Proxy: Reboot required'
WHIP_QUESTION='Your proxy settings have been saved.\n\nNB: You must reboot your system, before the new proxy settings will take effect.\n\nReboot system now?'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 13 65
CHOICE=$?
if (( $CHOICE == 0 )); then
reboot
fi
# - Reset init flag to force a reload of setings next time this menu is run.
PROXY_ENABLED=-1
#Return to this menu
TARGETMENUID=17
;;
esac
#Reset init flag to force a reload of setings next time this menu is run.
else
PROXY_ENABLED=-1
fi
}
#/////////////////////////////////////////////////////////////////////////////////////
# Main Loop
#/////////////////////////////////////////////////////////////////////////////////////
if (( $G_DIETPI_INSTALL_STAGE >= 0 )); then
#Start DietPi-Config
while (( $TARGETMENUID > -1 )); do
#Clear Screen buffer
clear
if (( $TARGETMENUID == 0 )); then
Menu_Main
elif (( $TARGETMENUID == 1 )); then
Menu_DisplayOptions
elif (( $TARGETMENUID == 2 )); then
Menu_DisplayOptions_Driver_Resolution
elif (( $TARGETMENUID == 3 )); then
Menu_AdvancedOptions
elif (( $TARGETMENUID == 4 )); then
Menu_PerformanceOptions
elif (( $TARGETMENUID == 5 )); then
Menu_SecurityOptions
elif (( $TARGETMENUID == 6 )); then
Menu_GpumemoryOptions
elif (( $TARGETMENUID == 7 )); then
Menu_LanguageOptions
elif (( $TARGETMENUID == 8 )); then
Menu_NetworkAdapters
elif (( $TARGETMENUID == 9 )); then
Menu_NetworkAdapters_Ethernet
elif (( $TARGETMENUID == 10 )); then
Menu_NetworkAdapters_Wifi
elif (( $TARGETMENUID == 11 )); then
Menu_Tools
elif (( $TARGETMENUID == 12 )); then
Menu_FilesystemBenchmark
elif (( $TARGETMENUID == 13 )); then
Menu_Overclock
elif (( $TARGETMENUID == 14 )); then
Menu_AudioOptions
elif (( $TARGETMENUID == 15 )); then
Menu_StressTest
elif (( $TARGETMENUID == 16 )); then
Menu_Network_Nas_Misc
elif (( $TARGETMENUID == 17 )); then
Menu_NetworkAdapters_Proxy
fi
done
else
echo -e " >> Filesystem prep has not yet completed: \n Please wait for the system to reboot "
fi
#-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}
^~
../oil_DEPS/wild/src/distro/DietPi/dietpi/dietpi-config:4456: Couldn't find terminator for here doc that starts here
|
|
Translating dietpi-config
|
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select an option:" --cancel-button "$TEXT_MENU_BACK" 12 75 4 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
unset whiptail_menu_array
if (( $CHOICE == 0 )); then
if [ "$OPTION" = "PSU noise reduction" ]; then
if (( ! $psu_noise_reduction_enabled )); then
whiptail --title "PSU noise reduction" --msgbox "This mode attempts to reduce power consumption on your SBC. In turn, this may reduce PSU inflicted noise, that may degrade audio output quality.\n\nThe following has now been set:\n - CPU gov = Powersave\n - HDMI output = Disabled" --backtitle "$WHIP_BACKTITLE" 14 70
sed -i "/CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=powersave" /DietPi/dietpi.txt
/DietPi/dietpi/dietpi-cpu_set
sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=0" /DietPi/dietpi.txt
else
sed -i "/CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=ondemand" /DietPi/dietpi.txt
/DietPi/dietpi/dietpi-cpu_set
sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=1" /DietPi/dietpi.txt
fi
#Return to This Menu
TARGETMENUID=14
elif [ "$OPTION" = "Soundcard" ]; then
WHIP_TITLE='DietPi - Soundcards'
local whiptail_menu_array=()
# - Global:
# RPI, none disables HDMI aswell.
if (( $G_HW_MODEL < 10 )); then
whiptail_menu_array+=("none" "Disables HDMI + 3.5mm Analogue")
# NanoPi M2/M3, BPi Pro, OPi Zero
elif (( $G_HW_MODEL == 32 || $G_HW_MODEL == 51 || $G_HW_MODEL == 61 || $G_HW_MODEL == 62 )); then
whiptail_menu_array+=("default" "3.5mm Analogue")
# Native PC | List available
elif (( $G_HW_MODEL == 21 )); then
whiptail_menu_array+=("default" "HW:0,0")
# Install prereqs to allow for detection
if (( ! $(dpkg --get-selections | grep -ci -m1 '^alsa-utils') )); then
/DietPi/dietpi/func/dietpi-set_hardware soundcard default
fi
for ((i=0; i<10; i++))
do
if [ -f /proc/asound/card$i/id ]; then
for ((j=0; j<10; j++))
do
if [ -f /proc/asound/card$i/pcm${j}p/info ]; then
local card_index=$(cat /proc/asound/card$i/pcm${j}p/info | grep -m1 '^card:' | awk '{print $2}')
local device_index=$(cat /proc/asound/card$i/pcm${j}p/info | grep -m1 '^device:' | awk '{print $2}')
local card_name=$(cat /proc/asound/card$i/id)
card_name+=$(cat /proc/asound/card$i/pcm${j}p/info | grep -m1 '^name:' | sed 's/name://g')
whiptail_menu_array+=( "hw:$card_index,$device_index" "$card_name" )
fi
done
fi
done
else
whiptail_menu_array+=("default" "HDMI")
fi
# - RPI
if (( $G_HW_MODEL < 10 )); then
whiptail_menu_array+=("rpi-bcm2835" "Onboard: HDMI (if plugged in, else 3.5mm)")
whiptail_menu_array+=("rpi-bcm2835-3.5mm" "Onboard: 3.5mm forced output")
whiptail_menu_array+=("rpi-bcm2835-ultrahq" "Onboard HQ: HDMI (if plugged in, else 3.5mm)")
whiptail_menu_array+=("rpi-bcm2835-ultrahq-3.5mm" "Onboard HQ: 3.5mm forced output")
whiptail_menu_array+=("allo-boss-dac-pcm512x-audio" "Allo Boss DAC")
whiptail_menu_array+=("allo-boss-dac-pcm512x-audio" "Allo Mini Boss DAC")
whiptail_menu_array+=("allo-digione" "Allo DigiOne")
whiptail_menu_array+=("allo-piano-dac-pcm512x-audio" "Allo Piano DAC")
whiptail_menu_array+=("allo-piano-dac-pcm512x-audio" "Allo Piano DAC")
whiptail_menu_array+=("dionaudio-loco" "Dion Audio LOCO")
whiptail_menu_array+=("dionaudio-loco-v2" "Dion Audio LOCO V2")
whiptail_menu_array+=("googlevoicehat-soundcard" "Google AIY voice kit")
whiptail_menu_array+=("hifiberry-amp" "HifiBerry AMP / AMP+")
whiptail_menu_array+=("hifiberry-dac" "HifiBerry DAC / MiniAMP")
whiptail_menu_array+=("hifiberry-dacplus" "HifiBerry DAC+ / DAC+ Pro")
whiptail_menu_array+=("hifiberry-digi" "HifiBerry DIGI / DIGI+")
whiptail_menu_array+=("hifiberry-digi-pro" "HifiBerry DIGI Pro")
whiptail_menu_array+=("i-sabre-k2m" "AudioPhonics I-Sabre ES9028 Q2M")
whiptail_menu_array+=("iqaudio-dacplus" "Pi-DAC+, Pi-DACZero, Pi-DAC Pro, Pi-DigiAMP+")
whiptail_menu_array+=("iqaudio-digi-wm8804-audio" "Pi-DIGI+")
whiptail_menu_array+=("iqaudio-dacplus,auto_mute_amp" "Pi-DigiAMP+")
whiptail_menu_array+=("iqaudio-dacplus,unmute_amp" "Pi-DigiAMP+")
whiptail_menu_array+=("justboom-dac" "JustBoom: DAC HAT, Amp HAT, DAC Zero and Amp Zero")
whiptail_menu_array+=("justboom-digi" "JustBoom: Digi HAT and Digi Zero")
whiptail_menu_array+=("rpi-dac" "Soekris DAM1021 (pcm1794a)")
# - C1/C2
elif (( $G_HW_MODEL == 10 || $G_HW_MODEL == 12 )); then
whiptail_menu_array+=("odroid-hifishield-plus" "Odroid HiFi Shield 1/Plus")
whiptail_menu_array+=("odroid-hifishield-2" "Odroid HiFi Shield 2")
# - h2+ | OPi Zero
elif (( $G_HW_MODEL == 32 )); then
whiptail_menu_array+=("h2-hdmi" "HDMI")
# - Rock64
elif (( $G_HW_MODEL == 43 )); then
whiptail_menu_array+=("rock64-analogue" "3.5MM")
# NanoPi M2/M3
elif (( $G_HW_MODEL == 61 || $G_HW_MODEL == 62 )); then
whiptail_menu_array+=("s5pxx18-hdmi" "HDMI")
# - H3
elif (( $G_HW_CPUID == 1 )); then
whiptail_menu_array+=("H3-analogue" "3.5mm analogue")
# - H5
# elif (( $G_HW_CPUID == 2 )); then
# whiptail_menu_array+=("H5-analogue" "3.5mm analogue")
# - Sparky
elif (( $G_HW_MODEL == 70 )); then
whiptail_menu_array+=("snd-soc-allo-piano-dac" "Allo Piano DAC")
whiptail_menu_array+=("snd-soc-allo-piano-dac-plus" "Allo Piano DAC 2.1")
whiptail_menu_array+=("allo-cheapo-analogue" "Allo Cheapo (3.5mm / RCA output)")
whiptail_menu_array+=("allo-cheapo-optical" "Allo Cheapo (Optical output)")
# - Asus tb
elif (( $G_HW_MODEL == 52 )); then
whiptail_menu_array+=("asus-tb-analogue" "3.5mm analogue")
fi
# - Global usb-dac, prefer at bottom of list
whiptail_menu_array+=("usb-dac" "USB Audio DAC (any)")
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Current : $soundcard_current" --default-item "$soundcard_current" --cancel-button "$TEXT_MENU_BACK" 18 90 10 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
unset whiptail_menu_array
if (( $CHOICE == 0 )); then
/DietPi/dietpi/func/dietpi-set_hardware soundcard "$OPTION"
REBOOT_REQUIRED=1
fi
#Return to This Menu
TARGETMENUID=14
elif [ "$OPTION" = "DietPi-JustBoom" ]; then
/DietPi/dietpi/misc/dietpi-justboom
#Return to This Menu
TARGETMENUID=14
fi
fi
}
#TARGETMENUID=15
STRESS_TEST_MODE=0 #0=CPU only | 1=CPU/RAM 2=CPU/RAM/IO
STRESS_TEST_DURATION=60
STRESS_TEST_RESULTS_TEMP_MIN=0
STRESS_TEST_RESULTS_TEMP_MAX=0
Menu_StressTest(){
TARGETMENUID=11
local stress_test_mode_text='CPU Burn: (CPU only)'
if (( $STRESS_TEST_MODE == 1 )); then
stress_test_mode_text='CPU & RAM: (CPU, RAM)'
elif (( $STRESS_TEST_MODE == 2 )); then
stress_test_mode_text='Full: (CPU, DISK, RAM)'
fi
WHIP_TITLE='DietPi - Stress Test'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select an option:" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 11 60 3 \
"Mode" "$stress_test_mode_text" \
"Duration" "$(( $STRESS_TEST_DURATION / 60 )) Minutes" \
"Start" "Launch the stress test" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
if [ "$OPTION" = "Duration" ]; then
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select a duration for the test" --cancel-button "$TEXT_MENU_BACK" --default-item "$STRESS_TEST_DURATION" --backtitle "$WHIP_BACKTITLE" 13 60 5 \
"60" "1 Minute" \
"300" "5 Minutes" \
"1800" "30 Minutes" \
"3600" "1 Hour" \
"21600" "6 Hours" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
STRESS_TEST_DURATION=$OPTION
TARGETMENUID=15
fi
elif [ "$OPTION" = "Mode" ]; then
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select a stress test type" --cancel-button "$TEXT_MENU_BACK" --default-item "$STRESS_TEST_MODE" --backtitle "$WHIP_BACKTITLE" 12 60 3 \
"0" "CPU Burn: (CPU only)" \
"1" "CPU & RAM: (CPU, RAM)" \
"2" "Full: (CPU, DISK, RAM)" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
STRESS_TEST_MODE=$OPTION
TARGETMENUID=15
fi
elif [ "$OPTION" = "Start" ]; then
G_AG_CHECK_INSTALL_PREREQ stress
if (( $? != 0 )); then
exit 1
fi
G_DIETPI-NOTIFY 3 Stress_Test "Running stress test for $STRESS_TEST_DURATION seconds"
G_DIETPI-NOTIFY 2 'To terminate, type: killall -w stress'
local start_time=$(date)
local start_time_epoch=$(date +%s)
local cores=$(nproc --all) # double up cpu threads, maximize overheads.
local memory_per_thread=$(( $(free -m | awk '/^Mem:/{print $2}') / ( $cores * 2 ) ))
local fp_log="$HOME/dietpi-config_stress.log"
rm "$fp_log" &> /dev/null
if (( $STRESS_TEST_MODE == 0 )); then
stress -c $(( $cores * 2 )) -t "$STRESS_TEST_DURATION"s &
elif (( $STRESS_TEST_MODE == 1 )); then
stress -c $(( $cores * 2 )) -i $cores -m $cores --vm-bytes "$memory_per_thread"M -t "$STRESS_TEST_DURATION"s &
elif (( $STRESS_TEST_MODE == 2 )); then
stress -c $(( $cores * 2 )) -i $cores -m $cores --vm-bytes "$memory_per_thread"M -d 2 -t "$STRESS_TEST_DURATION"s &
fi
# - Reset
STRESS_TEST_RESULTS_TEMP_MIN=1000
STRESS_TEST_RESULTS_TEMP_MAX=0
# - Check if system supports temp readouts
local cpu_supports_temp=0
local cpu_temp=$(G_OBTAIN_CPU_TEMP)
if [[ $cpu_temp =~ ^-?[0-9]+$ ]]; then
cpu_supports_temp=1
fi
# - Loop until stress completed
local remaning_time=0
while (( $(ps aux | grep -ci -m1 '[s]tress') == 1 ))
do
cpu_temp=$(G_OBTAIN_CPU_TEMP)
remaning_time=$(( $STRESS_TEST_DURATION + ( $start_time_epoch - $(date +%s) ) ))
echo -e "$(date) | $cpu_temp'c | $remaning_time seconds remaining"
echo -e "$(date) | $cpu_temp'c" >> "$fp_log"
if (( $cpu_supports_temp )); then
if (( $cpu_temp > $STRESS_TEST_RESULTS_TEMP_MAX )); then
STRESS_TEST_RESULTS_TEMP_MAX=$cpu_temp
fi
if (( $cpu_temp < $STRESS_TEST_RESULTS_TEMP_MIN )); then
STRESS_TEST_RESULTS_TEMP_MIN=$cpu_temp
fi
fi
sleep 1
((time_since_start++))
done
local end_time=$(date)
local end_time_epoch=$(date +%s)
local duration_seconds=$(( $end_time_epoch - $start_time_epoch ))
local output_string=" - Start Time: $start_time
- End Time : $end_time
- Duration : $duration_seconds seconds
- Min Temp : $STRESS_TEST_RESULTS_TEMP_MIN 'c
- Max Temp : $STRESS_TEST_RESULTS_TEMP_MAX 'c
- log : $fp_log"
G_DIETPI-NOTIFY 0 'Stress Test Completed'
G_DIETPI-NOTIFY 2 "$output_string"
whiptail --title "$WHIP_TITLE" --msgbox "Stress test results:\n$output_string" --backtitle "$WHIP_BACKTITLE" 14 65
TARGETMENUID=15
fi
fi
}
#TARGETMENUID=16
Menu_Network_Nas_Misc(){
TARGETMENUID=0
#Update installed software
Load_Installed_Software
#Samba Client
local sambaclient_installed=0
local sambaclient_status="Not Installed"
local sambaclient_menutext="Install now to access Windows shares and NAS devices"
local sambaclient_mounted_size="unknown"
local sambaclient_mounted_used="unknown"
local sambaclient_mounted_free="unknown"
if (( ${aSOFTWARE_INSTALL_STATE[1]:=0} == 2 )); then
sambaclient_installed=1
sambaclient_status="Unable to connect and/or incorrect details"
sambaclient_menutext="Input/Modify Details"
#Check if mount exists and is valid
if (( $(df -h | grep -ci -m1 '/mnt/samba') == 1 )); then
#Get stats
sambaclient_mounted_size=$(df -h | grep -m1 '/mnt/samba' | awk '{print $(NF-4)}')
sambaclient_mounted_used=$(df -h | grep -m1 '/mnt/samba' | awk '{print $(NF-3)}')
sambaclient_mounted_free=$(df -h | grep -m1 '/mnt/samba' | awk '{print $(NF-2)}')
sambaclient_status="/mnt/samba | Size $sambaclient_mounted_size | Used $sambaclient_mounted_used | Free $sambaclient_mounted_free"
fi
fi
#ftp Client mount, curlftpfs
local curlftpfs_installed=0
local curlftpfs_status="Not Installed"
local curlftpfs_menutext="Install now to access FTP as filesystem mount"
if (( ${aSOFTWARE_INSTALL_STATE[2]:=0} == 2 )); then
curlftpfs_installed=1
curlftpfs_status="Unable to connect and/or incorrect details"
curlftpfs_menutext="Input/Modify Details"
#Check if mount exists and is valid
if (( $(df -h | grep -ci -m1 '/mnt/ftp_client') == 1 )); then
#Get stats
curlftpfs_status="/mnt/ftp_client | Connected"
fi
fi
#NoIp Client
local noip_installed=0
local noip_status="Not Installed"
local noip_menutext="Install No-Ip now"
if (( ${aSOFTWARE_INSTALL_STATE[67]:=0} == 2 )); then
noip_installed=1
noip_status="Offline - Please Enter No-Ip Details"
noip_menutext="Enter/Setup NoIp Details"
#Check if noip is running (indicates login details are valid)
if (( $(ps aux | grep -ci -m1 '/usr/local/bin/[n]oip2') == 1 )); then
noip_status="Online / Active"
noip_menutext="Change NoIp Details"
fi
fi
#NFS Client
local nfsclient_installed=0
local nfsclient_status="Not Installed"
local nfsclient_menutext="Install now to access NFS shares"
local nfsclient_mounted_size="unknown"
local nfsclient_mounted_used="unknown"
local nfsclient_mounted_free="unknown"
if (( ${aSOFTWARE_INSTALL_STATE[110]:=0} == 2 )); then
nfsclient_installed=1
nfsclient_status="Unable to connect and/or incorrect details"
nfsclient_menutext="Input/Modify Details"
#Check if mount exists and is valid
if (( $(df -h | grep -ci -m1 '/mnt/nfs_client') == 1 )); then
#Get stats
nfsclient_mounted_size=$(df -h | grep -m1 '/mnt/nfs_client' | awk '{ print $2 }')
nfsclient_mounted_used=$(df -h | grep -m1 '/mnt/nfs_client' | awk '{ print $3 }')
nfsclient_mounted_free=$(df -h | grep -m1 '/mnt/nfs_client' | awk '{ print $4 }')
nfsclient_status="/mnt/nfs_client | Size $nfsclient_mounted_size | Used $nfsclient_mounted_used | Free $nfsclient_mounted_free"
fi
fi
#Apt mirror
local apt_mirror_current=$(sed -n 1p /etc/apt/sources.list | awk '{print $2}')
if [ ! -n "$apt_mirror_current" ]; then
apt_mirror_current='Unknown, no string from scrape'
fi
#NTPD mirror
local ntpd_mirror_current=$(grep -m1 '^CONFIG_NTP_MIRROR=' /DietPi/dietpi.txt | sed 's/.*=//')
if [ ! -n "$ntpd_mirror_current" ]; then
ntpd_mirror_current='Unknown, no string from scrape'
fi
#Network boot wait
local boot_wait_for_network=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_BOOT_WAIT_FOR_NETWORK=' | sed 's/.*=//')
local boot_wait_for_network_text=': '
if (( $boot_wait_for_network == 0 )); then
boot_wait_for_network_text+='Disabled'
elif (( $boot_wait_for_network == 1 )); then
boot_wait_for_network_text+='10 Seconds MAX (default)'
elif (( $boot_wait_for_network == 2 )); then
boot_wait_for_network_text+='Infinite wait'
fi
WHIP_TITLE='DietPi - Network Options: NAS/Misc'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "\n Samba client : $sambaclient_status\n FTP client : $curlftpfs_status\n NFS client : $nfsclient_status\n NoIp status : $noip_status\n Apt mirror : $apt_mirror_current\n NTPD mirror : $ntpd_mirror_current" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 21 100 7 \
"Samba Client" "$sambaclient_menutext" \
"FTP Client" "$curlftpfs_menutext" \
"NFS Client" "$nfsclient_menutext" \
"NoIp" "$noip_menutext" \
"Apt Mirror" "Select a different Apt mirror for sources.list" \
"NTPD Mirror" "Select a different NTPD mirror" \
"Boot Net Wait" "$boot_wait_for_network_text" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
case "$OPTION" in
"Boot Net Wait")
#Create Menu List for Whiptail
local whiptail_menu_array=()
whiptail_menu_array+=('0' ': Disabled')
whiptail_menu_array+=('1' ': Wait 10 Seconds MAX for network, before continuing boot (default)')
whiptail_menu_array+=('2' ': Infinite wait for network, before continuing boot')
OPTION=$(whiptail --title "Wait for network during boot" --menu "The following options will allow you to delay boot, until a valid network connection is available:" --default-item "$boot_wait_for_network" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 12 80 3 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
sed -i "/^CONFIG_BOOT_WAIT_FOR_NETWORK=/c CONFIG_BOOT_WAIT_FOR_NETWORK=$OPTION" /DietPi/dietpi.txt
#Return to this Menu
TARGETMENUID=16
fi
#delete []
unset whiptail_menu_array
;;
"Apt Mirror")
#Create Menu List for Whiptail
local whiptail_menu_array=(
"Custom" "Manually enter Apt mirror"
)
# - Raspbian
if (( $G_HW_MODEL < 10 )); then
whiptail_menu_array+=("http://mirrordirector.raspbian.org/raspbian" "Global")
whiptail_menu_array+=("https://www.mirrorservice.org/sites/archive.raspbian.org/raspbian" "Global (https)")
whiptail_menu_array+=("http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian" "UK")
whiptail_menu_array+=("ftp://ftp.fu-berlin.de/linux/raspbian/raspbian" "Germany")
whiptail_menu_array+=("http://mirror.umd.edu/raspbian/raspbian" "US")
whiptail_menu_array+=("http://mirrors.ustc.edu.cn/raspbian/raspbian" "China")
whiptail_menu_array+=("http://raspbian.mirror.digitalpacific.com.au/raspbian" "Australia")
# - Debian
else
whiptail_menu_array+=("http://ftp.debian.org/debian/" "Global")
whiptail_menu_array+=("http://ftp.uk.debian.org/debian/" "UK")
whiptail_menu_array+=("http://ftp.us.debian.org/debian/" "US")
whiptail_menu_array+=("http://ftp.cn.debian.org/debian/" "China")
whiptail_menu_array+=("http://ftp.au.debian.org/debian/" "Australia")
fi
OPTION=$(whiptail --title "Choose Apt Mirror" --menu "Please select a Apt mirror, or choose custom for manual entry." --default-item "$apt_mirror_current" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 15 100 7 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
case $OPTION in
Custom)
OPTION=$(whiptail --inputbox "Enter Your Apt Mirror\n - eg: http://ftp.debian.org/debian" 9 100 "$apt_mirror_current" --title "Set Apt Mirror" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
return_value=$OPTION
fi
;;
*)
return_value=$OPTION
;;
esac
/DietPi/dietpi/func/dietpi-set_software apt-mirror $OPTION
# - test it
G_DIETPI-NOTIFY 2 "Updating Apt, please wait..."
G_AGUP
local exit_code=$?
if (( $exit_code != 0 )); then
whiptail --title "Apt Error:" --msgbox "Failed to update apt, exit code: $exit_code\nPlease try another Apt mirror." --backtitle "$WHIP_BACKTITLE" 8 65
fi
fi
#Return to this Menu
TARGETMENUID=16
#delete []
unset whiptail_menu_array
;;
"NTPD Mirror")
#Create Menu List for Whiptail
local whiptail_menu_array=(
"Custom" "Manually enter NTPD mirror"
)
whiptail_menu_array+=('debian.pool.ntp.org' 'Debian Global')
whiptail_menu_array+=('pool.ntp.org' 'Global')
whiptail_menu_array+=('europe.pool.ntp.org' 'Europe')
whiptail_menu_array+=('north-america.pool.ntp.org' 'North America')
whiptail_menu_array+=('south-america.pool.ntp.org' 'South America')
whiptail_menu_array+=('africa.pool.ntp.org' 'Africa')
whiptail_menu_array+=('asia.pool.ntp.org' 'Asia')
whiptail_menu_array+=('oceania.pool.ntp.org' 'Oceania')
OPTION=$(whiptail --title "Choose NTPD Mirror" --menu "Please select a NTPD mirror, or choose custom for manual entry.\n - Further information: \"http://www.pool.ntp.org/zone/@\"" --default-item "$ntpd_mirror_current" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 16 100 7 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
return_value=$OPTION
case $OPTION in
Custom)
OPTION=$(whiptail --inputbox "Enter Your NTPD Mirror\n - eg: debian.pool.ntp.org" 9 100 "$ntpd_mirror_current" --title "Set NTPD Mirror" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
return_value=$OPTION
fi
;;
esac
sed -i "/CONFIG_NTP_MIRROR=/c\CONFIG_NTP_MIRROR=$OPTION" /DietPi/dietpi.txt
/DietPi/dietpi/func/dietpi-set_software ntpd-mode $(grep -m1 '^CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/.*=//')
#Return to this Menu
TARGETMENUID=16
fi
#delete []
unset whiptail_menu_array
;;
"NFS Client")
#Installed?
if (( ! $nfsclient_installed )); then
whiptail --title "Install NFS Client?" --yesno "NFS Client is not installed, would you like to install it now?\n\nThis will allow you access NFS shares." --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 12 65
CHOICE=$?
if (( $CHOICE == 0 )); then
#install nfsclient
/DietPi/dietpi/dietpi-software install 110
fi
else
/DietPi/dietpi/func/dietpi-set_nfsclient
fi
#Return to this Menu
TARGETMENUID=16
;;
Samba*)
#Installed?
if (( ! $sambaclient_installed )); then
whiptail --title "Install Samba Client?" --yesno "Samba Client is not installed, would you like to install it now?\n\nThis will allow you access Windows shared folders, NAS and CIFS capable devices." --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 12 65
CHOICE=$?
if (( $CHOICE == 0 )); then
#install smbclient
/DietPi/dietpi/dietpi-software install 1
fi
else
/DietPi/dietpi/func/dietpi-set_smbclient
fi
#Return to this Menu
TARGETMENUID=16
;;
FTP*)
#Installed?
if (( ! $curlftpfs_installed )); then
whiptail --title "Install FTP Client?" --yesno "FTP Client (curlftpfs) is not installed, would you like to install it now? \n \n - This is required to mount an FTP connection to filesystem" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 12 65
CHOICE=$?
if (( $CHOICE == 0 )); then
#install curlftpfs
/DietPi/dietpi/dietpi-software install 2
fi
else
/DietPi/dietpi/func/dietpi-set_curlftpfs
fi
#Return to this Menu
TARGETMENUID=16
;;
NoIp)
#Installed?
if (( ! $noip_installed )); then
local noip_url_address=''
whiptail --title "Install NoIp Client?" --yesno "NoIp Client is not installed, would you like to install it now?\n\n- NoIp will allow you to use a fixed web address, regardless of your internet IP\neg: MySuperDooperWebsite.noip2.biz would point to this device!" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 13 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Install
/DietPi/dietpi/dietpi-software install 67
fi
else
clear
service noip2 stop
noip2 -C
read -p "Press any key to continue....."
service noip2 start
fi
#Return to this Menu
TARGETMENUID=16
;;
esac
#Cancel
else
#Exit DietPi-Config on back to previous menu?
if (( $EXITONBACK == 1 )); then
#Return to this menu
TARGETMENUID=16
Menu_Exit
fi
fi
}
PROXY_ENABLED=-1
PROXY_ADDRESS=''
PROXY_PORT=''
PROXY_USERNAME=''
PROXY_PASSWORD=''
#So we can call this in other menus (eg: submenu of this)
Load_Proxy_Vars(){
PROXY_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_ENABLED=' | sed 's/.*=//')
PROXY_ADDRESS=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_ADDRESS=' | sed 's/.*=//')
PROXY_PORT=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_PORT=' | sed 's/.*=//')
PROXY_USERNAME=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_USERNAME=' | sed 's/.*=//')
PROXY_PASSWORD=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_PASSWORD=' | sed 's/.*=//')
}
#TARGETMENUID=17
Menu_NetworkAdapters_Proxy(){
TARGETMENUID=8
#Get current details on first menu init (PROXY_ENABLED=-1)
if (( $PROXY_ENABLED == -1 )); then
Load_Proxy_Vars
proxy_state_text='Disabled'
if (( $PROXY_ENABLED == 1 )); then
proxy_state_text='Enabled'
fi
fi
proxy_state_text_new='No'
if (( $PROXY_ENABLED == 1 )); then
proxy_state_text_new='Yes'
fi
WHIP_TITLE='DietPi - Proxy Network Options'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "\n Current Details:\n - Status: $proxy_state_text\n - Address: $PROXY_ADDRESS\n - Port: $PROXY_PORT\n - Username: $PROXY_USERNAME\n - Password: $PROXY_PASSWORD" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 21 60 6 \
"Toggle" "Use Proxy?: $proxy_state_text_new" \
"Address" "Enter Proxy server IP/URL" \
"Port" "Enter Proxy server port" \
"Username" "Enter Proxy server username" \
"Password" "Enter Proxy server password" \
"Apply" "Save Changes" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
case "$OPTION" in
Toggle)
((PROXY_ENABLED++))
if (( $PROXY_ENABLED >= 2 )); then
PROXY_ENABLED=0
fi
#Return to this menu
TARGETMENUID=17
;;
Address)
OPTION=$(whiptail --inputbox "Please enter the proxy URL or IP address\n - eg: MyProxy.com" 9 65 "$PROXY_ADDRESS" --title "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
PROXY_ADDRESS=$OPTION
fi
#Return to this Menu
TARGETMENUID=17
;;
Port)
OPTION=$(whiptail --inputbox "Please enter the proxy port number\n - eg: 1234" 9 65 "$PROXY_PORT" --title "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
PROXY_PORT=$OPTION
fi
#Return to this Menu
TARGETMENUID=17
;;
Username)
OPTION=$(whiptail --inputbox "Please enter the proxy username\n - eg: JoeBloggs\n - Leave blank if not required" 10 65 "$PROXY_USERNAME" --title "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
PROXY_USERNAME=$OPTION
fi
#Return to this Menu
TARGETMENUID=17
;;
Password)
OPTION=$(whiptail --inputbox "Please enter the proxy password\n - eg: LetMeIn\n - Leave blank if not required" 10 65 "$PROXY_PASSWORD" --title "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
PROXY_PASSWORD=$OPTION
fi
#Return to this Menu
TARGETMENUID=17
;;
Apply)
# - Save settings to dietpi.txt
sed -i "/^CONFIG_PROXY_ENABLED=/c\CONFIG_PROXY_ENABLED=$PROXY_ENABLED" /DietPi/dietpi.txt
sed -i "/^CONFIG_PROXY_ADDRESS=/c\CONFIG_PROXY_ADDRESS=$PROXY_ADDRESS" /DietPi/dietpi.txt
sed -i "/^CONFIG_PROXY_PORT=/c\CONFIG_PROXY_PORT=$PROXY_PORT" /DietPi/dietpi.txt
sed -i "/^CONFIG_PROXY_USERNAME=/c\CONFIG_PROXY_USERNAME=$PROXY_USERNAME" /DietPi/dietpi.txt
sed -i "/^CONFIG_PROXY_PASSWORD=/c\CONFIG_PROXY_PASSWORD=$PROXY_PASSWORD" /DietPi/dietpi.txt
# - Delete active export vars
#unset {http,https,ftp}_proxy #Does not apply to system when running from a bash script.
# - Delete any existing export settings from /etc/bash.bashrc
sed -i '/{http,https,ftp}_proxy=/d' /etc/bash.bashrc
# - Add export settings
if (( $PROXY_ENABLED == 1 )); then
if [ -n "$PROXY_USERNAME" ] && [ -n "$PROXY_PASSWORD" ]; then
cat << _EOF_ >> /etc/bash.bashrc
export {http,https,ftp}_proxy="http://$PROXY_USERNAME:$PROXY_PASSWORD@$PROXY_ADDRESS:$PROXY_PORT"
_EOF_
else
cat << _EOF_ >> /etc/bash.bashrc
export {http,https,ftp}_proxy="http://$PROXY_ADDRESS:$PROXY_PORT"
_EOF_
fi
fi
# - Ask user for reboot now to activate/disable proxy
REBOOT_REQUIRED=1
WHIP_TITLE='Proxy: Reboot required'
WHIP_QUESTION='Your proxy settings have been saved.\n\nNB: You must reboot your system, before the new proxy settings will take effect.\n\nReboot system now?'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 13 65
CHOICE=$?
if (( $CHOICE == 0 )); then
reboot
fi
# - Reset init flag to force a reload of setings next time this menu is run.
PROXY_ENABLED=-1
#Return to this menu
TARGETMENUID=17
;;
esac
#Reset init flag to force a reload of setings next time this menu is run.
else
PROXY_ENABLED=-1
fi
}
#/////////////////////////////////////////////////////////////////////////////////////
# Main Loop
#/////////////////////////////////////////////////////////////////////////////////////
if (( $G_DIETPI_INSTALL_STAGE >= 0 )); then
#Start DietPi-Config
while (( $TARGETMENUID > -1 )); do
#Clear Screen buffer
clear
if (( $TARGETMENUID == 0 )); then
Menu_Main
elif (( $TARGETMENUID == 1 )); then
Menu_DisplayOptions
elif (( $TARGETMENUID == 2 )); then
Menu_DisplayOptions_Driver_Resolution
elif (( $TARGETMENUID == 3 )); then
Menu_AdvancedOptions
elif (( $TARGETMENUID == 4 )); then
Menu_PerformanceOptions
elif (( $TARGETMENUID == 5 )); then
Menu_SecurityOptions
elif (( $TARGETMENUID == 6 )); then
Menu_GpumemoryOptions
elif (( $TARGETMENUID == 7 )); then
Menu_LanguageOptions
elif (( $TARGETMENUID == 8 )); then
Menu_NetworkAdapters
elif (( $TARGETMENUID == 9 )); then
Menu_NetworkAdapters_Ethernet
elif (( $TARGETMENUID == 10 )); then
Menu_NetworkAdapters_Wifi
elif (( $TARGETMENUID == 11 )); then
Menu_Tools
elif (( $TARGETMENUID == 12 )); then
Menu_FilesystemBenchmark
elif (( $TARGETMENUID == 13 )); then
Menu_Overclock
elif (( $TARGETMENUID == 14 )); then
Menu_AudioOptions
elif (( $TARGETMENUID == 15 )); then
Menu_StressTest
elif (( $TARGETMENUID == 16 )); then
Menu_Network_Nas_Misc
elif (( $TARGETMENUID == 17 )); then
Menu_NetworkAdapters_Proxy
fi
done
else
echo -e " >> Filesystem prep has not yet completed: \n Please wait for the system to reboot "
fi
#-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}
^~
../oil_DEPS/wild/src/distro/DietPi/dietpi/dietpi-config:4456: Couldn't find terminator for here doc that starts here
|
|
Parsing dietpi-autostart
|
AST not printed.
|
|
Parsing dietpi-letsencrypt
|
AST not printed.
|
|
Parsing dietpi-cron
|
AST not printed.
|
|
Parsing dietpi-ramdisk
|
AST not printed.
|