#!/bin/bash
{
#////////////////////////////////////
# DietPi Software
#
#////////////////////////////////////
# Created by Daniel Knight / daniel_haze@hotmail.com / dietpi.com
#
#////////////////////////////////////
#
# Info:
# - filename /DietPi/dietpi/dietpi-software
# - Installs "ready to run" software with optimizations unique to the device.
# - Runs dietpi-update during 1st run setup.
# - Generates and uses /DietPi/dietpi/.installed (software list) # 0=not installed, 1=selected for install, 2=installed
#////////////////////////////////////
#Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales.
LANG=en_GB.UTF-8
#Exit path for non-root logins.
if (( $UID != 0 )); then
clear
echo -e "\n ERROR: You do not have root privileges.\n Please login as root, or, use:\n sudo dietpi-software\n"
exit
fi
#/////////////////////////////////////////////////////////////////////////////////////
#Obtain Install Stage Index
#/////////////////////////////////////////////////////////////////////////////////////
# -3 = first boot / -2 = partition / -1 = filesystem / 0 = run dietpi-software at login / 1 = completed
DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage)
#/////////////////////////////////////////////////////////////////////////////////////
#Hardware Details
#/////////////////////////////////////////////////////////////////////////////////////
HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) # 0=1(256) 1=1(512) 2=2(1024)
HW_MODEL_DESCRIPTION=$(sed -n 2p /DietPi/dietpi/.hw_model)
DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model)
#cpu/core count
CPU_CORES_TOTAL=$(nproc --all)
#Overide XU3/4 to 4 cores
if (( $HW_MODEL == 11 )); then
CPU_CORES_TOTAL=4
fi
#/////////////////////////////////////////////////////////////////////////////////////
#Filepath
#/////////////////////////////////////////////////////////////////////////////////////
FP_INSTALLED_FILE="/DietPi/dietpi/.installed"
FP_DIETPIAUTOMATION_LOG="/root/DietPi-Automation.log"
#Used to set user/personal data directories (eg: usbdrive /mnt/usb_1)
TARGET_DIRECTORY="/root"
#Uninstall temp file
UNINSTALL_FILE='/tmp/dietpi_uninstall_list'
#Default user content folders used in DietPi.
FOLDER_MUSIC='Music'
FOLDER_PICTURES='Pictures'
FOLDER_VIDEO='Video'
FOLDER_DOWNLOADS='downloads'
#/////////////////////////////////////////////////////////////////////////////////////
# Installation System Vars
#/////////////////////////////////////////////////////////////////////////////////////
#Run Instalation Flag (1 = run installs)
GOSTARTINSTALL=0
INSTALL_URL_ADDRESS=""
INSTALL_DESCRIPTION='DietPi'
#Special installation Vars
USER_EMONHUB_APIKEY_COMPLETED=0
USER_EMONHUB_APIKEY_CURRENT=0
#DietPi Software
INSTALL_DIETPI_CHOICESMADE=false
#Linux Software
INSTALL_LINUX_CHOICESMADE=false
#SSH Server Choices system
INSTALL_SSHSERVER_CHOICESMADE=false
#Fileserver Choices system
INSTALL_FILESERVER_CHOICESMADE=false
#Logging Choices system
INSTALL_LOGGING_CHOICESMADE=false
#/////////////////////////////////////////////////////////////////////////////////////
# First Run / Automation functions Vars (eg: on a fresh install)
#/////////////////////////////////////////////////////////////////////////////////////
AUTOINSTALL_INDEX=0
AUTOINSTALL_SKIPUSBDRIVEPROMPT=0
AUTOINSTALL_SKIPQUESTIONS=0
AUTOINSTALL_IGNOREERRORS=0
AUTOINSTALL_DEDICATEDUSBDRIVEFORMAT=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
#/////////////////////////////////////////////////////
# Error Vars
#/////////////////////////////////////////////////////
ERROR_TEXT=""
#/////////////////////////////////////////////////////////////////////////////////////
# WHIPTAIL MENU Vars
#/////////////////////////////////////////////////////////////////////////////////////
WHIP_BACKTITLE='DietPi-Software'
WHIP_TITLE=0
WHIP_QUESTION=0
MENU_MAIN_LASTITEM=""
TARGETMENUID=0
#/////////////////////////////////////////////////////////////////////////////////////
# Internet Connection Test Vars
#/////////////////////////////////////////////////////////////////////////////////////
INTERNET_CONNECTED=0
#Use /etc/apt/sources.list for connection test
INTERNET_URL_TEST=$(cat /etc/apt/sources.list | grep -m1 "deb http" | awk '{print $2}')
#Global funcs
Check_Internet_Connection(){
INTERNET_CONNECTED=0
while (( $INTERNET_CONNECTED == 0 )); do
/DietPi/dietpi/func/check_connection "$INTERNET_URL_TEST"
if (( $? == 0 )); then
INTERNET_CONNECTED=1
else
Menu_No_Internet
fi
done
}
Create_UserContent_Folders(){
mkdir -p "$TARGET_DIRECTORY"/"$FOLDER_MUSIC" &> /dev/null
mkdir -p "$TARGET_DIRECTORY"/"$FOLDER_PICTURES" &> /dev/null
mkdir -p "$TARGET_DIRECTORY"/"$FOLDER_VIDEO" &> /dev/null
mkdir -p "$TARGET_DIRECTORY"/"$FOLDER_DOWNLOADS" &> /dev/null
chmod -R 775 "$TARGET_DIRECTORY"/"$FOLDER_MUSIC"
chmod -R 775 "$TARGET_DIRECTORY"/"$FOLDER_PICTURES"
chmod -R 775 "$TARGET_DIRECTORY"/"$FOLDER_VIDEO"
chmod -R 775 "$TARGET_DIRECTORY"/"$FOLDER_DOWNLOADS"
}
Download_Test_Media(){
if [ ! -f "$TARGET_DIRECTORY/$FOLDER_MUSIC"/fourdee_tech.ogg ]; then
#Grab My test music
wget http://dietpi.com/downloads/audio/fourdee_tech.ogg -O "$TARGET_DIRECTORY/$FOLDER_MUSIC"/fourdee_tech.ogg
#Grab Absolute Radio Streams
wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=vrbb -O "$TARGET_DIRECTORY/$FOLDER_MUSIC"/Absolute-Radio.pls
wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a8bb -O "$TARGET_DIRECTORY/$FOLDER_MUSIC"/Absolute-Radio-80s.pls
wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a9bb -O "$TARGET_DIRECTORY/$FOLDER_MUSIC"/Absolute-Radio-90s.pls
wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a0bb -O "$TARGET_DIRECTORY/$FOLDER_MUSIC"/Absolute-Radio-00s.pls
fi
}
#apt-get install
AGI(){
local string="$@"
DEBIAN_FRONTEND=noninteractive apt-get install -y $string
local result=$?
if (( $result != 0 )); then
Error_AptGet_Failed
fi
}
Write_InstallFileList(){
##Write_InstallFileList = write to /DietPi/dietpi/.installed
##Write_InstallFileList 1 = write to /tmp/dietpi-software_selected (used to obtain list of selected software to prompt user before startring)
#FP_INSTALLED_FILE="/DietPi/dietpi/.installed"
#if [[ $1 =~ ^-?[0-9]+$ ]]; then
# if (( $1 == 1 )); then
# FP_INSTALLED_FILE="/tmp/dietpi-software_selected"
# fi
#fi
#Leave this until we have a SQL database to read from.
local output="
#DietPi External Drive
USBDRIVE=${USBDRIVE:=0}
#DietPi Software
GRASSHOPPER=${GRASSHOPPER:=0}
DESKTOP_LXDE=${DESKTOP_LXDE:=0}
WEBSERVER_LAMP=${WEBSERVER_LAMP:=0}
WEBSERVER_LASP=${WEBSERVER_LASP:=0}
WEBSERVER_LAAP=${WEBSERVER_LAAP:=0}
WEBSERVER_LEMP=${WEBSERVER_LEMP:=0}
WEBSERVER_LESP=${WEBSERVER_LESP:=0}
WEBSERVER_LEAP=${WEBSERVER_LEAP:=0}
WEBSERVER_LLMP=${WEBSERVER_LLMP:=0}
WEBSERVER_LLSP=${WEBSERVER_LLSP:=0}
WEBSERVER_LLAP=${WEBSERVER_LLAP:=0}
WEBSERVER_APACHE=${WEBSERVER_APACHE:=0}
WEBSERVER_NGINX=${WEBSERVER_NGINX:=0}
WEBSERVER_LIGHTTPD=${WEBSERVER_LIGHTTPD:=0}
WEBSERVER_MYSQL=${WEBSERVER_MYSQL:=0}
WEBSERVER_MARIADB=${WEBSERVER_MARIADB:=0}
WEBSERVER_SQLITE=${WEBSERVER_SQLITE:=0}
WEBSERVER_PHP=${WEBSERVER_PHP:=0}
WEBSERVER_MYADMINPHP=${WEBSERVER_MYADMINPHP:=0}
WEBSERVER_REDIS=${WEBSERVER_REDIS:=0}
OPENBAZAAR=${OPENBAZAAR:=0}
OWNCLOUD=${OWNCLOUD:=0}
TRANSMISSION=${TRANSMISSION:=0}
PHPBB=${PHPBB:=0}
HIFI=${HIFI:=0}
KODI=${KODI:=0}
MINIDLNA=${MINIDLNA:=0}
NOIPDYNDNS=${NOIPDYNDNS:=0}
OPENTYRIAN=${OPENTYRIAN:=0}
DIETPICAM=${DIETPICAM:=0}
DELUGE=${DELUGE:=0}
FILESERVER_SAMBA=${FILESERVER_SAMBA:=0}
FILESERVER_PROFTP=${FILESERVER_PROFTP:=0}
FILESERVER_VSFTPD=${FILESERVER_VSFTPD:=0}
RASPCONTROL=${RASPCONTROL:=0}
LINUXDASH=${LINUXDASH:=0}
PIHOLE=${PIHOLE:=0}
SUBSONIC=${SUBSONIC:=0}
WEAVED=${WEAVED:=0}
WEBIOPI=${WEBIOPI:=0}
DIETPICLOUDSHELL=${DIETPICLOUDSHELL:=0}
HAPROXY=${HAPROXY:=0}
SQUEEZEBOXSERVER=${SQUEEZEBOXSERVER:=0}
WORDPRESS=${WORDPRESS:=0}
TIGHTVNCSERVER=${TIGHTVNCSERVER:=0}
FAIL2BAN=${FAIL2BAN:=0}
PHPSYSINFO=${PHPSYSINFO:=0}
PHPIMAGEGALLERY=${PHPIMAGEGALLERY:=0}
AMPACHE=${AMPACHE:=0}
OPENVPNSERVER=${OPENVPNSERVER:=0}
LETSENCRYPT=${LETSENCRYPT:=0}
WIRINGPI=${WIRINGPI:=0}
RPIGPIO=${RPIGPIO:=0}
RPII2C=${RPII2C:=0}
WIFIHOTSPOT=${WIFIHOTSPOT:=0}
TORHOTSPOT=${TORHOTSPOT:=0}
SHAIRPORTSYNC=${SHAIRPORTSYNC:=0}
BRUTEFIR=${BRUTEFIR:=0}
PYDIO=${PYDIO:=0}
SQUEEZELITE=${SQUEEZELITE:=0}
EMONHUB=${EMONHUB:=0}
EMONCMS=${EMONCMS:=0}
RPIMONITOR=${RPIMONITOR:=0}
NETDATA=${NETDATA:=0}
BAIKAL=${BAIKAL:=0}
MUMBLESERVER=${MUMBLESERVER:=0}
#Additional Linux Software
VIMFULL=${VIMFULL:=0}
SSHCLIENT=${SSHCLIENT:=0}
SMBCLIENT=${SMBCLIENT:=0}
GITCLIENT=${GITCLIENT:=0}
BUILDESSENTIAL=${BUILDESSENTIAL:=0}
ALSABASE=${ALSABASE:=0}
XSERVERXORG=${XSERVERXORG:=0}
CURLFTPFS=${CURLFTPFS:=0}
FFMPEG=${FFMPEG:=0}
ORACLEJAVA=${ORACLEJAVA:=0}
NODEJS=${NODEJS:=0}
SSHSERVER_DROPBEAR=${SSHSERVER_DROPBEAR:=2}
SSHSERVER_OPENSSH=${SSHSERVER_OPENSSH:=0}
LOGGING_LOGROTATE=${LOGGING_LOGROTATE:=0}
LOGGING_RAMLOG=${LOGGING_RAMLOG:=2}
LOGGING_RSYSLOG=${LOGGING_RSYSLOG:=0}
#DietPi Choice System: SSH Server
INDEX_SSHSERVER_CURRENT=${INDEX_SSHSERVER_CURRENT:=-1}
INDEX_SSHSERVER_TARGET=${INDEX_SSHSERVER_TARGET:=-1}
#DietPi Choice System: File Server
INDEX_FILESERVER_CURRENT=${INDEX_FILESERVER_CURRENT:=0}
INDEX_FILESERVER_TARGET=${INDEX_FILESERVER_TARGET:=0}
#DietPi Choice System: Logging
INDEX_LOGGING_CURRENT=${INDEX_LOGGING_CURRENT:=-1}
INDEX_LOGGING_TARGET=${INDEX_LOGGING_TARGET:=-1}
#DietPi Preference System: Webserver base
INDEX_WEBSERVER_CURRENT=${INDEX_WEBSERVER_CURRENT:=-2}
INDEX_WEBSERVER_TARGET=${INDEX_WEBSERVER_TARGET:=-2}
"
echo "$output"_ > "$FP_INSTALLED_FILE"
}
Read_InstallFileList(){
if [[ -f "$FP_INSTALLED_FILE" ]]; then
. "$FP_INSTALLED_FILE"
fi
}
Install_Dietpi_Software(){
#--------------------------------------------------------------
# Stop Services
/DietPi/dietpi/dietpi-services stop
#--------------------------------------------------------------
#Text install info vars (for Webserver stacks)
local info_1="LAMP"
local info_2="Apache2"
local info_3="MySql"
local info_4="PHP"
# Apply all "combo" installs that require webserver stack
# - Installs that require any WEBSERVER_L??P
if (( $DIETPICAM || $LINUXDASH || $PIHOLE || $PHPSYSINFO || $PHPIMAGEGALLERY )); then
# - Check for existing installations
if (( ! $WEBSERVER_LAMP && ! $WEBSERVER_LASP && ! $WEBSERVER_LAAP && \
! $WEBSERVER_LLMP && ! $WEBSERVER_LLSP && ! $WEBSERVER_LLAP && \
! $WEBSERVER_LEMP && ! $WEBSERVER_LESP && ! $WEBSERVER_LEAP )); then
# - None found, Select one for Install, based on user preference
if (( $INDEX_WEBSERVER_TARGET == 0 )); then
WEBSERVER_LASP=1
elif (( $INDEX_WEBSERVER_TARGET == -1 )); then
WEBSERVER_LESP=1
elif (( $INDEX_WEBSERVER_TARGET == -2 )); then
WEBSERVER_LLSP=1
fi
fi
fi
# - Installs that require a SQLite stack: WEBSERVER_L?SP
if (( $GRASSHOPPER )); then
# - Check for existing installations
if (( ! $WEBSERVER_LASP && ! $WEBSERVER_LLSP && ! $WEBSERVER_LESP )); then
if (( $WEBSERVER_LAMP || $WEBSERVER_LAAP )); then
WEBSERVER_LASP=1
elif (( $WEBSERVER_LLMP || $WEBSERVER_LLAP )); then
WEBSERVER_LLSP=1
elif (( $WEBSERVER_LEMP || $WEBSERVER_LEAP )); then
WEBSERVER_LESP=1
# - None found, Select one for Install, based on user preference
else
if (( $INDEX_WEBSERVER_TARGET == 0 )); then
WEBSERVER_LASP=1
elif (( $INDEX_WEBSERVER_TARGET == -1 )); then
WEBSERVER_LESP=1
elif (( $INDEX_WEBSERVER_TARGET == -2 )); then
WEBSERVER_LLSP=1
fi
fi
fi
fi
# - Installs that require a MySQL stack: WEBSERVER_L?[MA]P
if (( $OWNCLOUD || $PHPBB || $WORDPRESS || $AMPACHE || $PYDIO || $EMONCMS || $BAIKAL )); then
# - Check for existing installations
if (( ! $WEBSERVER_LAMP && ! $WEBSERVER_LAAP && \
! $WEBSERVER_LLMP && ! $WEBSERVER_LLAP && \
! $WEBSERVER_LEMP && ! $WEBSERVER_LEAP )); then
if (( $WEBSERVER_LASP )); then
WEBSERVER_LAMP=1
elif (( $WEBSERVER_LLSP )); then
WEBSERVER_LLMP=1
elif (( $WEBSERVER_LESP )); then
WEBSERVER_LEMP=1
# - None found, Select one for Install, based on user preference
else
if (( $INDEX_WEBSERVER_TARGET == 0 )); then
WEBSERVER_LAMP=1
elif (( $INDEX_WEBSERVER_TARGET == -1 )); then
WEBSERVER_LEMP=1
elif (( $INDEX_WEBSERVER_TARGET == -2 )); then
WEBSERVER_LLMP=1
fi
fi
fi
fi
#Define extra DietPi install flags for WEBSERVER_STACKS
if (( $WEBSERVER_LLAP == 1 )); then
WEBSERVER_LIGHTTPD=1
WEBSERVER_MARIADB=1
WEBSERVER_PHP=1
info_1="LLAP"
info_2="Lighttpd"
info_3="MariaDB"
info_4="PHP"
fi
if (( $WEBSERVER_LLSP == 1 )); then
WEBSERVER_LIGHTTPD=1
WEBSERVER_SQLITE=1
WEBSERVER_PHP=1
info_1="LLSP"
info_2="Lighttpd"
info_3="SQLite"
info_4="PHP"
fi
if (( $WEBSERVER_LLMP == 1 )); then
WEBSERVER_LIGHTTPD=1
WEBSERVER_MYSQL=1
WEBSERVER_PHP=1
info_1="LLMP"
info_2="Lighttpd"
info_3="MySql"
info_4="PHP"
fi
if (( $WEBSERVER_LEAP == 1 )); then
WEBSERVER_NGINX=1
WEBSERVER_MARIADB=1
WEBSERVER_PHP=1
info_1="LEAP"
info_2="Nginx"
info_3="MariaDB"
info_4="PHP"
fi
if (( $WEBSERVER_LESP == 1 )); then
WEBSERVER_NGINX=1
WEBSERVER_SQLITE=1
WEBSERVER_PHP=1
info_1="LESP"
info_2="Nginx"
info_3="SQLite"
info_4="PHP"
fi
if (( $WEBSERVER_LEMP == 1 )); then
WEBSERVER_NGINX=1
WEBSERVER_MYSQL=1
WEBSERVER_PHP=1
info_1="LEMP"
info_2="Nginx"
info_3="MySql"
info_4="PHP"
fi
if (( $WEBSERVER_LAAP == 1 )); then
WEBSERVER_APACHE=1
WEBSERVER_MARIADB=1
WEBSERVER_PHP=1
info_1="LAAP"
info_2="Apache2"
info_3="MariaDB"
info_4="PHP"
fi
if (( $WEBSERVER_LASP == 1 )); then
WEBSERVER_APACHE=1
WEBSERVER_SQLITE=1
WEBSERVER_PHP=1
info_1="LASP"
info_2="Apache2"
info_3="SQLite"
info_4="PHP"
fi
if (( $WEBSERVER_LAMP == 1 )); then
WEBSERVER_APACHE=1
WEBSERVER_MYSQL=1
WEBSERVER_PHP=1
info_1="LAMP"
info_2="Apache2"
info_3="MySql"
info_4="PHP"
fi
#--------------------------------------------------------------
#Install Software
#Installs that require DESKTOP_LXDE
if (( $TIGHTVNCSERVER == 1 )); then
DESKTOP_LXDE=1
fi
#Desktop LXDE
if (( $DESKTOP_LXDE == 1 )); then
INSTALL_DESCRIPTION='Desktop (LXDE)'
Banner_Installing
AGI lxde upower policykit-1 iceweasel p7zip-full --no-install-recommends
#upower policykit-1. Needed for LXDE logout menu item to show shutdown/restart ......
fi
#BitTorrent Transmission
if (( $TRANSMISSION == 1 )); then
INSTALL_DESCRIPTION='BitTorrent (Transmission)'
Banner_Installing
AGI transmission-daemon
fi
#ProFTPd
if (( $FILESERVER_PROFTP == 1 )); then
INSTALL_DESCRIPTION='FTP Server (Proftp)'
Banner_Installing
echo -e "proftpd-basic shared/proftpd/inetd_or_standalone select standalone" | debconf-set-selections
AGI proftpd-basic
fi
#Samba Server
if (( $FILESERVER_SAMBA == 1 )); then
INSTALL_DESCRIPTION='Samba File Server'
Banner_Installing
AGI samba samba-common-bin --no-install-recommends
fi
#vsFTPD
if (( $FILESERVER_VSFTPD == 1 )); then
INSTALL_DESCRIPTION='FTP Server (vsFTPD)'
Banner_Installing
AGI vsftpd --no-install-recommends
fi
#WEBSERVER_APACHE
if (( $WEBSERVER_APACHE == 1 )); then
INSTALL_DESCRIPTION="$info_1: ($info_2) / $info_3 / $info_4"
Banner_Installing
AGI apache2
fi
#WEBSERVER_NGINX
if (( $WEBSERVER_NGINX == 1 )); then
INSTALL_DESCRIPTION="$info_1: ($info_2) / $info_3 / $info_4"
Banner_Installing
AGI nginx xml-core --no-install-recommends
fi
#WEBSERVER_LIGHTTPD
if (( $WEBSERVER_LIGHTTPD == 1 )); then
INSTALL_DESCRIPTION="$info_1: ($info_2) / $info_3 / $info_4"
Banner_Installing
AGI lighttpd
fi
#WEBSERVER_MYSQL
if (( $WEBSERVER_MYSQL == 1 )); then
INSTALL_DESCRIPTION="$info_1: $info_2 / ($info_3) / $info_4"
Banner_Installing
echo -e "mysql-server mysql-server/root_password password dietpi" | debconf-set-selections
echo -e "mysql-server mysql-server/root_password_again password dietpi" | debconf-set-selections
AGI mysql-server
fi
#WEBSERVER_MARIADB
if (( $WEBSERVER_MARIADB == 1 )); then
INSTALL_DESCRIPTION="$info_1: $info_2 / ($info_3) / $info_4"
Banner_Installing
echo -e "mysql-server mysql-server/root_password password dietpi" | debconf-set-selections
echo -e "mysql-server mysql-server/root_password_again password dietpi" | debconf-set-selections
AGI mariadb-server mariadb-client
fi
#WEBSERVER_SQLITE
if (( $WEBSERVER_SQLITE == 1 )); then
INSTALL_DESCRIPTION="$info_1: $info_2 / ($info_3) / $info_4"
Banner_Installing
AGI sqlite3
fi
# - Installs that require WEBSERVER_REDIS
# if (( $EMONCMS == 1 )); then
# WEBSERVER_REDIS=1
# fi
#WEBSERVER_REDIS
if (( $WEBSERVER_REDIS == 1 )); then
INSTALL_DESCRIPTION="Redis Server"
Banner_Installing
AGI redis-server
fi
#WEBSERVER_PHP
if (( $WEBSERVER_PHP == 1 )); then
INSTALL_DESCRIPTION="$info_1: $info_2 / $info_3 / ($info_4)"
Banner_Installing
#Install base PHP packages/modules.
if (( $WEBSERVER_APACHE == 1 )); then
AGI php5 libapache2-mod-php5
else
AGI php5-fpm php5-cgi php5-xsl
fi
#php-SQL modules
if (( $WEBSERVER_MYSQL == 1 )) ||
(( $WEBSERVER_MARIADB == 1 )); then
AGI php5-mysql
fi
if (( $WEBSERVER_SQLITE == 1 )); then
AGI php5-sqlite
fi
#Redis php5 module | >= 1 to check for existing installs (2)
if (( $WEBSERVER_REDIS >= 1 )); then
AGI php5-redis
fi
#Wheezy - APC
if (( $DISTRO == 1 )); then
AGI php-apc
#Jessie - APCu
else
AGI php5-apcu
fi
fi
#WEBSERVER_MYADMINPHP
if (( $WEBSERVER_MYADMINPHP == 1 )); then
INSTALL_DESCRIPTION='phpMyAdmin'
Banner_Installing
#Mysql must be running during install to allow debconf setup.
service mysql start &> /dev/null
debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true"
debconf-set-selections <<< "phpmyadmin phpmyadmin/database-type select mysql"
debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password dietpi"
debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password dietpi"
debconf-set-selections <<< "phpmyadmin phpmyadmin/password-confirm password dietpi"
debconf-set-selections <<< "phpmyadmin phpmyadmin/setup-password password dietpi"
debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password dietpi"
if (( $WEBSERVER_APACHE == 1 )); then
debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2"
elif (( $WEBSERVER_LIGHTTPD == 1 )); then
debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect lighttpd"
else
debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect none"
fi
AGI phpmyadmin
fi
#Forums PHPBB
if (( $PHPBB == 1 )); then
INSTALL_DESCRIPTION='phpBB3 Forums'
Banner_Installing
INSTALL_URL_ADDRESS='https://www.phpbb.com/files/release/phpBB-3.1.6.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip -d /var/www
rm package.zip
else
Error_NoConnection_NoInstall
#Abort failed install
PHPBB=0
fi
fi
#OPENBAZAAR
if (( $OPENBAZAAR == 1 )); then
INSTALL_DESCRIPTION='OpenBazaar'
Banner_Installing
AGI libssl-dev libffi-dev python-dev openssl python-pip libzmq3-dev
add-apt-repository ppa:chris-lea/libsodium
AGI libsodium-dev
pip install cryptography
AGI autoconf pkg-config libtool
cd
git clone https://github.com/zeromq/libzmq
git clone https://github.com/pyca/pynacl/
git clone https://github.com/OpenBazaar/OpenBazaar-Server.git
cd
cd libzmq
./autogen.sh && ./configure && make -j 4
make check && make install && ldconfig
cd
cd pynacl
python setup.py build && python setup.py install
cd
cd OpenBazaar-Server
pip install -r requirements.txt
fi
#OwnCloud
if (( $OWNCLOUD == 1 )); then
INSTALL_DESCRIPTION='OwnCloud'
Banner_Installing
#Wheezy
if (( $DISTRO == 1 )); then
INSTALL_URL_ADDRESS='http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/'
#Jessie
elif (( $DISTRO == 3 )); then
INSTALL_URL_ADDRESS='http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_8.0/'
fi
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
if [ ! -f /etc/apt/sources.list.d/owncloud.list ]; then
echo "deb $INSTALL_URL_ADDRESS /" > /etc/apt/sources.list.d/owncloud.list
wget "$INSTALL_URL_ADDRESS"Release.key
apt-key add - < Release.key
apt-get update
fi
AGI owncloud --force-yes
else
Error_NoConnection_NoInstall
#Abort failed install
OWNCLOUD=0
fi
fi
#Hifi
if (( $HIFI == 1 )); then
INSTALL_DESCRIPTION='Hifi / Web Interface Music Player (Mpd Ympd)'
Banner_Installing
#check source is online
INSTALL_URL_ADDRESS='http://www.ympd.org/downloads/ympd-1.2.3-armhf.tar.bz2'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
#Install MPD
AGI mpd libmpdclient2
#Setup ympd
wget "$INSTALL_URL_ADDRESS"
tar -xvf ympd-*
rm ympd-*
mv ympd /usr/bin/ympd
else
Error_NoConnection_NoInstall
#Abort failed install
HIFI=0
fi
fi
#Kodi
if (( $KODI == 1 )); then
INSTALL_DESCRIPTION='Kodi'
Banner_Installing
#Wheezy
if (( $DISTRO == 1 )); then
if (( $HW_MODEL < 10 )); then
#check source is online
INSTALL_URL_ADDRESS='http://archive.mene.za.net/raspbian'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
#Check if apt address and key needs adding
if (( $(cat /etc/apt/sources.list.d/mene.list | grep -ci -m1 'http://archive.mene.za.net/raspbian') == 0 )); then
echo -e 'deb http://archive.mene.za.net/raspbian wheezy contrib' >> /etc/apt/sources.list.d/mene.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-key 5243CDED
fi
apt-get update
INSTALL_DESCRIPTION='Kodi (Michael Gorven Repo)'
Banner_Installing
AGI kodi
else
Error_NoConnection_NoInstall
#Abort failed install
KODI=0
fi
fi
#Jessie
elif (( $DISTRO == 3 )); then
#Odroids
if (( $HW_MODEL >= 10 )) && (( $HW_MODEL < 20 )); then
AGI kodi-odroid
#XU4 - requires pulse audio (fixes corrupt sound)
if (( $HW_MODEL == 11 )); then
AGI pulseaudio --no-install-recommends
fi
#Everything else
else
AGI kodi
fi
fi
fi
#MINIDLNA
if (( $MINIDLNA == 1 )); then
INSTALL_DESCRIPTION='DLNA/UPnP Media Server (MiniDLNA)'
Banner_Installing
AGI minidlna
fi
#NoIp
if (( $NOIPDYNDNS == 1 )); then
INSTALL_DESCRIPTION='Website URL Address (No-Ip)'
Banner_Installing
#x32 x64
if (( $HW_MODEL == 20 )); then
INSTALL_URL_ADDRESS="http://dietpi.com/downloads/binaries/all/noip_x32_x64.zip"
#arm64
elif (( $HW_MODEL == 12 )); then
INSTALL_URL_ADDRESS="http://dietpi.com/downloads/binaries/all/noip_arm64.zip"
#armv6+
else
INSTALL_URL_ADDRESS="http://dietpi.com/downloads/binaries/all/noip_armhf.zip"
fi
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
#NoIp Binary install
wget "$INSTALL_URL_ADDRESS" -O dietpi-noip.zip
unzip dietpi-noip.zip
rm dietpi-noip.zip
mv noip_binary /usr/local/bin/noip2
chmod +x /usr/local/bin/noip2
#noip2 service file
cp /DietPi/dietpi/conf/noip_init /etc/init.d/noip2
chmod +x /etc/init.d/noip2
update-rc.d noip2 defaults
else
Error_NoConnection_NoInstall
#Abort failed install
NOIPDYNDNS=0
fi
fi
#OpenTyrian
if (( $OPENTYRIAN == 1 )); then
INSTALL_DESCRIPTION='Gaming (OpenTyrian Game)'
Banner_Installing
INSTALL_URL_ADDRESS="http://dietpi.com/downloads/binaries/rpi/opentyrian_armhf.zip"
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
AGI ibsdl1.2debian libsdl-net1.2 --no-install-recommends
#Download binaries
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip -d /
rm package.zip
chmod +x /usr/local/games/opentyrian/opentyrian
else
Error_NoConnection_NoInstall
#Abort failed install
OPENTYRIAN=0
fi
fi
if (( $DIETPICAM == 1 )); then
INSTALL_DESCRIPTION='RPi Camera / Web Interface Surveillance (DietPi-Cam)'
Banner_Installing
#check source is online
INSTALL_URL_ADDRESS='https://github.com/Fourdee/RPi_Cam_Web_Interface/archive/6.0.19.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
#Install pre-reqs
AGI gpac motion
#Get source/binaries and extract
wget "$INSTALL_URL_ADDRESS" -O File.zip
unzip File.zip
rm File.zip
#work form inside RPi_Cam folder
cd RPi_Cam*
#Setup /var/www/dietpicam
mkdir -p /var/www/dietpicam/media
cp -R www/* /var/www/dietpicam/
chmod +x /var/www/dietpicam/raspizip.sh
mknod /var/www/dietpicam/FIFO p
mknod /var/www/dietpicam/FIFO1 p
#Temp cam.jpg file symlink
ln -sf /run/shm/mjpeg/cam.jpg /var/www/dietpicam/cam.jpg
#Setup Raspimjpeg binary
cp bin/raspimjpeg /opt/vc/bin/raspimjpeg
chmod +x /opt/vc/bin/raspimjpeg
ln -s /opt/vc/bin/raspimjpeg /usr/bin/raspimjpeg
#Cleanup / remove extracted source
cd "$HOME"/
rm -R "$HOME"/RPi_Cam*
else
Error_NoConnection_NoInstall
#Abort failed install
DIETPICAM=0
fi
fi
#DELUGE
if (( $DELUGE == 1 )); then
INSTALL_DESCRIPTION='Deluge (BitTorrent Server, Web Interface)'
Banner_Installing
AGI deluged deluge-web deluge-webui deluge-console
fi
#GRASSHOPPER
if (( $GRASSHOPPER == 1 )); then
INSTALL_DESCRIPTION='Grasshopper'
Banner_Installing
AGI python
#Download Grasshopper
local grasshopper_directory='/var/www'
INSTALL_URL_ADDRESS='http://sourceforge.net/projects/grasshopperwebapp/files/grasshopper_v5_application.zip/download'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O grasshopper.zip
unzip grasshopper.zip -d "$grasshopper_directory"
rm grasshopper.zip
#Install
chmod +x "$grasshopper_directory"/install/install.sh
"$grasshopper_directory"/install/install.sh
else
Error_NoConnection_NoInstall
GRASSHOPPER=0
fi
fi
#RASPCONTROL
if (( $RASPCONTROL == 1 )); then
INSTALL_DESCRIPTION='Raspcontrol (Web interface system stats)'
Banner_Installing
INSTALL_URL_ADDRESS='https://github.com/harmon25/raspcontrol/archive/master.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip
rm package.zip
mkdir -p /var/www/raspcontrol
mv raspcontrol-master/* /var/www/raspcontrol
rm -R raspcontrol-master
else
Error_NoConnection_NoInstall
RASPCONTROL=0
fi
fi
#LINUXDASH
if (( $LINUXDASH == 1 )); then
INSTALL_DESCRIPTION='Linux Dash (Web interface system stats)'
Banner_Installing
INSTALL_URL_ADDRESS='https://github.com/afaqurk/linux-dash/archive/master.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip
rm package.zip
mkdir -p /var/www/linuxdash
mv linux-dash-master/* /var/www/linuxdash
rm -R linux-dash-master
else
Error_NoConnection_NoInstall
LINUXDASH=0
fi
fi
#PIHOLE
if (( $PIHOLE == 1 )); then
INSTALL_DESCRIPTION='Pi-hole (Block adverts on your network)'
Banner_Installing
# - Web stats (Downloaded as zip)
INSTALL_URL_ADDRESS='https://github.com/Fourdee/AdminLTE/archive/master.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
if (( $? == 0 )); then
#Install
AGI dnsmasq bc
service dnsmasq stop
#Generate PiHole Dirs
mkdir -p /etc/pihole
mkdir -p /var/www/pihole
#Grab/Setup Web interface panel
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip
mv AdminLTE-master/* /var/www/pihole/
rm -R AdminLTE-master
rm package.zip
# - Grab chronometer (this script is run to parse logfiles for PiHole webpage stats)
wget https://raw.githubusercontent.com/Fourdee/pi-hole/master/advanced/Scripts/chronometer.sh -O /usr/local/bin/chronometer.sh
chmod +x /usr/local/bin/chronometer.sh
# - Blacklist/whitelist scripts
wget https://raw.githubusercontent.com/Fourdee/pi-hole/master/advanced/Scripts/blacklist.sh -O /usr/local/bin/blacklist.sh
chmod +x /usr/local/bin/blacklist.sh
wget https://raw.githubusercontent.com/Fourdee/pi-hole/master/advanced/Scripts/whitelist.sh -O /usr/local/bin/whitelist.sh
chmod +x /usr/local/bin/whitelist.sh
# - Default ads list
wget https://raw.githubusercontent.com/Fourdee/pi-hole/master/adlists.default -O /etc/pihole/adlists.default
#Check free available memory. Increase swapfile size to prevent gravity running out of mem.
if (( $(free -m -o | grep -m1 'Mem:' | awk '{print $4}') < 512 )); then
if [ -f /etc/dphys-swapfile ] &&
(( $(cat /etc/dphys-swapfile | grep 'CONF_SWAPSIZE=' | sed 's/.*=//') < 512 )); then
echo -e "\nDietPi:\nIncreasing swapfile size to 512MB before running gravity.sh, please wait.....\n"
/DietPi/dietpi/func/dietpi-set_dphys-swapfile 512
fi
fi
#Run and update adblocking databases (gravity)
wget https://raw.githubusercontent.com/Fourdee/pi-hole/master/gravity.sh -O /usr/local/bin/gravity.sh
chmod 755 /usr/local/bin/gravity.sh
/usr/local/bin/gravity.sh
else
Error_NoConnection_NoInstall
PIHOLE=0
fi
fi
#SUBSONIC
if (( $SUBSONIC == 1 )); then
INSTALL_DESCRIPTION='SubSonic (Web interface media streamer)'
Banner_Installing
INSTALL_URL_ADDRESS='http://sourceforge.net/projects/subsonic/files/subsonic/5.3/subsonic-5.3.deb/download'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
if (( $? == 0 )); then
AGI lame
#Install SubSonic
wget "$INSTALL_URL_ADDRESS" -O package.deb
dpkg -i package.deb
rm package.deb
else
Error_NoConnection_NoInstall
SUBSONIC=0
fi
fi
#WEAVED
if (( $WEAVED == 1 )); then
INSTALL_DESCRIPTION='Weaved (Access your device over the internet)'
Banner_Installing
INSTALL_URL_ADDRESS='https://github.com/weaved/installer/raw/master/binaries/weaved-nixinstaller_1.2.13.bin'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
if (( $? == 0 )); then
#Install WEAVED
wget "$INSTALL_URL_ADDRESS" -O weaved_setup.bin
chmod +x weaved_setup.bin
##Dont run this, let the user run it for "1st time setup"
#./weaved_setup.bin
else
Error_NoConnection_NoInstall
WEAVED=0
fi
fi
#DietPi software that requires RPI GPIO
if (( $WEBIOPI == 1 )); then
RPIGPIO=1
fi
if (( $RPIGPIO == 1 )); then
INSTALL_DESCRIPTION='RPi.GPIO'
Banner_Installing
#Wheezy
if (( $DISTRO == 1 )); then
AGI python-rpi.gpio python3-rpi.gpio
#Jessie
elif (( $DISTRO == 3 )); then
# >= v111 image
if [ -f /etc/.dietpi_image_version ]; then
AGI python-rpi.gpio python3-rpi.gpio
# - < v111 Bug in older DietPi images with sources.list | Use pip, as offical repo = python3-rpi.gpio: Depends: python3 (< 3.3) but 3.4.2-2 is to be installed
else
AGI python3-pip
pip3 install RPi.GPIO
fi
fi
fi
#WIRINGPI
if (( $WIRINGPI == 1 )); then
INSTALL_DESCRIPTION='Wiring Pi'
Banner_Installing
#check source is online | https://git.drogon.net/?p=wiringPi;a=shortlog;h=refs/heads/master snapshot
INSTALL_URL_ADDRESS='https://git.drogon.net/?p=wiringPi;a=snapshot;h=b0a60c3302973ca1878d149d61f2f612c8f27fac;sf=tgz'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.tar
tar xfz package.tar
rm package.tar
cd wiringPi*
./build
cd ..
#rm -R /root/wiringPi* #Also Contains example code for users.
else
Error_NoConnection_NoInstall
#Abort Install
WIRINGPI=0
fi
fi
#RPII2C
if (( $RPII2C == 1 )); then
INSTALL_DESCRIPTION='RPi I2C'
Banner_Installing
/DietPi/dietpi/func/dietpi-rpi_i2c_control 1
fi
#WEBIOPI
if (( $WEBIOPI == 1 )); then
INSTALL_DESCRIPTION='WebIOPi (Control RPi.GPIO from web interface)'
Banner_Installing
INSTALL_URL_ADDRESS='http://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.1.tar.gz/download'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
if (( $? == 0 )); then
#Python dev, pre-reqs
AGI python-dev python-setuptools --no-install-recommends
#Install WEBIOPI
wget "$INSTALL_URL_ADDRESS" -O package.tar
tar xvzf package.tar
rm package.tar
cd WebIOPi*
#Automate Weaved prompt
sed -i '/read response/c\response="n"' setup.sh
#Run setup script
./setup.sh skip-apt
clear
cd ..
#Cleanup
rm -R WebIOPi*
else
Error_NoConnection_NoInstall
WEBIOPI=0
fi
fi
#DIETPICLOUDSHELL
if (( $DIETPICLOUDSHELL == 1 )); then
INSTALL_DESCRIPTION='DietPi-Cloudshell (System stats)'
Banner_Installing
AGI net-tools
##Cloudshell (Enable LCD screen)
## - Already set on DietPi Image.
#echo "options fbtft_device name=hktft9340 busnum=1 rotate=270" > /etc/modprobe.d/cloudshell.conf
#echo "fbtft_device" >> /etc/modules
fi
#HAPROXY
if (( $HAPROXY == 1 )); then
INSTALL_DESCRIPTION='HaProxy - High Performance TCP/HTTP Load Balancer'
Banner_Installing
#check source is online
INSTALL_URL_ADDRESS='http://www.haproxy.org/download/1.6/src/haproxy-1.6.2.tar.gz'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
#Download HAPROXY
wget "$INSTALL_URL_ADDRESS" -O package.tar
tar -xvf package.tar
rm package.tar
cd haproxy-*
#Pre-reqs
AGI libpcre3-dev libssl-dev
#Compile and install
make -j "$(nproc --all)" TARGET=linux2628 CPU=generic USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_LINUX_SPLICE=1
make install
mkdir /etc/haproxy
#Exit directory
cd ..
#Clean up
rm -R haproxy-*
#Install init script as service
cp /DietPi/dietpi/conf/haproxy_init /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy
update-rc.d haproxy defaults
else
Error_NoConnection_NoInstall
#Abort failed install
HAPROXY=0
fi
fi
#SQUEEZEBOXSERVER
if (( $SQUEEZEBOXSERVER == 1 )); then
INSTALL_DESCRIPTION='SqueezeBox (Logitech Media Server)'
Banner_Installing
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/logitechmediaserver_7.9.0_all.deb'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.deb
dpkg -i package.deb
rm package.deb
#Stop service
service logitechmediaserver stop
# + ARMv6 cpan
if (( $HW_MODEL <= 1 )); then
wget http://dietpi.com/downloads/binaries/all/logitechmediaserver_7.9.0_CPAN_5.20_armv6hf.tar.gz -O package.tar
tar xvzf package.tar -C /
rm package.tar
fi
else
Error_NoConnection_NoInstall
#Abort failed install
SQUEEZEBOXSERVER=0
fi
fi
#WORDPRESS
if (( $WORDPRESS == 1 )); then
INSTALL_DESCRIPTION='Wordpress'
Banner_Installing
#check source is online
INSTALL_URL_ADDRESS='https://wordpress.org/latest.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip -d /var/www/
rm package.zip
chown -R www-data:www-data /var/www/wordpress
chmod -R 775 /var/www/wordpress
else
Error_NoConnection_NoInstall
#Abort failed install
WORDPRESS=0
fi
fi
#TIGHTVNCSERVER
if (( $TIGHTVNCSERVER == 1 )); then
INSTALL_DESCRIPTION='VNC Server (Tight)'
Banner_Installing
AGI tightvncserver --no-install-recommends
fi
#FAIL2BAN
if (( $FAIL2BAN == 1 )); then
INSTALL_DESCRIPTION='Fail2Ban'
Banner_Installing
AGI fail2ban --no-install-recommends
fi
#PHPSYSINFO
if (( $PHPSYSINFO == 1 )); then
INSTALL_DESCRIPTION='PhpSysInfo (Stats)'
Banner_Installing
#check source is online
INSTALL_URL_ADDRESS='https://github.com/phpsysinfo/phpsysinfo/archive/master.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip -d /var/www/
rm package.zip
mv /var/www/phpsysinfo-* /var/www/phpsysinfo
else
Error_NoConnection_NoInstall
#Abort failed install
PHPSYSINFO=0
fi
fi
#PHPIMAGEGALLERY
if (( $PHPIMAGEGALLERY == 1 )); then
INSTALL_DESCRIPTION='Php Image Gallery'
Banner_Installing
#check source is online
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/Single_File_PHP_Gallery_4.6.1.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
AGI php5-gd
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip -d /var/www/gallery
rm package.zip
else
Error_NoConnection_NoInstall
#Abort failed install
PHPIMAGEGALLERY=0
fi
fi
#AMPACHE
if (( $AMPACHE == 1 )); then
INSTALL_DESCRIPTION='Ampache'
Banner_Installing
#check source is online
INSTALL_URL_ADDRESS='https://github.com/ampache/ampache/archive/master.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
AGI php5-curl
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip
rm package.zip
mv ampache-* /var/www/ampache
#composer install required for 3.8.2
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer
cd /var/www/ampache
composer install --prefer-source --no-interaction
cd ~/
else
Error_NoConnection_NoInstall
#Abort failed install
AMPACHE=0
fi
fi
#OPENVPNSERVER
if (( $OPENVPNSERVER == 1 )); then
INSTALL_DESCRIPTION='OpenVPN Server'
Banner_Installing
AGI openvpn easy-rsa iptables
fi
#LETSENCRYPT
if (( $LETSENCRYPT == 1 )); then
INSTALL_DESCRIPTION='Lets Encrypt (SSL cert)'
Banner_Installing
#check source is online
INSTALL_URL_ADDRESS='https://github.com/letsencrypt/letsencrypt/archive/master.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip -d /root
rm package.zip
mv letsencrypt* /etc/letsencrypt_scripts
#This is the only way to run the apt-get installs, without running the front end.
cd /etc/letsencrypt_scripts
./letsencrypt-auto --help
cd ~/
else
Error_NoConnection_NoInstall
#Abort failed install
LETSENCRYPT=0
fi
fi
#Software that requires WiFihotspot:
if (( $TORHOTSPOT == 1 )); then
WIFIHOTSPOT=1
fi
#WIFIHOTSPOT
if (( $WIFIHOTSPOT == 1 )); then
INSTALL_DESCRIPTION='Wifi Hotspot'
Banner_Installing
#check source is online
# - NB: These are hostapd binaries with RTL drivers enabled.
# - armv6
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/hostapd_14128.zip'
# - arm64
if (( $HW_MODEL == 12 )); then
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/hostapd_2.5-arm64.zip'
fi
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
# - Prereqs
AGI hostapd isc-dhcp-server iptables
# - For all devices, excluding RPi 3 inbuilt wifi, Install modified hostapd binary with RTL drivers enabled.
if (( $HW_MODEL != 3 )); then
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip -o package.zip -d /usr/sbin
rm package.zip
chmod +x /usr/sbin/hostapd
fi
else
Error_NoConnection_NoInstall
#Abort failed install
WIFIHOTSPOT=0
fi
fi
#TORHOTSPOT
if (( $TORHOTSPOT == 1 )); then
INSTALL_DESCRIPTION='Tor Hotspot'
Banner_Installing
# - Prereqs
AGI tor
fi
#SHAIRPORTSYNC
if (( $SHAIRPORTSYNC == 1 )); then
INSTALL_DESCRIPTION='Shairport Sync'
Banner_Installing
#check source is online
# - ARMv6
if (( $HW_MODEL <= 1 )); then
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/shairport-sync-dietpi_armv6.deb'
# - ARMv7
else
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/shairport-sync-dietpi_armv7.deb'
fi
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
# - Prereqs
AGI openssl avahi-daemon libsoxr0 libavahi-client3 libtool libconfig9 libpopt0 libdaemon0 --no-install-recommends
wget "$INSTALL_URL_ADDRESS" -O package.deb
dpkg -i package.deb
rm package.deb
else
Error_NoConnection_NoInstall
#Abort failed install
SHAIRPORTSYNC=0
fi
fi
#BRUTEFIR
if (( $BRUTEFIR == 1 )); then
INSTALL_DESCRIPTION='BruteFIR / ALSA Loopback'
Banner_Installing
#check folder is online
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/conf/BruteFIR/'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
# - Prereqs
AGI brutefir
wget -r -nH --cut-dirs=2 --no-parent --reject="index.htm*" -e robots=off "$INSTALL_URL_ADDRESS"
mv BruteFIR /etc/
else
Error_NoConnection_NoInstall
#Abort failed install
BRUTEFIR=0
fi
fi
#PYDIO
if (( $PYDIO == 1 )); then
INSTALL_DESCRIPTION='Pydio'
Banner_Installing
#check folder is online
INSTALL_URL_ADDRESS='http://sourceforge.net/projects/ajaxplorer/files/pydio/stable-channel/6.2.2/pydio-core-6.2.2.zip/download'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
# - Prereqs
AGI php5-mcrypt php5-gd
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip -d /var/www
mv /var/www/pydio-core-* /var/www/pydio
rm package.zip
else
Error_NoConnection_NoInstall
#Abort failed install
PYDIO=0
fi
fi
#SQUEEZELITE
if (( $SQUEEZELITE == 1 )); then
INSTALL_DESCRIPTION='SqueezeLite'
Banner_Installing
# - Prereqs
AGI squeezelite
fi
#EMONCMS
if (( $EMONCMS == 1 )); then
INSTALL_DESCRIPTION='EmonCMS'
Banner_Installing
#check folder is online
INSTALL_URL_ADDRESS='https://github.com/emoncms/emoncms/archive/stable.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
# - Prereqs
AGI php5-curl php-pear php5-dev php5-mcrypt ufw
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip -d /var/www
rm package.zip
mv /var/www/emoncms* /var/www/emoncms
else
Error_NoConnection_NoInstall
#Abort failed install
EMONCMS=0
fi
fi
#EMONHUB
if (( $EMONHUB == 1 )); then
INSTALL_DESCRIPTION='EmonPi / EmonHub'
Banner_Installing
#check, is online
INSTALL_URL_ADDRESS='https://github.com/Fourdee/emonhub/archive/emon-pi.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
# - Prereqs
AGI minicom python-pip python-serial python-configobj --no-install-recommends
pip install paho-mqtt pydispatcher
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip
rm package.zip
# - move everything to /etc/emonhub
rm -R /etc/emonhub
mkdir -p /etc/emonhub
mv emonhub-*/* /etc/emonhub/
rm -R emonhub-*
else
Error_NoConnection_NoInstall
#Abort failed install
EMONHUB=0
fi
fi
#RPIMONITOR
if (( $RPIMONITOR == 1 )); then
INSTALL_DESCRIPTION='Rpi-Monitor'
Banner_Installing
#check, is online
INSTALL_URL_ADDRESS='https://github.com/XavierBerger/RPi-Monitor-deb/raw/master/packages/rpimonitor_2.10-1_all.deb'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.deb
dpkg -i package.deb
rm package.deb
# - Prereqs
apt-get -f -y install
else
Error_NoConnection_NoInstall
#Abort failed install
RPIMONITOR=0
fi
fi
#NETDATA
if (( $NETDATA == 1 )); then
INSTALL_DESCRIPTION='netdata'
Banner_Installing
#Rpi 1
if (( $HW_MODEL < 2 )); then
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/netdata_1.0.0_armv6.tgz'
#ARM64
elif (( $HW_MODEL == 12 )); then
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/netdata_1.0.0_arm64.tgz'
#all others
else
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/netdata_1.0.0_armv7.tgz'
fi
#check, is online
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
AGI --no-install-recommends zlib1g-dev
wget "$INSTALL_URL_ADDRESS" -O package.tgz
tar -xzvf package.tgz -C /
rm package.tgz
else
Error_NoConnection_NoInstall
#Abort failed install
NETDATA=0
fi
fi
#BAIKAL
if (( $BAIKAL == 1 )); then
INSTALL_DESCRIPTION='BaiKal'
Banner_Installing
#check folder is online
INSTALL_URL_ADDRESS='https://github.com/fruux/Baikal/archive/master.zip'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip package.zip -d /var/www
rm package.zip
mv /var/www/Baikal* /var/www/baikal
else
Error_NoConnection_NoInstall
#Abort failed install
BAIKAL=0
fi
fi
#MUMBLESERVER
if (( $MUMBLESERVER == 1 )); then
INSTALL_DESCRIPTION='Murmur - Mumble VoIP Server'
Banner_Installing
AGI mumble-server
fi
}
Install_Linux_Software(){
# Stop Services
/DietPi/dietpi/dietpi-services stop
if (( $VIMFULL == 1 )); then
INSTALL_DESCRIPTION='Vim'
Banner_Installing
AGI vim
VIMFULL=2
fi
if (( $SSHCLIENT == 1 )); then
INSTALL_DESCRIPTION='OpenSSH Client'
Banner_Installing
AGI openssh-client
SSHCLIENT=2
fi
if (( $SMBCLIENT == 1 )); then
INSTALL_DESCRIPTION='Samba Client'
Banner_Installing
#Remove Information file
rm /mnt/samba/readme.txt &> /dev/null
AGI smbclient cifs-utils --no-install-recommends
SMBCLIENT=2
fi
#DietPi software that requires Build-Essential
if (( $HAPROXY == 1 )); then
BUILDESSENTIAL=1
elif (( $WIRINGPI == 1 )); then
BUILDESSENTIAL=1
elif (( $OPENBAZAAR == 1 )); then
BUILDESSENTIAL=1
fi
if (( $BUILDESSENTIAL == 1 )); then
INSTALL_DESCRIPTION='Build Essential'
Banner_Installing
AGI build-essential --no-install-recommends
BUILDESSENTIAL=2
fi
#DietPi software that requires GITCLIENT
if (( $EMONCMS == 1 )); then
GITCLIENT=1
elif (( $AMPACHE == 1 )); then
GITCLIENT=1
elif (( $OPENBAZAAR == 1 )); then
GITCLIENT=1
fi
if (( $GITCLIENT == 1 )); then
INSTALL_DESCRIPTION='Git'
Banner_Installing
AGI git --no-install-recommends
GITCLIENT=2
fi
#DietPi software that requires Alsa-base
if (( $DESKTOP_LXDE == 1 )); then
ALSABASE=1
elif (( $HIFI == 1 )); then
ALSABASE=1
elif (( $KODI == 1 )); then
ALSABASE=1
elif (( $MINIDLNA == 1 )); then
ALSABASE=1
elif (( $OPENTYRIAN == 1 )); then
ALSABASE=1
elif (( $SUBSONIC == 1 )); then
ALSABASE=1
elif (( $TIGHTVNCSERVER == 1 )); then
ALSABASE=1
elif (( $SQUEEZEBOXSERVER == 1 )); then
ALSABASE=1
elif (( $AMPACHE == 1 )); then
ALSABASE=1
elif (( $SHAIRPORTSYNC == 1 )); then
ALSABASE=1
elif (( $BRUTEFIR == 1 )); then
ALSABASE=1
elif (( $SQUEEZELITE == 1 )); then
ALSABASE=1
fi
if (( $ALSABASE == 1 )); then
INSTALL_DESCRIPTION='ALSA (Linux Sound System)'
Banner_Installing
AGI alsa-base alsa-utils
#RPI
if (( $HW_MODEL < 10 )); then
#enable snd-bcm2835 if no other soundcard is configured.
if (( $(cat /DietPi/config.txt | grep -ci -m1 '#dtoverlay') == 1 )); then
/DietPi/dietpi/func/dietpi-set_soundcard rpi-bcm2835
fi
#C2 - asound.conf by oversun
elif (( $HW_MODEL == 12 )); then
cat << _EOF_ > /etc/asound.conf
pcm.!default {
type plug
slave {
pcm "hw:0,0"
format S32_LE
}
}
_EOF_
#OrangePi PC (HDMI)
elif (( $HW_MODEL == 30 )); then
cat << _EOF_ > /etc/asound.conf
pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}
_EOF_
fi
ALSABASE=2
fi
#DietPi software that requires Xserver - Xorg
if (( $DESKTOP_LXDE == 1 )); then
XSERVERXORG=1
elif (( $KODI == 1 )); then
XSERVERXORG=1
elif (( $OPENTYRIAN == 1 )); then
XSERVERXORG=1
elif (( $TIGHTVNCSERVER == 1 )); then
XSERVERXORG=1
fi
if (( $XSERVERXORG == 1 )); then
XSERVERXORG=2
#Xserver Prereqs (ALL)
INSTALL_DESCRIPTION='Xserver (Xinit / Xauth)'
Banner_Installing
AGI xinit xauth xserver-xorg dbus-x11 xfonts-base x11-xserver-utils x11-common x11-utils --no-install-recommends
#RPI
if (( $HW_MODEL < 10 )); then
INSTALL_DESCRIPTION='Xserver (FBTurbo)'
Banner_Installing
#Wheezy
if (( $DISTRO == 1 )); then
AGI xserver-xorg-video-fbturbo xserver-xorg-video-fbdev --no-install-recommends
#Jessie
elif (( $DISTRO == 3 )); then
sleep 1
# - Install OpenGL driver?
#AGI xcompmgr libgl1-mesa-dri raspi-gpio mesa-utils
# - Requires 256mb GPU?
# - status: still software driver being used on rpi 3.
fi
#Odroid C2
elif (( $HW_MODEL == 12 )); then
INSTALL_DESCRIPTION='Xserver (AMLogic VPU / Mali GPU)'
Banner_Installing
AGI xcompmgr xterm aml-libs-odroid mali450-odroid --no-install-recommends
# xcompmgr is fix for broken transparency with lxdesession and improve performance
#No xorg needed
#Odroid XU4
elif (( $HW_MODEL == 11 )); then
INSTALL_DESCRIPTION='Xserver (Exynos 5422)'
Banner_Installing
AGI xterm firmware-samsung xf86-video-armsoc-odroid malit628-odroid --no-install-recommends
cp /DietPi/dietpi/conf/xorg_xu4.conf /etc/X11/xorg.conf
#Odroid C1
elif (( $HW_MODEL == 10 )); then
INSTALL_DESCRIPTION='Xserver (AMLogic VPU / Mali GPU)'
Banner_Installing
AGI xcompmgr xterm aml-libs-odroid xf86-video-mali-odroid libump-odroid mali450-odroid --no-install-recommends
# xcompmgr is fix for broken transparency with lxdesession and improve performance
cp /DietPi/dietpi/conf/xorg_c1.conf /etc/X11/xorg.conf
fi
fi
if (( $CURLFTPFS == 1 )); then
INSTALL_DESCRIPTION='CurlFtpFs (FTP client as filesystem mount)'
Banner_Installing
#Remove information file
rm /mnt/ftp_client/readme.txt &> /dev/null
AGI curlftpfs
CURLFTPFS=2
fi
#Install Choice based SSH Server
if (( $SSHSERVER_DROPBEAR == 1 )); then
INSTALL_DESCRIPTION='Dropbear SSH Server'
Banner_Installing
AGI dropbear
#set to start on next boot
sed -i '/NO_START=1/c\NO_START=0' /etc/default/dropbear
SSHSERVER_DROPBEAR=2
fi
if (( $SSHSERVER_OPENSSH == 1 )); then
INSTALL_DESCRIPTION='OpenSSH Server'
Banner_Installing
AGI openssh-server --no-install-recommends
#Jessie, must enable root login
if (( $DISTRO == 3 )); then
sed -i '/PermitRootLogin/c\PermitRootLogin yes' /etc/ssh/sshd_config
#Restart ssh server now so root users can login during setup.
systemctl restart ssh
fi
SSHSERVER_OPENSSH=2
#SSH server package also installs client.
SSHCLIENT=2
fi
#Install Choices Logging
if (( $LOGGING_RAMLOG == 1 )); then
INSTALL_DESCRIPTION='DietPi-Ramlog'
Banner_Installing
#Install (add tmpfs mount to fstab)
sed -i '/\/var\/log/c\tmpfs \/var\/log tmpfs defaults,size=20m,noatime,nodev,nosuid,mode=1777 0 0' /etc/fstab
LOGGING_RAMLOG=2
fi
if (( $LOGGING_LOGROTATE == 1 )); then
INSTALL_DESCRIPTION='Logrotate'
Banner_Installing
AGI logrotate --no-install-recommends
LOGGING_LOGROTATE=2
fi
#Software that requires rsyslog
if (( $FAIL2BAN == 1 )); then
LOGGING_RSYSLOG=1
elif (( $OPENVPNSERVER == 1 )); then
LOGGING_RSYSLOG=1
fi
if (( $LOGGING_RSYSLOG == 1 )); then
INSTALL_DESCRIPTION='Rsyslog'
Banner_Installing
AGI rsyslog --no-install-recommends
LOGGING_RSYSLOG=2
fi
#Software that requires ffmpeg
if (( $SUBSONIC == 1 )); then
FFMPEG=1
elif (( $AMPACHE == 1 )); then
FFMPEG=1
fi
if (( $FFMPEG == 1 )); then
INSTALL_DESCRIPTION='FFmpeg'
Banner_Installing
if (( $DISTRO == 1 )); then
AGI ffmpeg
elif (( $DISTRO == 3 )); then
#RPi v1 armv6, broken packages in multimedia repo. https://github.com/Fourdee/DietPi/issues/84#issuecomment-151201361
if (( $HW_MODEL < 2 )); then
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/ffmpeg_2.7.2-1_armhf-v6.deb'
wget "$INSTALL_URL_ADDRESS" -O package.deb
dpkg -i package.deb
rm package.deb
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/fdk-aac_0.1.4_armhf-v6.deb'
wget "$INSTALL_URL_ADDRESS" -O package.deb
dpkg -i package.deb
rm package.deb
#Install pre-reqs
AGI libogg0 libvorbisenc2 libtheora0 libspeex1 libopencore-amrwb0 libopencore-amrnb0 libass5
#rpi 2/3
elif (( $HW_MODEL == 2 )) || (( $HW_MODEL == 3 )); then
#Add Deb Multimedia repo for ffmpeg
if [ ! -f /etc/apt/sources.list.d/debmultimedia.list ]; then
echo -e "deb http://www.deb-multimedia.org jessie main non-free" > /etc/apt/sources.list.d/debmultimedia.list
apt-get update
AGI deb-multimedia-keyring --force-yes
apt-get update
AGI ffmpeg
#Done. Remove deb http://www.deb-multimedia.org from apt sources
# - When installing Kodi, apt uses the packages from deb http://www.deb-multimedia.org, rather than Raspbian.
rm /etc/apt/sources.list.d/debmultimedia.list
/DietPi/dietpi/dietpi-apt-get_update 2
fi
#Jessie (now available from backports).
else
AGI ffmpeg
fi
fi
FFMPEG=2
fi
#ORACLEJAVA
# - Software that requires JRE/JDK
if (( $SUBSONIC == 1 )); then
ORACLEJAVA=1
fi
if (( $ORACLEJAVA == 1 )); then
INSTALL_DESCRIPTION='Oracle Java 8 jdk'
Banner_Installing
# - Raspbian
if (( $HW_MODEL < 10 )); then
AGI oracle-java8-jdk
# - Debian. Add repo
else
cat << _EOF_ > /etc/apt/sources.list.d/webupd8team-java.list
deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
_EOF_
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
# - Accept the license: https://github.com/Fourdee/DietPi/issues/298
debconf-set-selections <<< "oracle-java8-installer shared/accepted-oracle-license-v1-1 boolean true"
AGI oracle-java8-installer
fi
ORACLEJAVA=2
fi
#Programs that require NODEJS
if (( $NETDATA == 1 )); then
NODEJS=1
fi
#NODEJS
if (( $NODEJS == 1 )); then
INSTALL_DESCRIPTION='NodeJS - Javascript Runtime'
Banner_Installing
#ARM64 (Odroid C2) - Not currently available via nodesource.com
if (( $HW_MODEL == 12 )); then
#check, is online
INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/c2/nodejs_5-1_arm64.deb'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
# - Preqs
wget "$INSTALL_URL_ADDRESS" -O package.deb
dpkg -i package.deb
rm package.deb
NODEJS=2
else
Error_NoConnection_NoInstall
#Abort failed install
NODEJS=0
fi
#Everything else
else
#check, is online
INSTALL_URL_ADDRESS='https://deb.nodesource.com/setup_5.x'
/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS"
#Install
if (( $? == 0 )); then
# - Preqs
AGI apt-transport-https
# - Add repo (use their install script)
curl -sL "$INSTALL_URL_ADDRESS" | -E bash -
# - install
AGI nodejs
NODEJS=2
else
Error_NoConnection_NoInstall
#Abort failed install
NODEJS=0
fi
fi
fi
}
Uninstall_NonSelected_Choices(){
#Uninstall software using our temp uninstall file script
if [ -f "$UNINSTALL_FILE" ]; then
#Write .Install File
Write_InstallFileList
#Run the temp uninstall script
while read -r line
do
/DietPi/dietpi/dietpi-uninstall "$line"
done < $UNINSTALL_FILE
rm $UNINSTALL_FILE
#Reload installed file (dietpi-uninstall sets flags back to 0)
Read_InstallFileList
fi
}
Apply_SSHServer_Choices(){
#Work out which SSH Server needs installing from Indexs (if any)
#Work out which SSH server needs removing (if any), and, create a temp script file
if (( $INDEX_SSHSERVER_TARGET != $INDEX_SSHSERVER_CURRENT )); then
#No SSH server
if (( $INDEX_SSHSERVER_TARGET == 0 )); then
echo -e "SSHSERVER_DROPBEAR" >> "$UNINSTALL_FILE"
echo -e "SSHSERVER_OPENSSH" >> "$UNINSTALL_FILE"
#Dropbear
elif (( $INDEX_SSHSERVER_TARGET == -1 )); then
SSHSERVER_DROPBEAR=1
echo -e "SSHSERVER_OPENSSH" >> "$UNINSTALL_FILE"
#Openssh
elif (( $INDEX_SSHSERVER_TARGET == -2 )); then
SSHSERVER_OPENSSH=1
echo -e "SSHSERVER_DROPBEAR" >> "$UNINSTALL_FILE"
fi
#Inform user (From testing, stopping SSH server services does not disconnect user, however, just incase it does in the future)
/DietPi/dietpi/dietpi-banner 0
echo -e "\n Stopping SSH Servers, please wait.....\n\n - If you are connected via SSH, you may be disconnected.\n - Your system will reboot once your DietPi-Software installation is completed.\n - Go make a coffee :) \n"
#stop all SSH server services
service ssh stop &> /dev/null
service dropbear stop &> /dev/null
#Update Current SSHSERVER index
INDEX_SSHSERVER_CURRENT=$INDEX_SSHSERVER_TARGET
fi
}
Apply_FileServer_Choices(){
#Work out which File Server needs installing from Indexs (if any)
#Work out which File server needs removing (if any), and, create a temp script file
if (( $INDEX_FILESERVER_TARGET != $INDEX_FILESERVER_CURRENT )); then
#No File server
if (( $INDEX_FILESERVER_TARGET == 0 )); then
echo -e "FILESERVER_SAMBA" >> "$UNINSTALL_FILE"
echo -e "FILESERVER_PROFTP" >> "$UNINSTALL_FILE"
#echo -e "FILESERVER_VSFTPD" >> "$UNINSTALL_FILE"
#ProFTP
elif (( $INDEX_FILESERVER_TARGET == -1 )); then
FILESERVER_PROFTP=1
echo -e "FILESERVER_SAMBA" >> "$UNINSTALL_FILE"
#Samba
elif (( $INDEX_FILESERVER_TARGET == -2 )); then
FILESERVER_SAMBA=1
echo -e "FILESERVER_PROFTP" >> "$UNINSTALL_FILE"
fi
#Update Current SSHSERVER index
INDEX_FILESERVER_CURRENT=$INDEX_FILESERVER_TARGET
fi
}
Apply_Logging_Choices(){
#Work out which Logging system needs installing from Indexs (if any)
#Work out which Logging system needs removing (if any), and, create a temp script file
if (( $INDEX_LOGGING_TARGET != $INDEX_LOGGING_CURRENT )); then
#None
if (( $INDEX_LOGGING_TARGET == 0 )); then
echo -e "LOGGING_LOGROTATE" >> "$UNINSTALL_FILE"
echo -e "LOGGING_RAMLOG" >> "$UNINSTALL_FILE"
echo -e "LOGGING_RSYSLOG" >> "$UNINSTALL_FILE"
#Ramlog - clear every 24H
elif (( $INDEX_LOGGING_TARGET == -1 )); then
LOGGING_RAMLOG=1
echo -e "LOGGING_LOGROTATE" >> "$UNINSTALL_FILE"
echo -e "LOGGING_RSYSLOG" >> "$UNINSTALL_FILE"
#Ramlog - backup every 1H to $HOME/logfile_storage, then clear.
elif (( $INDEX_LOGGING_TARGET == -2 )); then
LOGGING_RAMLOG=1
echo -e "LOGGING_LOGROTATE" >> "$UNINSTALL_FILE"
echo -e "LOGGING_RSYSLOG" >> "$UNINSTALL_FILE"
#Logrotate + rsyslog - logs to disk
elif (( $INDEX_LOGGING_TARGET == -3 )); then
LOGGING_LOGROTATE=1
LOGGING_RSYSLOG=1
echo -e "LOGGING_RAMLOG" >> "$UNINSTALL_FILE"
fi
#Requires Rsyslog. Override and remove from uninstall file.
if (( $FAIL2BAN > 0 )) ||
(( $OPENVPNSERVER > 0 )); then
sed -i '/LOGGING_RSYSLOG/d' "$UNINSTALL_FILE"
fi
#Update Current Logging index
INDEX_LOGGING_CURRENT=$INDEX_LOGGING_TARGET
fi
}
Apply_Webserver_Preference(){
if (( $INDEX_WEBSERVER_TARGET != $INDEX_WEBSERVER_CURRENT )); then
#Update Current to Target
INDEX_WEBSERVER_CURRENT=$INDEX_WEBSERVER_TARGET
fi
}
Install_Apply_Configs(){
# Stop Services
/DietPi/dietpi/dietpi-services stop
# Copy/Set optimised Software settings.
# Set install states to 2 (installed).
#Destop
if (( $DESKTOP_LXDE == 1 )); then
#Odroid C1/C2 - Fix for broken/laggy transparency
# - xcompmgr -a seems faster, but causes display corruption vertically on right side of screen
if (( $HW_MODEL == 10 )) || (( $HW_MODEL == 12 )); then
cat << _EOF_ > /etc/xdg/lxsession/LXDE/autostart
xcompmgr -n
@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash
_EOF_
fi
#Remove Lxrandr Menu item (monitor configuration tool as we set res in dietpi-config)
rm /usr/share/applications/lxrandr.desktop &> /dev/null
#Copy PCmanFM configs
mkdir -p "$HOME"/.config/pcmanfm/LXDE
cp /DietPi/dietpi/conf/desktop/pcmanfm.conf "$HOME"/.config/pcmanfm/LXDE/pcmanfm.conf
cp /DietPi/dietpi/conf/desktop/pcmanfm-desktopitems.conf "$HOME"/.config/pcmanfm/LXDE/desktop-items-0.conf
#Disable Trash
sed -i '/use_trash=/c\use_trash=0' /etc/xdg/libfm/libfm.conf
#Copy DietPi pcmanfm favourite links
cp /DietPi/dietpi/conf/desktop/.gtk-bookmarks "$HOME"/.gtk-bookmarks
#Copy DietPi Panel config
mkdir -p "$HOME"/.config/lxpanel/LXDE/panels
cp /DietPi/dietpi/conf/desktop/panel "$HOME"/.config/lxpanel/LXDE/panels/panel
#Openbox config
mkdir -p "$HOME"/.config/openbox
cp /DietPi/dietpi/conf/desktop/lxde-rc.xml "$HOME"/.config/openbox/lxde-rc.xml
#Create Desktop SymLinks
mkdir -p "$HOME"/Desktop
ln -sf /usr/share/applications/pcmanfm.desktop "$HOME"/Desktop/pcmanfm.desktop
ln -sf /usr/share/applications/htop.desktop "$HOME"/Desktop/htop.desktop
#DietPi Desktop symlinks
ln -sf /DietPi/dietpi/conf/desktop/dietpi-software.desktop "$HOME"/Desktop/dietpi-software.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-config.desktop "$HOME"/Desktop/dietpi-config.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-launcher.desktop "$HOME"/Desktop/dietpi-launcher.desktop
#DietPi Menu symlinks
ln -sf /DietPi/dietpi/conf/desktop/dietpi-software.desktop /usr/share/applications/dietpi-software.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-update.desktop /usr/share/applications/dietpi-update.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-config.desktop /usr/share/applications/dietpi-config.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-uninstall.desktop /usr/share/applications/dietpi-uninstall.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-backup.desktop /usr/share/applications/dietpi-backup.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-sync.desktop /usr/share/applications/dietpi-sync.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-bugreport.desktop /usr/share/applications/dietpi-bugreport.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-process_tool.desktop /usr/share/applications/dietpi-process_tool.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-cleaner.desktop /usr/share/applications/dietpi-cleaner.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-cron.desktop /usr/share/applications/dietpi-cron.desktop
ln -sf /DietPi/dietpi/conf/desktop/dietpi-launcher.desktop /usr/share/applications/dietpi-launcher.desktop
DESKTOP_LXDE=2
fi
#WEBSERVER_LAMP
if (( $WEBSERVER_LAMP == 1 )); then
WEBSERVER_LAMP=2
fi
#WEBSERVER_LASP
if (( $WEBSERVER_LASP == 1 )); then
WEBSERVER_LASP=2
fi
#WEBSERVER_LAAP
if (( $WEBSERVER_LAAP == 1 )); then
WEBSERVER_LAAP=2
fi
#WEBSERVER_LEMP
if (( $WEBSERVER_LEMP == 1 )); then
WEBSERVER_LEMP=2
fi
#WEBSERVER_LESP
if (( $WEBSERVER_LESP == 1 )); then
WEBSERVER_LESP=2
fi
#WEBSERVER_LEAP
if (( $WEBSERVER_LEAP == 1 )); then
WEBSERVER_LEAP=2
fi
#WEBSERVER_LLMP
if (( $WEBSERVER_LLMP == 1 )); then
WEBSERVER_LLMP=2
fi
#WEBSERVER_LLSP
if (( $WEBSERVER_LLSP == 1 )); then
WEBSERVER_LLSP=2
fi
#WEBSERVER_LLAP
if (( $WEBSERVER_LLAP == 1 )); then
WEBSERVER_LLAP=2
fi
#WEBSERVER_APACHE
if (( $WEBSERVER_APACHE == 1 )); then
#create www directory
mkdir -p /var/www
#Jessie
if (( $DISTRO == 3 )); then
#Apache2 confs
cp /DietPi/dietpi/conf/apache2_jessie.conf /etc/apache2/apache2.conf
cat << _EOF_ > /etc/apache2/sites-available/000-default.conf
ServerAdmin webmaster@localhost
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
_EOF_
cat << _EOF_ > /etc/apache2/mods-available/mpm_event.conf
StartServers $CPU_CORES_TOTAL
MinSpareThreads 1
MaxSpareThreads 8
ThreadLimit 16
ThreadsPerChild 4
MaxRequestWorkers 50
MaxConnectionsPerChild 0
_EOF_
cat << _EOF_ > /etc/apache2/mods-available/mpm_prefork.conf
StartServers $CPU_CORES_TOTAL
MinSpareServers 1
MaxSpareServers $CPU_CORES_TOTAL
MaxRequestWorkers 50
MaxConnectionsPerChild 0
_EOF_
cat << _EOF_ > /etc/apache2/mods-available/mpm_worker.conf
StartServers $CPU_CORES_TOTAL
MinSpareThreads 1
MaxSpareThreads 8
ThreadLimit 16
ThreadsPerChild 4
MaxRequestWorkers 50
MaxConnectionsPerChild 0
_EOF_
#Use /var/www as default webfolder
mv /var/www/html/index.html /var/www/index.html &> /dev/null
rm -R /var/www/html &> /dev/null
#Wheezy
elif (( $DISTRO == 1 )); then
#Rpi apache2 confs
cp /DietPi/dietpi/conf/apache2_wheezy.conf /etc/apache2/apache2.conf
sed -i "/StartServers /c\StartServers $CPU_CORES_TOTAL" /etc/apache2/apache2.conf
sed -i "/MinSpareServers /c\MinSpareServers 1" /etc/apache2/apache2.conf
sed -i "/MaxSpareServers /c\MaxSpareServers $CPU_CORES_TOTAL" /etc/apache2/apache2.conf
sed -i "/MinSpareThreads /c\MinSpareThreads 1" /etc/apache2/apache2.conf
sed -i "/MaxSpareThreads /c\MaxSpareThreads 8" /etc/apache2/apache2.conf
sed -i "/MaxClients /c\MaxClients 50" /etc/apache2/apache2.conf
sed -i "/MaxRequestsPerChild /c\MaxRequestsPerChild 0" /etc/apache2/apache2.conf
sed -i "/ThreadLimit /c\ThreadLimit 16" /etc/apache2/apache2.conf
sed -i "/ThreadsPerChild /c\ThreadsPerChild 8" /etc/apache2/apache2.conf
sed -i "/MaxKeepAliveRequests /c\MaxKeepAliveRequests 10" /etc/apache2/apache2.conf
fi
#Sites-Available settings. Disable access log, set error log level
sed -i "/CustomLog /c\ #CustomLog "'${APACHE_LOG_DIR}'"/access.log combined" /etc/apache2/sites-available/*
sed -i "/LogLevel /c\ LogLevel error" /etc/apache2/sites-available/*
#Apply permissions
chown -R www-data:www-data /var/www
WEBSERVER_APACHE=2
fi
#WEBSERVER_NGINX
if (( $WEBSERVER_NGINX == 1 )); then
#create www directory
mkdir -p /var/www
#Nginx confs
mkdir /etc/nginx/sites-dietpi
cp /DietPi/dietpi/conf/nginx.conf /etc/nginx/nginx.conf
cp /DietPi/dietpi/conf/nginx.site-available-default /etc/nginx/sites-available/default
#Nginx index page
if (( $DISTRO == 1 )); then
cp /usr/share/nginx/www/index.html /var/www/index.html
elif (( $DISTRO == 3 )); then
cp /usr/share/nginx/html/index.html /var/www/index.html
fi
#CPU core count
sed -i "/worker_processes/c\worker_processes $CPU_CORES_TOTAL;" /etc/nginx/nginx.conf
#Apply permissions
chown -R www-data:www-data /var/www
WEBSERVER_NGINX=2
fi
#WEBSERVER_LIGHTTPD
if (( $WEBSERVER_LIGHTTPD == 1 )); then
#create www directory
mkdir -p /var/www
#www path
sed -i '/^server.document-root/c\server.document-root = "/var/www"' /etc/lighttpd/lighttpd.conf
#Configure fastcgi for PHP-FPM
cat << _EOF_ > /etc/lighttpd/conf-available/15-fastcgi-php.conf
# -*- depends: fastcgi -*-
# /usr/share/doc/lighttpd/fastcgi.txt.gz
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi
## Start an FastCGI server using php-fpm
fastcgi.server += ( ".php" =>
((
"socket" => "/var/run/php5-fpm.sock",
"broken-scriptfilename" => "enable"
))
)
_EOF_
#enable cgi/php
lighttpd-enable-mod fastcgi
lighttpd-enable-mod fastcgi-php
#Move default page
mv /var/www/html/index.lighttpd.html /var/www/
#Apply permissions
chown -R www-data:www-data /var/www
service lighttpd force-reload
WEBSERVER_LIGHTTPD=2
fi
#NB: Webserver_name now = 2
#WEBSERVER_MYSQL
if (( $WEBSERVER_MYSQL == 1 )); then
WEBSERVER_MYSQL=2
fi
#WEBSERVER_MARIADB
if (( $WEBSERVER_MARIADB == 1 )); then
WEBSERVER_MARIADB=2
fi
#WEBSERVER_SQLITE
if (( $WEBSERVER_SQLITE == 1 )); then
WEBSERVER_SQLITE=2
fi
#WEBSERVER_PHP
if (( $WEBSERVER_PHP == 1 )); then
#PHP-FPM
# - Apache2 has uses its own PHP module
if (( $WEBSERVER_APACHE == 2 )); then
echo -e "nothing here" &> /dev/null
# - All other webservers (eg: Nginx/Lighttpd) use PHP-FPM
else
# - Php-FPM confs
cp /DietPi/dietpi/conf/php-fpm.conf /etc/php5/fpm/php-fpm.conf
cp /DietPi/dietpi/conf/php-fpm_pool.conf /etc/php5/fpm/pool.d/www.conf
sed -i '/cgi.fix_pathinfo=/c\cgi.fix_pathinfo=1' /etc/php5/fpm/php.ini
# - PHP5-fpm optimizations based on total cores
sed -i "/pm.max_children = /c\pm.max_children = $CPU_CORES_TOTAL" /etc/php5/fpm/pool.d/www.conf
sed -i "/pm.start_servers = /c\pm.start_servers = $CPU_CORES_TOTAL" /etc/php5/fpm/pool.d/www.conf
sed -i "/pm.min_spare_servers = /c\pm.min_spare_servers = $CPU_CORES_TOTAL" /etc/php5/fpm/pool.d/www.conf
sed -i "/pm.max_spare_servers = /c\pm.max_spare_servers = $CPU_CORES_TOTAL" /etc/php5/fpm/pool.d/www.conf
fi
#php APC/u settings
local target_php_ini=0
local target_php_cachesize=$(( $(free -m -o | grep -m1 'Mem:' | awk '{print $2}') / 30 ))
if (( $target_php_cachesize < 10 )); then
target_php_cachesize=10
fi
# - 3days TTL
local target_apc_ttl='259200'
#Wheezy APC
if (( $DISTRO == 1 )); then
# - apc ini locations
if (( $WEBSERVER_APACHE == 2 )); then
target_php_ini='/etc/php5/apache2/conf.d/20-apc.ini'
elif (( $WEBSERVER_NGINX == 2 )); then
target_php_ini='/etc/php5/fpm/conf.d/20-apc.ini'
fi
echo -e "extension=apc.so" > "$target_php_ini"
echo -e "apc.enabled=1" >> "$target_php_ini"
echo -e "apc.shm_size=$target_php_cachesize" >> "$target_php_ini"
echo -e "apc.ttl=$target_apc_ttl" >> "$target_php_ini"
cp /usr/share/doc/php-apc/apc.php /var/www/apc.php
#Jessie. Opcache + APCu
else
#PHP OPcache
php5enmod opcache
if (( $WEBSERVER_APACHE == 2 )); then
target_php_ini='/etc/php5/apache2/php.ini'
else
target_php_ini='/etc/php5/fpm/php.ini'
fi
sed -i "/opcache.enable=/c\opcache.enable=1" $target_php_ini
sed -i "/opcache.memory_consumption=/c\opcache.memory_consumption=$target_php_cachesize" $target_php_ini
sed -i "/opcache.revalidate_freq=/c\opcache.revalidate_freq=60" $target_php_ini
wget https://raw.githubusercontent.com/rlerdorf/opcache-status/master/opcache.php -O /var/www/opcache.php
#APCu
php5enmod apcu
# - apc.shm_size= requires M at end to prevent warning: https://github.com/Fourdee/DietPi/issues/218
target_php_cachesize+="M"
target_php_ini='/etc/php5/mods-available/apcu.ini'
cat << _EOF_ > "$target_php_ini"
extension=apcu.so
apc.shm_size=$target_php_cachesize
apc.ttl=$target_apc_ttl
_EOF_
cp /usr/share/doc/php5-apcu/apc.php /var/www/apc.php
fi
#Apply permissions
chown -R www-data:www-data /var/www/apc.php
chown -R www-data:www-data /var/www/opcache.php
#Set all PHP.INI's to UTF-8
sed -i '/default_charset/c\default_charset = "UTF-8"' /etc/php5/apache2/php.ini &> /dev/null
sed -i '/default_charset/c\default_charset = "UTF-8"' /etc/php5/cli/php.ini &> /dev/null
sed -i '/default_charset/c\default_charset = "UTF-8"' /etc/php5/fpm/php.ini &> /dev/null
#Set all PHP.ini tmp_upload_dir to sd (cant be /tmp as its ramdisk and limited size. Also used by Owncloud uploads)
local tmp_upload_dir="/var/tmp/php_upload_tmp"
mkdir -p "$tmp_upload_dir"
chown -R www-data:www-data "$tmp_upload_dir"
sed -i "/upload_tmp_dir =/c\upload_tmp_dir = $tmp_upload_dir" /etc/php5/apache2/php.ini &> /dev/null
sed -i "/upload_tmp_dir =/c\upload_tmp_dir = $tmp_upload_dir" /etc/php5/cli/php.ini &> /dev/null
sed -i "/upload_tmp_dir =/c\upload_tmp_dir = $tmp_upload_dir" /etc/php5/fpm/php.ini &> /dev/null
#Set all PHP.ini max upload sizes.
local php_max_post_size='2G'
local php_max_upload_size='2G'
sed -i "/upload_max_filesize =/c\upload_max_filesize = $php_max_upload_size" /etc/php5/apache2/php.ini &> /dev/null
sed -i "/post_max_size =/c\post_max_size = $php_max_post_size" /etc/php5/apache2/php.ini &> /dev/null
sed -i "/upload_max_filesize =/c\upload_max_filesize = $php_max_upload_size" /etc/php5/cli/php.ini &> /dev/null
sed -i "/post_max_size =/c\post_max_size = $php_max_post_size" /etc/php5/cli/php.ini &> /dev/null
sed -i "/upload_max_filesize =/c\upload_max_filesize = $php_max_upload_size" /etc/php5/fpm/php.ini &> /dev/null
sed -i "/post_max_size =/c\post_max_size = $php_max_post_size" /etc/php5/fpm/php.ini &> /dev/null
#PHP info web file
cat << _EOF_ > /var/www/phpinfo.php
_EOF_
WEBSERVER_PHP=2
fi
#WEBSERVER_MYADMINPHP
if (( $WEBSERVER_MYADMINPHP == 1 )); then
if (( $WEBSERVER_NGINX == 2 )); then
ln -s /usr/share/phpmyadmin /var/www
fi
WEBSERVER_MYADMINPHP=2
fi
#WEBSERVER_REDIS
if (( $WEBSERVER_REDIS == 1 )); then
#Enable resdis extensions for all webstacks:
echo -e "extension=redis.so" > /etc/php5/cli/conf.d/20-redis.ini &> /dev/null
echo -e "extension=redis.so" > /etc/php5/apache2/conf.d/20-redis.ini &> /dev/null
WEBSERVER_REDIS=2
fi
#OPENBAZAAR
if (( $OPENBAZAAR == 1 )); then
OPENBAZAAR=2
fi
#OwnCloud
if (( $OWNCLOUD == 1 )); then
#Setup /var/lib/owncloud/data
local target_data_symlink="/var/lib/owncloud/data"
mkdir -p "$target_data_symlink" &> /dev/null
#remove the /data path, but keep base directories
rm -R "$target_data_symlink" &> /dev/null
#Setup Data directory
local target_data_dir="$TARGET_DIRECTORY"
# we cant use /root with www-data.
if [ "$target_data_dir" = "/root" ]; then
target_data_dir=""
fi
# - Add target dir to base dirs
target_data_dir+="/owncloud_data"
mkdir -p "$target_data_dir"
#Create symlink
ln -fs "$target_data_dir" "$target_data_symlink"
#Set permissions to both directory and symlink.
chown -R www-data:www-data "$target_data_dir"
chown -R www-data:www-data "$target_data_symlink"
chmod -R 770 "$target_data_dir"
chmod -R 770 "$target_data_symlink"
#Set max upload size
sed -i "/php_value upload_max_filesize/c\php_value upload_max_filesize 2G" /var/www/owncloud/.htaccess
sed -i "/php_value post_max_size/c\php_value post_max_size 2G" /var/www/owncloud/.htaccess
#Set max allowed memory total/4
local memory_limit_max="$(( $(free -m -o | grep -m1 'Mem:' | awk '{print $2}') / 4 ))M"
sed -i "/php_value memory_limit/c\php_value memory_limit $memory_limit_max" /var/www/owncloud/.htaccess
if (( $WEBSERVER_NGINX == 2 )); then
cp /DietPi/dietpi/conf/nginx.sites-dietpi.owncloud.conf /etc/nginx/sites-dietpi/owncloud.conf
fi
OWNCLOUD=2
fi
# Transmission
if (( $TRANSMISSION == 1 )); then
sed -i '/USER=/c\USER=root' /etc/init.d/transmission-daemon
#Jessie, Transmission uses a systemd service
if (( $DISTRO == 3 )); then
sed -i '/User=/c\User=root' /lib/systemd/system/transmission-daemon.service
# SystemD Service missing --config-dir - Falling back to stable LSB.
#https://github.com/Fourdee/DietPi/issues/86
rm /lib/systemd/system/transmission-daemon.service
systemctl daemon-reload
fi
cp /DietPi/dietpi/conf/transmission_settings /etc/transmission-daemon/settings.json
Create_UserContent_Folders
sed -i '/"download-dir":/c\"download-dir": "'$TARGET_DIRECTORY/$FOLDER_DOWNLOADS'",' /etc/transmission-daemon/settings.json
#total mem / 7
local cache_size=$(( $(free -m -o | grep -m1 'Mem:' | awk '{print $2}') / 7 ))
local peer_limit=25
local max_peers=25
local peer_limit_torrent=15
local upload_slots=3
#Reduce for hardware below
#OrangePi
if (( $HW_MODEL == 30 )); then
peer_limit=15
max_peers=15
peer_limit_torrent=10
upload_slots=3
#Odroid C2
elif (( $HW_MODEL == 12 )); then
peer_limit=18
max_peers=18
peer_limit_torrent=10
upload_slots=3
#Odroid XU4
elif (( $HW_MODEL == 11 )); then
peer_limit=20
max_peers=20
peer_limit_torrent=10
upload_slots=3
#Odroid C1
elif (( $HW_MODEL == 10 )); then
peer_limit=16
max_peers=16
peer_limit_torrent=10
upload_slots=3
#RPi v3
elif (( $HW_MODEL == 3 )); then
peer_limit=14
max_peers=14
peer_limit_torrent=8
upload_slots=2
#RPi v2
elif (( $HW_MODEL == 2 )); then
peer_limit=12
max_peers=12
peer_limit_torrent=7
upload_slots=2
#RPi v1 512
elif (( $HW_MODEL == 1 )); then
peer_limit=10
max_peers=10
peer_limit_torrent=6
upload_slots=2
#RPi v1 256
elif (( $HW_MODEL == 0 )); then
peer_limit=7
max_peers=7
peer_limit_torrent=5
upload_slots=2
fi
#Apply optimized settings
sed -i '/cache-size-mb/c\ "cache-size-mb": '$cache_size',' /etc/transmission-daemon/settings.json
sed -i '/peer-limit-global/c\ "peer-limit-global": '$peer_limit',' /etc/transmission-daemon/settings.json
sed -i '/max-peers-global/c\ "max-peers-global": '$max_peers',' /etc/transmission-daemon/settings.json
sed -i '/peer-limit-per-torrent/c\ "peer-limit-per-torrent": '$peer_limit_torrent',' /etc/transmission-daemon/settings.json
sed -i '/upload-slots-per-torrent/c\ "upload-slots-per-torrent": '$upload_slots',' /etc/transmission-daemon/settings.json
TRANSMISSION=2
fi
#PHPBB
if (( $PHPBB == 1 )); then
chown -R www-data:www-data /var/www/phpBB3
/DietPi/dietpi/func/create_mysql_db phpbb3 dietpi root dietpi
PHPBB=2
fi
# Proftpd
if (( $FILESERVER_PROFTP == 1 )); then
sed -i "/root/c\#root" /etc/ftpusers
cp /DietPi/dietpi/conf/proftpd.conf /etc/proftpd/proftpd.conf
sed -i "/DefaultRoot /c\DefaultRoot $TARGET_DIRECTORY" /etc/proftpd/proftpd.conf
FILESERVER_PROFTP=2
fi
#Samba Server
if (( $FILESERVER_SAMBA == 1 )); then
echo -e "dietpi\ndietpi" | smbpasswd -s -a root
cp /DietPi/dietpi/conf/smb.conf /etc/samba/smb.conf
sed -i "/path = /c\path = $TARGET_DIRECTORY" /etc/samba/smb.conf
FILESERVER_SAMBA=2
fi
# vsFTPD
if (( $FILESERVER_VSFTPD == 1 )); then
cp /DietPi/dietpi/conf/vsftpd.conf /etc/vsftpd.conf
sed -i '/root/c\#root' /etc/ftpusers
sed -i "/local_root=/c\local_root=$TARGET_DIRECTORY" /etc/vsftpd.conf
FILESERVER_VSFTPD=2
fi
#Ympd MPD
if (( $HIFI == 1 )); then
#Start at boot
cp /DietPi/dietpi/conf/ympd_init /etc/init.d/ympd
chmod +x /etc/init.d/ympd
update-rc.d ympd defaults
#Copy default config
cp /DietPi/dietpi/conf/mpd.conf /etc/mpd.conf
#Add audio output options to mpd config
cat << _EOF_ >> /etc/mpd.conf
audio_output {
type "alsa"
name "My ALSA Device"
device "hw:0,0"
format "44100:16:2"
mixer_device "default"
mixer_control "PCM"
mixer_index "0"
}
#HDMI - Set format and audio_output_format to 48000hz
#audio_output_format "48000:16:2"
#samplerate_converter "Fastest Sinc Interpolator"
_EOF_
#OrangePi , unmute 3.5mm and add mixer controls
if (( $HW_MODEL >= 30 )) && (( $HW_MODEL < 40 )); then
amixer set -c 0 'Audio lineout' unmute &> /dev/null
sed -i '/mixer_device/c\mixer_device "hw:0"' /etc/mpd.conf
sed -i '/mixer_control/c\mixer_control "Lineout volume control"' /etc/mpd.conf
fi
#Setup data locations
Create_UserContent_Folders
sed -i '/music_directory/c\music_directory "'$TARGET_DIRECTORY/$FOLDER_MUSIC'"' /etc/mpd.conf
sed -i '/playlist_directory/c\playlist_directory "'$TARGET_DIRECTORY/$FOLDER_MUSIC'"' /etc/mpd.conf
mkdir -p "$TARGET_DIRECTORY"/.mpd_cache
sed -i '/db_file/c\db_file "'$TARGET_DIRECTORY'/.mpd_cache/db_file"' /etc/mpd.conf
#Grab our test music for the user.
Download_Test_Media
HIFI=2
fi
#Kodi
if (( $KODI == 1 )); then
#Remove Kodi user (Whilst waving)
userdel -r kodi &> /dev/null
#Run Kodi as root
sed -i '/USER=/c\USER=root' /etc/default/kodi &> /dev/null
#Copy udev rules, probably not needed for root, but we'll do it anyway
cp /DietPi/dietpi/conf/kodi_udev /etc/udev/rules.d/99-input.rules
chmod +x /etc/udev/rules.d/99-input.rules
#Create .desktop SymLinks
mkdir -p "$HOME"/Desktop
rm /usr/share/applications/kodi.desktop &> /dev/null
ln -sf /DietPi/dietpi/conf/desktop/kodi.desktop /usr/share/applications/kodi.desktop
ln -sf /DietPi/dietpi/conf/desktop/kodi.desktop "$HOME"/Desktop/kodi.desktop
#startkodi alias.
if (( $(cat /etc/bash.bashrc | grep -ci -m1 'startkodi') == 0 )); then
echo -e "alias startkodi='/DietPi/dietpi/misc/start_kodi'" >> /etc/bash.bashrc
fi
KODI=2
fi
#MINIDLNA
if (( $MINIDLNA == 1 )); then
#Run as root
sed -i '/USER=m/c\USER=root' /etc/init.d/minidlna
# + SystemD (incase minidlna package updates to systemd)
sed -i '/User=m/c\User=root' /lib/systemd/system/minidlna.service &> /dev/null
sed -i '/Group=m/c\Group=root' /lib/systemd/system/minidlna.service &> /dev/null
#Copy Config
cp /DietPi/dietpi/conf/minidlna.conf /etc/minidlna.conf
#Setup data directories
Create_UserContent_Folders
mkdir -p "$TARGET_DIRECTORY"/.MiniDLNA_Cache
sed -i "/media_dir=A,/c\media_dir=A,$TARGET_DIRECTORY/$FOLDER_MUSIC" /etc/minidlna.conf
sed -i "/media_dir=P,/c\media_dir=P,$TARGET_DIRECTORY/$FOLDER_PICTURES" /etc/minidlna.conf
sed -i "/media_dir=V,/c\media_dir=V,$TARGET_DIRECTORY/$FOLDER_VIDEO" /etc/minidlna.conf
sed -i "/db_dir=/c\db_dir=$TARGET_DIRECTORY/.MiniDLNA_Cache" /etc/minidlna.conf
MINIDLNA=2
fi
#NoIp
if (( $NOIPDYNDNS == 1 )); then
NOIPDYNDNS=2
fi
#OpenTyrian
if (( $OPENTYRIAN == 1 )); then
#Copy the DietPi run file for OpenTyrian
cp /DietPi/dietpi/conf/opentyrian_run /usr/local/games/opentyrian/run
chmod +x /usr/local/games/opentyrian/run
#Create .Desktop SymLinks
mkdir -p "$HOME"/Desktop
rm /usr/share/applications/opentyrian.desktop &> /dev/null
ln -s /DietPi/dietpi/conf/desktop/opentyrian.desktop /usr/share/applications/opentyrian.desktop
ln -s /DietPi/dietpi/conf/desktop/opentyrian.desktop "$HOME"/Desktop/opentyrian.desktop
OPENTYRIAN=2
fi
#DietPi-Cam
if (( $DIETPICAM == 1 )); then
#raspimjpeg Conf
cp /DietPi/dietpi/conf/dietpicam_raspimjpeg /etc/raspimjpeg
chmod +x /etc/raspimjpeg
ln -s /etc/raspimjpeg /var/www/dietpicam/raspimjpeg
#raspimjpeg/php schedule startup and control script
cp /DietPi/dietpi/conf/raspimjpeg.service /etc/dietpi/dietpi-software/services/raspimjpeg.service
#Motion config file
mkdir -p /etc/motion
cp /DietPi/dietpi/conf/dietpicam_motion /etc/motion/motion.conf
chgrp www-data /etc/motion/motion.conf
chmod 777 /etc/motion/motion.conf
usermod -a -G video www-data
#Set web permissions for local dietpicam web directory
chown -R www-data:www-data /var/www/dietpicam
#Setup Data directory
local dietpicam_media_directory=$TARGET_DIRECTORY
# we cant use /root/dietpicam, even with permissions setup, it cant access it. So move it to /dietpicam
if [ "$dietpicam_media_directory" = "/root" ]; then
dietpicam_media_directory=""
fi
mkdir -p "$dietpicam_media_directory"/dietpicam
rm -R /var/www/dietpicam/media
ln -s "$dietpicam_media_directory"/dietpicam /var/www/dietpicam/media
chown -R www-data:www-data "$dietpicam_media_directory"/dietpicam
chmod -R 777 "$dietpicam_media_directory"/dietpicam
#Enable RPi Camera module
sed -i '/start_x=/c\start_x=1' /DietPi/config.txt
DIETPICAM=2
fi
#Deluge
if (( $DELUGE == 1 )); then
#copy init
cp /DietPi/dietpi/conf/deluge.service /etc/dietpi/dietpi-software/services/deluge.service
#Generate deluge default config
deluged
killall -w deluged
#Copy DietPi configs
cp /DietPi/dietpi/conf/deluge.conf "$HOME"/.config/deluge/core.conf
cp /DietPi/dietpi/conf/deluge_web.conf "$HOME"/.config/deluge/web.conf
#Set remote access login details
echo -e "localclient:dietpi:10" > "$HOME"/.config/deluge/auth
#Setup data directory
Create_UserContent_Folders
sed -i '/"move_completed_path": /c\"move_completed_path": "'$TARGET_DIRECTORY/$FOLDER_DOWNLOADS'",' "$HOME"/.config/deluge/core.conf
sed -i '/"download_location": /c\"download_location": "'$TARGET_DIRECTORY/$FOLDER_DOWNLOADS'",' "$HOME"/.config/deluge/core.conf
sed -i '/"torrentfiles_location": /c\"torrentfiles_location": "'$TARGET_DIRECTORY/$FOLDER_DOWNLOADS'",' "$HOME"/.config/deluge/core.conf
#Applied Optimized settings
# - Cache size is in steps of 16 KiB. (Cachesize * 16 = total KiB)
local deluge_cache_size=$(( $(free -m -o | grep -m1 'Mem:' | awk '{print $2}') * 1000 / 9 / 16 ))
sed -i '/"cache_size": /c\ "cache_size": '"$deluge_cache_size"',' "$HOME"/.config/deluge/core.conf
DELUGE=2
fi
#GRASSHOPPER
if (( $GRASSHOPPER == 1 )); then
GRASSHOPPER=2
fi
#RaspControl
if (( $RASPCONTROL == 1 )); then
chown -R www-data:www-data /var/www/raspcontrol
chmod -R 750 /var/www/raspcontrol
#Setup login file
mkdir -p /etc/raspcontrol
cat << _EOF_ > /etc/raspcontrol/database.aptmnt
{
"user": "root",
"password": "dietpi"
}
_EOF_
chown -R www-data:www-data /etc/raspcontrol
chmod -R 750 /etc/raspcontrol
RASPCONTROL=2
fi
#Linux Dash
if (( $LINUXDASH == 1 )); then
chown -R www-data:www-data /var/www/linuxdash
chmod -R 750 /var/www/linuxdash
LINUXDASH=2
fi
#PIHOLE
if (( $PIHOLE == 1 )); then
#Generate index page that replaces adverts
cat << _EOF_ > /var/www/index.html
Blocked by Pi-hole.
_EOF_
#Set /var/www/pihole permisions
chown -R www-data:www-data /var/www/pihole
chmod -R 775 /var/www/pihole
#Generate pihole.log , set permissions to www-data
echo -e "" > /var/log/pihole.log
chown www-data:www-data /var/log/pihole.log &> /dev/null
chmod 775 /var/log/pihole.log
#Apply dnsmasq.conf
cp /DietPi/dietpi/conf/dnsmasq.conf /etc/dnsmasq.conf
#Add active network adapter
local active_network_adapter=$(sed -n 3p /DietPi/dietpi/.network)
sed -i "/interface=/c\interface=$active_network_adapter" /etc/dnsmasq.conf
#Set dnsmasq service to user www-data.
sed -i '/DNSMASQ_USER=/c\DNSMASQ_USER="www-data"' /etc/init.d/dnsmasq
PIHOLE=2
fi
#SUBSONIC
if (( $SUBSONIC == 1 )); then
#Generate user dir
Create_UserContent_Folders
#Optimize memory limit
local subsonic_memory_max=$(( $(free -m -o | grep -m1 'Mem:' | awk '{print $2}') / 5 ))
#Minimum cap 150mb
if (( $subsonic_memory_max < 150 )); then
subsonic_memory_max=150
fi
cat << _EOF_ > /etc/default/subsonic
SUBSONIC_USER=root
SUBSONIC_ARGS="--quiet --pidfile=/run/subsonic.pid --max-memory=$subsonic_memory_max --default-music-folder=$TARGET_DIRECTORY/$FOLDER_MUSIC --default-podcast-folder=$TARGET_DIRECTORY/$FOLDER_MUSIC --default-playlist-folder=$TARGET_DIRECTORY/$FOLDER_MUSIC"
_EOF_
#Grab our test media for user
Download_Test_Media
#Symlink ffmpeg to subsonic transcoder
#rpi armv6 jessie (using compiled ffmpeg)
if (( $HW_MODEL < 2 )) &&
(( $DISTRO == 3 )); then
ln -fs /usr/local/bin/ffmpeg /var/subsonic/transcode
#ARMv7
else
ln -fs /usr/bin/ffmpeg /var/subsonic/transcode
fi
SUBSONIC=2
fi
#RPIGPIO
if (( $RPIGPIO == 1 )); then
RPIGPIO=2
fi
#WIRINGPI
if (( $WIRINGPI == 1 )); then
WIRINGPI=2
fi
#RPII2C
if (( $RPII2C == 1 )); then
RPII2C=2
fi
#WEBIOPI
if (( $WEBIOPI == 1 )); then
#auto start
update-rc.d webiopi defaults
WEBIOPI=2
fi
#WEAVED
if (( $WEAVED == 1 )); then
WEAVED=2
fi
#DIETPICLOUDSHELL
if (( $DIETPICLOUDSHELL == 1 )); then
#Enable DietPi-Cloudshell autostart
/DietPi/dietpi/dietpi-autostart 5
#add alias
if (( $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-cloudshell=' ) == 0 )); then
sed -i "/#DietPi Additions/a alias dietpi-cloudshell='/DietPi/dietpi/dietpi-cloudshell'" /etc/bash.bashrc
fi
DIETPICLOUDSHELL=2
fi
#HAPROXY
if (( $HAPROXY == 1 )); then
#Create jail directory
mkdir -p /var/lib/haproxy
cat << _EOF_ > /etc/haproxy/haproxy.cfg
global
#rsyslog is required for logging
#log /var/log local0
#log /var/log local1 notice
maxconn 64
#Jail directory
chroot /var/lib/haproxy
stats socket /run/haproxy.sock mode 660 level admin
stats timeout 30s
user root
group root
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL).
ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
frontend localnodes
bind *:80
mode http
default_backend nodes
backend nodes
mode http
balance roundrobin
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
server web01 127.0.0.1:9000 check
server web02 127.0.0.1:9001 check
server web03 127.0.0.1:9002 check
#Admin web page
listen stats *:1338
stats enable
stats uri /
stats hide-version
stats auth admin:dietpi
_EOF_
#Add html error pages
mkdir -p /etc/haproxy/errors
local errorcode=0
errorcode=400; echo -e "[html]$errorcode[/html]" > /etc/haproxy/errors/"$errorcode".http
errorcode=403; echo -e "[html]$errorcode[/html]" > /etc/haproxy/errors/"$errorcode".http
errorcode=408; echo -e "[html]$errorcode[/html]" > /etc/haproxy/errors/"$errorcode".http
errorcode=500; echo -e "[html]$errorcode[/html]" > /etc/haproxy/errors/"$errorcode".http
errorcode=502; echo -e "[html]$errorcode[/html]" > /etc/haproxy/errors/"$errorcode".http
errorcode=503; echo -e "[html]$errorcode[/html]" > /etc/haproxy/errors/"$errorcode".http
errorcode=504; echo -e "[html]$errorcode[/html]" > /etc/haproxy/errors/"$errorcode".http
HAPROXY=2
fi
#SQUEEZEBOXSERVER
if (( $SQUEEZEBOXSERVER == 1 )); then
#Remove service
update-rc.d logitechmediaserver remove
rm /etc/init.d/logitechmediaserver
#DietPi-Services init
cp /DietPi/dietpi/conf/squeezeboxserver.service /etc/dietpi/dietpi-software/services/squeezeboxserver.service
#Generate user dir
Create_UserContent_Folders
#Grab our test media for user
Download_Test_Media
SQUEEZEBOXSERVER=2
fi
#WORDPRESS
if (( $WORDPRESS == 1 )); then
#Create mysql DB
/DietPi/dietpi/func/create_mysql_db wordpress dietpi root dietpi
service mysql stop
WORDPRESS=2
fi
#TIGHTVNCSERVER
if (( $TIGHTVNCSERVER == 1 )); then
#User, enter PW
WHIP_QUESTION='A password is required for your VNC Server.\n\nThe next screen will allow you to set your password, this password will be used when connecting from a VNC client/viewer.\n\nPress Ok/Enter when ready.'
whiptail --title "VNC Server Password" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 13 70
local entering_pw=1
local loop_count=0
while (( $entering_pw == 1 )); do
vncpasswd
((loop_count++))
#Password file created
if [ -f "$HOME"/.vnc/passwd ]; then
entering_pw=0
#Endless loop
elif (( $loop_count >= 30 )); then
entering_pw=0
fi
done
TIGHTVNCSERVER=2
fi
#FAIL2BAN
if (( $FAIL2BAN == 1 )); then
cat << _EOF_ > /etc/fail2ban/fail2ban.conf
[Definition]
# loglevel #1=error #2=warn #3=info
loglevel = 3
logtarget = /var/log/fail2ban.log
socket = /var/run/fail2ban/fail2ban.sock
pidfile = /var/run/fail2ban/fail2ban.pid
_EOF_
cp /DietPi/dietpi/conf/fail2ban_jail.conf /etc/fail2ban/jail.conf
FAIL2BAN=2
fi
#PHPSYSINFO
if (( $PHPSYSINFO == 1 )); then
#conf
cp /DietPi/dietpi/conf/phpsysinfo.ini /var/www/phpsysinfo/phpsysinfo.ini
#Set permissions
chown -R www-data:www-data /var/www/phpsysinfo
chmod -R 775 /var/www/phpsysinfo
PHPSYSINFO=2
fi
#PHPIMAGEGALLERY
if (( $PHPIMAGEGALLERY == 1 )); then
#Get test images
mkdir -p /var/www/gallery/DietPi
wget http://dietpi.com/images/dietpi-logo_256.png -O /var/www/gallery/DietPi/logo_256.png
mkdir -p /var/www/gallery/Tr-Zero
wget http://media.indiedb.com/images/games/1/25/24673/SS_0.jpg -O /var/www/gallery/Tr-Zero/SS_0.jpg
wget http://media.indiedb.com/images/games/1/25/24673/SS_44.jpg -O /var/www/gallery/Tr-Zero/SS_1.jpg
wget http://media.indiedb.com/images/games/1/25/24673/3.png -O /var/www/gallery/Tr-Zero/SS_2.jpg
#permissions for cache/thumbnail/database
mkdir -p /var/www/gallery/_sfpg_data
chown -R www-data:www-data /var/www/gallery/_sfpg_data
chmod -R 775 /var/www/gallery/_sfpg_data
#enable (Some type of security trigger)
sed -i "/define('SECURITY_PHRASE'/c\define('SECURITY_PHRASE', 'true');" /var/www/gallery/index.php
PHPIMAGEGALLERY=2
fi
#AMPACHE
if (( $AMPACHE == 1 )); then
Create_UserContent_Folders
Download_Test_Media
#create/insert our pre-made ampache sql db
wget http://dietpi.com/downloads/mysql_databases/ampache_mysql_3.8.2-v113.zip -O sql.zip
unzip sql.zip
rm sql.zip
/DietPi/dietpi/func/create_mysql_db ampache dietpi root dietpi
mysql -u root -pdietpi ampache < ampache.sql
rm ampache.sql
#Grab config
wget http://dietpi.com/downloads/conf/ampache.cfg.php_3.8.2-v113 -O /var/www/ampache/config/ampache.cfg.php
#Set Permisions
chown -R www-data:www-data /var/www/ampache
chmod -R 775 /var/www/ampache
AMPACHE=2
fi
#OPENVPNSERVER
if (( $OPENVPNSERVER == 1 )); then
local key_size=1024
#Start Cert/Key generation.
cp -R /usr/share/easy-rsa/ /etc/openvpn
mkdir -p /etc/openvpn/easy-rsa/keys
cat << _EOF_ >> /etc/openvpn/easy-rsa/vars
export KEY_SIZE=$key_size
export KEY_COUNTRY="UK"
export KEY_PROVINCE="DietPi"
export KEY_CITY="DietPi"
export KEY_ORG="DietPi"
export KEY_EMAIL="noreply@DietPi.com"
export KEY_OU="DietPi"
export KEY_NAME="DietPi_OpenVPN_Server"
_EOF_
#Create Server Cert Auth
echo -e "\nDietPi:\nGenerating unique OpenVPN certificates and keys. Please wait....\n"
openssl dhparam -out /etc/openvpn/dh"$key_size".pem "$key_size"
#Build Server certs/keys
chmod -R +x /etc/openvpn/easy-rsa
cd /etc/openvpn/easy-rsa
. ./vars
./clean-all
./build-ca --batch DietPi_OpenVPN_Server
./build-key-server --batch DietPi_OpenVPN_Server
#Copy Server cert/keys
cp /etc/openvpn/easy-rsa/keys/{DietPi_OpenVPN_Server.crt,DietPi_OpenVPN_Server.key,ca.crt} /etc/openvpn/
#Build client cert/keys
./build-key --batch DietPi_OpenVPN_Client
cd ..
#End Cert/Key generation.
#Server config
cat << _EOF_ > /etc/openvpn/server.conf
port 1194
proto udp
dev tun
ca ca.crt
cert DietPi_OpenVPN_Server.crt
key DietPi_OpenVPN_Server.key
dh dh$key_size.pem
server 10.8.0.0 255.255.255.0
client-to-client
keepalive 10 60
comp-lzo
max-clients 10
user nobody
group nogroup
persist-key
persist-tun
verb 3
#Web Forwarding (uncomment to enable)
#push "redirect-gateway"
#push "dhcp-option DNS 10.8.0.1"
_EOF_
#Client config
cat << _EOF_ > /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
client
proto udp
dev tun
#Ip/Domain name of DietPi system, running OpenVPN server.
remote mywebsite.com 1194
resolv-retry infinite
nobind
user nobody
group nogroup
persist-key
persist-tun
ns-cert-type server
comp-lzo
verb 3
_EOF_
#Unified client file. Add DietPi generated certs/keys.
# - Add Server Cert auth
echo '' >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
cat /etc/openvpn/ca.crt >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
echo '' >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
# - Add Client Cert
echo '' >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
cat /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.crt >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
echo '' >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
# - Add Client Key
echo '' >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
cat /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.key >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
echo '' >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn
#Copy client file to DietPi fileserver locations (/root or /mnt/usb_1)
cp /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn "$TARGET_DIRECTORY"/
# - and /boot partition
cp /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn /boot/
#enable ipv4 forwarding
sed -i '/net.ipv4.ip_forward=/c\net.ipv4.ip_forward=1' /etc/sysctl.conf
#Web Fowarding (Setup IPtables, must also be run during boot)
#iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o "$(sed -n 3p /DietPi/dietpi/.network)" -j MASQUERADE
OPENVPNSERVER=2
fi
#LETSENCRYPT
if (( $LETSENCRYPT == 1 )); then
LETSENCRYPT=2
fi
#WIFIHOTSPOT
if (( $WIFIHOTSPOT == 1 )); then
local eth_index=$(sed -n 1p /DietPi/dietpi/.network)
local wifi_index=$(sed -n 2p /DietPi/dietpi/.network)
# - DHCPD Config
cat << _EOF_ > /etc/dhcp/dhcpd.conf
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address 192.168.42.255;
option routers 192.168.42.1;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
_EOF_
# - Assign wlan as interface for dhcp server.
cat << _EOF_ > /etc/default/isc-dhcp-server
INTERFACES="wlan$wifi_index"
_EOF_
# - Remove all entries below wlan, so we can recreate them.
sed -i '/allow-hotplug wlan/q0' /etc/network/interfaces
# - enable up wlan
sed -i "/allow-hotplug wlan/c\allow-hotplug wlan$wifi_index" /etc/network/interfaces
# - Add wifi settings to network interfaces config
cat << _EOF_ >> /etc/network/interfaces
iface wlan$wifi_index inet static
address 192.168.42.1
netmask 255.255.255.0
#gateway 192.168.0.1
#wireless-essid FuzonWifi
#wireless-key abcde12345
#wireless-mode Managed
wireless-power off
#wpa-ssid FuzonWifi
#wpa-psk abcde12345
#dns-nameservers 8.8.8.8 8.8.4.4
# IP tables
up iptables-restore < /etc/iptables.ipv4.nat
_EOF_
# - Assign static IP for wlan now
ifconfig wlan$wifi_index 192.168.42.1
# - Create access point config
cat << _EOF_ > /etc/hostapd/hostapd.conf
interface=wlan$wifi_index
driver=rtl871xdrv
ssid=$(cat /DietPi/dietpi.txt | grep -m1 '^wifi_hotspot_ssid=' | sed 's/.*=//')
hw_mode=g
channel=$(cat /DietPi/dietpi.txt | grep -m1 '^wifi_hotspot_channel=' | sed 's/.*=//')
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=$(cat /DietPi/dietpi.txt | grep -m1 '^wifi_hotspot_key=' | sed 's/.*=//')
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
_EOF_
# - Enable access point config
cat << _EOF_ > /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
_EOF_
# - Enable IPv4 forwarding
sed -i "/net.ipv4.ip_forward=/c\net.ipv4.ip_forward=1" /etc/sysctl.conf
echo 1 > /proc/sys/net/ipv4/ip_forward
# - Apply iptables
iptables -t nat -A POSTROUTING -o eth$eth_index -j MASQUERADE
iptables -A FORWARD -i eth$eth_index -o wlan$wifi_index -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan$wifi_index -o eth$eth_index -j ACCEPT
# - Save IP tables, applied during ifup in /etc/network/interfaces.
iptables-save > /etc/iptables.ipv4.nat
#RPi 3 - WiFi hotspot. Internal Wifi fix.
# - Disable driver definition
if (( $HW_MODEL == 3 )); then
sed -i '/driver=/c\#driver=rtl871xdrv' /etc/hostapd/hostapd.conf
fi
WIFIHOTSPOT=2
fi
#TORHOTSPOT
if (( $TORHOTSPOT == 1 )); then
# - Tor config
cat << _EOF_ > /etc/tor/torrc
Log notice file /var/log/tor/notices.log
VirtualAddrNetwork 10.192.0.0/10
AutomapHostsSuffixes .onion,.exit
AutomapHostsOnResolve 1
TransPort 9040
TransListenAddress 192.168.42.1
DNSPort 53
DNSListenAddress 192.168.42.1
_EOF_
# - Flush IP tables
iptables -F
iptables -t nat -F
# - Generate tor prerouting tables
local wifi_index=$(sed -n 2p /DietPi/dietpi/.network)
iptables -t nat -A PREROUTING -i wlan$wifi_index -p tcp --dport 22 -j REDIRECT --to-ports 22
iptables -t nat -A PREROUTING -i wlan$wifi_index -p udp --dport 53 -j REDIRECT --to-ports 53
iptables -t nat -A PREROUTING -i wlan$wifi_index -p tcp --syn -j REDIRECT --to-ports 9040
# - Save
iptables-save > /etc/iptables.ipv4.nat
# - Generate Logfile
mkdir -p /var/log/tor
echo 0 > /var/log/tor/notices.log
chown -R debian-tor:nogroup /var/log/tor/notices.log
# - User: Test tor is functional.
#https://check.torproject.org
TORHOTSPOT=2
fi
#SHAIRPORTSYNC
if (( $SHAIRPORTSYNC == 1 )); then
#Reduce min volume scale threshold (prevents hissing on low end soundcards eg:rpi)
sed -i '/volume_range_db = /c\volume_range_db = 40;' /etc/shairport-sync.conf
SHAIRPORTSYNC=2
fi
#BRUTEFIR
if (( $BRUTEFIR == 1 )); then
#Copy configs and services
cp /DietPi/dietpi/conf/brutefir_config /etc/BruteFIR/
cp /DietPi/dietpi/conf/brutefir.service /etc/dietpi/dietpi-software/services/brutefir.service
#Modules
echo -e "snd-aloop" > /etc/modules-load.d/brutefir-alsa-loopback.conf
echo -e "options snd-aloop id=BruteFIR enable=1 pcm_substreams=1 pcm_notify=1" > /etc/modprobe.d/brutefir-alsa-loopback.conf
#Asound.conf RPI
cat << _EOF_ > /etc/asound.conf
pcm.!default {
type plug
slave {
pcm {
type hw
card "BruteFIR"
device 0
channels 2
format "S16_LE"
rate 44100
}
}
}
ctl.!default {
type hw
card "BruteFIR"
}
_EOF_
BRUTEFIR=2
fi
#PYDIO
if (( $PYDIO == 1 )); then
#Configure apache2
# - Disable php output_buffering =
sed -i '/output_buffering = /c\output_buffering = Off/' /etc/php5/apache2/php.ini
# - Allow overrides and redirects
sed -i "/AllowOverride /c\ AllowOverride All" /etc/apache2/sites-enabled/000-default*
# - +Jessie
sed -i "/AllowOverride /c\ AllowOverride All" /etc/apache2/apache2.conf
# - Enable apache2 rewrite engine
a2enmod rewrite
# - Enable PHP mods
php5enmod mcrypt
php5enmod gd
#Create Mysql DB
/DietPi/dietpi/func/create_mysql_db pydio dietpi root dietpi
#Setup Data directory
local target_data_dir="$TARGET_DIRECTORY"
# - we cant use /root with www-data.
if [ "$target_data_dir" = "/root" ]; then
target_data_dir=""
fi
target_data_dir+="/pydio_data"
# - Generate user data dir
mkdir -p "$target_data_dir"
# - move data structure
mv /var/www/pydio/data/* "$target_data_dir"/
rm -R /var/www/pydio/data
ln -sf "$target_data_dir" /var/www/pydio/data
#Set permissions
chown -R www-data:www-data /var/www/pydio
chown -R www-data:www-data "$target_data_dir"
PYDIO=2
fi
#SQUEEZELITE
if (( $SQUEEZELITE == 1 )); then
#Specify buffers for RPi (prevents buffer underruns on default settings)
# - Miliseconds
# -- Nice big buffer for single cores
if (( $CPU_CORES_TOTAL == 1 )); then
sed -i '/SB_EXTRA_ARGS=/c\SB_EXTRA_ARGS="-a 180"' /etc/default/squeezelite
# -- lapse buffer for >=2 cores
else
sed -i '/SB_EXTRA_ARGS=/c\SB_EXTRA_ARGS="-a 75"' /etc/default/squeezelite
fi
# - Buffer/period/bit
#sed -i '/SB_EXTRA_ARGS=/c\SB_EXTRA_ARGS="-a 4096:8:16:0"' /etc/default/squeezelite
SQUEEZELITE=2
fi
#EMONCMS
if (( $EMONCMS == 1 )); then
# - Enable extensions:
echo -e "extension=dio.so" > /etc/php5/apache2/conf.d/20-dio.ini
echo -e "extension=dio.so" > /etc/php5/cli/conf.d/20-dio.ini
echo -e "extension=dio.so" > /etc/php5/mods-available/dio.ini
# - Enable rewrite engine
a2enmod rewrite
# - Allow overrides and redirects
sed -i "/AllowOverride /c\ AllowOverride All" /etc/apache2/sites-enabled/000-default*
# - +Jessie
sed -i "/AllowOverride /c\ AllowOverride All" /etc/apache2/apache2.conf
# - Set www permissions
chown -R www-data:www-data /var/www/emoncms
# - Create mysql DB
/DietPi/dietpi/func/create_mysql_db emoncms dietpi root dietpi
# - Create data dirs for emoncms feed engines:
mkdir /var/lib/{phpfiwa,phpfina,phptimeseries}
chown www-data:root /var/lib/{phpfiwa,phpfina,phptimeseries}
# - Copy default emonCMS config file, apply our dietpi sql creds
cp /var/www/emoncms/default.settings.php /var/www/emoncms/settings.php
sed -i 's/_DB_USER_/root/g' /var/www/emoncms/settings.php
sed -i 's/_DB_PASSWORD_/dietpi/g' /var/www/emoncms/settings.php
# - Set write permissions for the emoncms logfile:
# NB: Create the file here. chmod 666 permissions are required. Has been added to dietpi-ramlog and applied during boot | Apply_Unique_Logfile_Permissions()
echo 0 > /var/log/emoncms.log
EMONCMS=2
fi
#EMONHUB
if (( $EMONHUB == 1 )); then
# - Copy configs
cp /etc/emonhub/conf/default/emonhub /etc/default/emonhub
# - Setup service
cp /etc/emonhub/service/emonhub /etc/init.d/emonhub
chmod +x /etc/init.d/emonhub
update-rc.d emonhub defaults
chmod +x -R /etc/emonhub
#RPI 3 - Must disable BCM BT to recover UART 0
if (( $HW_MODEL == 3 )); then
# - Add DToverlay to disable bluetooth
if (( $(cat /DietPi/config.txt | grep -ci -m1 '=pi3-disable-bt') == 0 )); then
echo -e "\ndtoverlay=pi3-disable-bt" >> /DietPi/config.txt
# - Enable
else
sed -i '/pi3-disable-bt/c\dtoverlay=pi3-disable-bt' /DietPi/config.txt
fi
# - Disable bluetooth service
systemctl stop hciuart
systemctl disable hciuart
fi
#RPI - Disable serial tty that emonPi uses.
sed -i 's/console=ttyAMA0,115200//' /boot/cmdline.txt
systemctl stop serial-getty@ttyAMA0.service
systemctl disable serial-getty@ttyAMA0.service
# - Apply user API KEY
USER_EMONHUB_APIKEY_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_emonhub_apikey=' | sed 's/.*=//')
sed -i "/apikey/c\ apikey = $USER_EMONHUB_APIKEY_CURRENT" /etc/emonhub/conf/emonhub.conf
EMONHUB=2
fi
#RPIMONITOR
if (( $RPIMONITOR == 1 )); then
# - Update apt package stats
/usr/share/rpimonitor/scripts/updatePackagesStatus.pl
# - Create a cron job to check this daily?
RPIMONITOR=2
fi
#NETDATA
if (( $NETDATA == 1 )); then
getent group netdata > /dev/null || groupadd -r netdata
getent passwd netdata > /dev/null || useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
for x in /var/cache/netdata /usr/share/netdata/web /etc/netdata /var/log/netdata; do
chown -R netdata.netdata $x
chmod 0755 $x
done
# - Workaround to prevent update checks and the "distracting update flashing button": https://github.com/firehol/netdata/issues/233#issuecomment-210468649
echo 0 > /usr/share/netdata/web/version.txt
NETDATA=2
fi
#BAIKAL
if (( $BAIKAL == 1 )); then
# - Permissions
chown -R www-data:www-data /var/www/baikal
# - install/run composer | Also run for ampache. Move this to a global function....
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer
cd /var/www/baikal
composer install --no-interaction
cd ~/
# - Mysql DB
/DietPi/dietpi/func/create_mysql_db baikal dietpi root dietpi
BAIKAL=2
fi
#MUMBLESERVER
if (( $MUMBLESERVER == 1 )); then
#Cap total connections
sed -i '/users=/c\users=40' /etc/mumble-server.ini
# - RPI 1
if (( $HW_MODEL <= 1 )); then
sed -i '/users=/c\users=8' /etc/mumble-server.ini
fi
#Name the root channel
sed -i '/registerName=/c\registerName=DietPi Mumble Server' /etc/mumble-server.ini
#Disable DB logging
sed -i '/logdays=/c\logdays=-1' /etc/mumble-server.ini
MUMBLESERVER=2
fi
}
Install_Apply_GPU_Settings(){
local memory_split_mode=0
#Define Memory Split Modes with installed software
#Mode 3 (Kodi / Dietpicam / MED GPU RAM / 128MB)
if (( $KODI == 2 )); then
memory_split_mode=3
elif (( $DIETPICAM == 2 )); then
memory_split_mode=3
#Mode 2 (Desktop / LOW GPU RAM)
elif (( $DESKTOP_LXDE == 2 )); then
memory_split_mode=2
elif (( $OPENTYRIAN == 2 )); then
memory_split_mode=2
#Mode 1 - DietPi-Cloudshell (forces display output)
elif (( $DIETPICLOUDSHELL == 2 )); then
memory_split_mode=1
#Mode 0 (Server)
else
memory_split_mode=0
fi
#Apply GPU Settings
#Mode 3
if (( $memory_split_mode == 3 )); then
#odroid C1
if (( $HW_MODEL == 10 )); then
sed -i '/setenv hdmioutput /c\setenv hdmioutput "1"' /DietPi/boot.ini
sed -i '/setenv vpu /c\setenv vpu "1"' /DietPi/boot.ini
sed -i '/setenv m_bpp /c\setenv m_bpp "32"' /DietPi/boot.ini
#rpi
elif (( $HW_MODEL < 10 )); then
sed -i '/gpu_mem_256=/c\gpu_mem_256=128' /DietPi/config.txt
sed -i '/gpu_mem_512=/c\gpu_mem_512=128' /DietPi/config.txt
sed -i '/gpu_mem_1024=/c\gpu_mem_1024=128' /DietPi/config.txt
sed -i "/rpi_hdmi_output=/c\rpi_hdmi_output=1" /DietPi/dietpi.txt
fi
#Mode 2
elif (( $memory_split_mode == 2 )); then
#odroid C1
if (( $HW_MODEL == 10 )); then
sed -i '/setenv hdmioutput /c\setenv hdmioutput "1"' /DietPi/boot.ini
sed -i '/setenv vpu /c\setenv vpu "1"' /DietPi/boot.ini
sed -i '/setenv m_bpp /c\setenv m_bpp "32"' /DietPi/boot.ini
#rpi
elif (( $HW_MODEL < 10 )); then
sed -i '/gpu_mem_256=/c\gpu_mem_256=64' /DietPi/config.txt
sed -i '/gpu_mem_512=/c\gpu_mem_512=64' /DietPi/config.txt
sed -i '/gpu_mem_1024=/c\gpu_mem_1024=64' /DietPi/config.txt
sed -i "/rpi_hdmi_output=/c\rpi_hdmi_output=1" /DietPi/dietpi.txt
fi
#Mode 1 - DietPi-Cloudshell
elif (( $memory_split_mode == 1 )); then
#odroid C1
if (( $HW_MODEL == 10 )); then
sed -i '/setenv hdmioutput /c\setenv hdmioutput "1"' /DietPi/boot.ini
sed -i '/setenv m_bpp /c\setenv m_bpp "16"' /DietPi/boot.ini
#rpi
elif (( $HW_MODEL < 10 )); then
sed -i '/framebuffer_width=/c\framebuffer_width=320' /DietPi/config.txt
sed -i '/framebuffer_height=/c\framebuffer_height=240' /DietPi/config.txt
sed -i '/gpu_mem_256=/c\gpu_mem_256=16' /DietPi/config.txt
sed -i '/gpu_mem_512=/c\gpu_mem_512=16' /DietPi/config.txt
sed -i '/gpu_mem_1024=/c\gpu_mem_1024=16' /DietPi/config.txt
sed -i "/rpi_hdmi_output=/c\rpi_hdmi_output=1" /DietPi/dietpi.txt
fi
#Mode 0
elif (( $memory_split_mode == 0 )); then
#odroid C1
if (( $HW_MODEL == 10 )); then
#sed -i '/setenv hdmioutput /c\setenv hdmioutput "1"' /DietPi/boot.ini
sed -i '/setenv vpu /c\setenv vpu "0"' /DietPi/boot.ini
sed -i '/setenv m_bpp /c\setenv m_bpp "16"' /DietPi/boot.ini
#rpi
elif (( $HW_MODEL < 10 )); then
sed -i '/gpu_mem_256=/c\gpu_mem_256=16' /DietPi/config.txt
sed -i '/gpu_mem_512=/c\gpu_mem_512=16' /DietPi/config.txt
sed -i '/gpu_mem_1024=/c\gpu_mem_1024=16' /DietPi/config.txt
#sed -i "/rpi_hdmi_output=/c\rpi_hdmi_output=1" /DietPi/dietpi.txt
fi
fi
#Odroid C2 always force 24bit. This ensures both Kodi and Xserver will work. Known issue, waiting for Odroid/HK fix.
if (( $HW_MODEL == 12 )); then
sed -i '/setenv m_bpp /c\setenv m_bpp "24"' /DietPi/boot.ini
fi
}
Dedicated_Usb_Drive_Enable(){
local usb_hdd_mounted=$(df -h | grep -ci -m1 '/mnt/usb_1')
#Only enable if mounted
if (( $usb_hdd_mounted == 1 )); then
USBDRIVE=2
#Move swapfile to USB
echo -e "\nDietPi: Moving swapfile to USB drive, please wait...\n"
/DietPi/dietpi/func/dietpi-set_dphys-swapfile $(cat /etc/dphys-swapfile | grep 'CONF_SWAPSIZE=' | sed 's/.*=//') /mnt/usb_1/.swapfile
fi
}
Run_Installations(){
#------------------------------------------------------------
#Disable powersaving on Main screen during installation
setterm -blank 0 -powersave off 2> /dev/null
#------------------------------------------------------------
#Set target user/personal data base directory
# - Flash (default)
TARGET_DIRECTORY="/root"
# - dietpi.txt custom override (dietpi_userdata_basedirectory=)
local dietpi_userdata_basedirectory=$(cat /DietPi/dietpi.txt | grep -m1 'dietpi_userdata_basedirectory=' | sed 's/.*=//')
if [ "$dietpi_userdata_basedirectory" != "Auto" ]; then
TARGET_DIRECTORY="$dietpi_userdata_basedirectory"
# - USB
elif (( $USBDRIVE > 0 )); then
TARGET_DIRECTORY="/mnt/usb_1"
fi
#Attempt to create user/personal data directory
mkdir -p "$TARGET_DIRECTORY" &> /dev/null
# - Permissions test | Generate a test file inside the target directory, and check it exists.
local test_file_name=".testfile_dietpi_userdata_basedirectory"
echo 0 > "$TARGET_DIRECTORY"/"$test_file_name"
if [ -f "$TARGET_DIRECTORY"/"$test_file_name" ]; then
rm "$TARGET_DIRECTORY"/"$test_file_name" &> /dev/null
else
Error_Create_UserDataDirectory
exit
fi
#------------------------------------------------------------
#Set current path to home folder
cd "$HOME"/
#Update Apt
Banner_Apt_Update
#Always clean and update apt, before running installs.
#The previous "once every 7days" update caused missing package errors if a package filename was changed in the repo during that time.
# - Wait for outstanding DietPi apt-get update thread to finish.
/DietPi/dietpi/dietpi-apt-get_update 1
# - use normal apt as visual for user.
apt-get clean
apt-get update
#Simluated apt installation to check for failures related to apt-cache.
echo -e "\nDietPi: Running apt simulation to check for errors, please wait...\n"
local package_to_test="bash-doc"
apt-get install $package_to_test -s -y &> /dev/null
local result=$?
if (( $result != 0 )); then
echo -e "\nError: Apt simulation failed.\n - The apt cache may be corrupt\nDietPi-Software will now exit\n"
exit
fi
#Upgrade Apt
Banner_Setup
Banner_Apt_Update
# - Set noninteractive | Allows automation for Odroid kernel updates without user prompt.
DEBIAN_FRONTEND='noninteractive' apt-get upgrade -y
#Generate dir for dietpi-software installed "non-service" based control scripts
mkdir -p /etc/dietpi/dietpi-software/services
chmod -R +x /etc/dietpi/dietpi-software/services
#Apply DietPi choice systems
Apply_FileServer_Choices
Apply_SSHServer_Choices
Apply_Logging_Choices
#Apply DietPi preference systems
Apply_Webserver_Preference
#Install Linux Software
Install_Linux_Software
#Install DietPi Optimized Software
Install_Dietpi_Software
#Apply Uninstall script created by DietPi choice system
Uninstall_NonSelected_Choices
#Apply DietPi Configuration and Optimization Files
Banner_Configs
Install_Apply_Configs
#Apply GPU Memory Splits
Install_Apply_GPU_Settings
#Disable services so DietPi-services can take control (DietPi will start all services from rc.local)
/DietPi/dietpi/dietpi-services disable
#Write to .install File
Write_InstallFileList
#DietPi-Automation
if (( $DIETPI_INSTALL_STAGE == 0 )) &&
(( $AUTOINSTALL_INDEX == 1 )); then
#Apply Timezone
if [ "$AUTOINSTALL_TIMEZONE" != "Europe/London" ]; then
echo -e "\nDietPi: Setting Timezone = $AUTOINSTALL_TIMEZONE"
echo -e "$AUTOINSTALL_TIMEZONE" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
fi
#Apply Language (Locale)
if [ "$AUTOINSTALL_LANGUAGE" != "en_GB" ]; then
echo -e "\nDietPi: Setting Locale = $AUTOINSTALL_LANGUAGE"
#Disable en_GB
sed -i "/en_GB.UTF-8/c\# en_GB.UTF-8 UTF-8" /etc/locale.gen
#Enable user setting
sed -i "/$AUTOINSTALL_LANGUAGE.UTF-8/c $AUTOINSTALL_LANGUAGE.UTF-8 UTF-8" /etc/locale.gen
echo -e "LANG=$AUTOINSTALL_LANGUAGE.UTF-8" > /etc/default/locale
locale-gen
localectl set-locale LANG=$AUTOINSTALL_LANGUAGE
fi
#Apply Keyboard
if [ "$AUTOINSTALL_KEYBOARD" != "gb" ]; then
echo -e "\nDietPi: Setting Keyboard = $AUTOINSTALL_KEYBOARD"
sed -i '/XKBLAYOUT=/c XKBLAYOUT="'"$AUTOINSTALL_KEYBOARD"'"' /etc/default/keyboard
#systemctl restart keyboard-setup
fi
#Apply & Mount Network drives if installed
if (( $SMBCLIENT == 2 )); then
/DietPi/dietpi/func/dietpi-set_smbclient 1
fi
if (( $CURLFTPFS == 2 )); then
/DietPi/dietpi/func/dietpi-set_curlftpfs 1
fi
local run_custom_script=0
#Custom 1st run Script (Local file)
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
#check source is online
INSTALL_URL_ADDRESS=$AUTOINSTALL_CUSTOMSCRIPTURL
/DietPi/dietpi/func/check_connection "$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 == 1 )); 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
}
FirstRun_Automation(){
#Get settings
AUTOINSTALL_INDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Install_Index=' | sed 's/.*=//')
AUTOINSTALL_SKIPUSBDRIVEPROMPT=$(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_DietpiSoftware_SkipUsbDrive=1')
AUTOINSTALL_SKIPQUESTIONS=$(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_DietpiSoftware_SkipQuestions=1')
AUTOINSTALL_IGNOREERRORS=$(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_DietpiSoftware_IgnoreErrors=1')
AUTOINSTALL_DEDICATEDUSBDRIVEFORMAT=0
AUTOINSTALL_AUTOSTARTTARGET=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_AutoStartTarget=' | sed 's/.*=//' )
AUTOINSTALL_SSHINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_DietpiSoftware_SSHServerIndex=' | sed 's/.*=//')
AUTOINSTALL_FILESERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_DietpiSoftware_FileServerIndex=' | sed 's/.*=//')
AUTOINSTALL_LOGGINGINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_DietpiSoftware_LoggingIndex=' | sed 's/.*=//')
AUTOINSTALL_WEBSERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_DietpiSoftware_WebserverIndex=' | sed 's/.*=//')
AUTOINSTALL_TIMEZONE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Timezone=' | sed 's/.*=//' )
AUTOINSTALL_LANGUAGE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Locale=' | sed 's/.*=//' )
AUTOINSTALL_KEYBOARD=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_KeyboardLayout=' | sed 's/.*=//' )
AUTOINSTALL_CUSTOMSCRIPTURL=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_CustomScriptURL=' | sed 's/AUTO_CustomScriptURL=//')
#Automated install based on index
if (( $AUTOINSTALL_INDEX > 0 )); then
/DietPi/dietpi/dietpi-banner 0
echo -e "\n Running Automated Installation:\n"
#Skip dietpi-software menu
TARGETMENUID=-1
#Set start install
GOSTARTINSTALL=1
#Auto format/setup USB drive
if [ -f /boot/Automation_Format_My_Usb_Drive ]; then
#Skip USB drive prompt
AUTOINSTALL_SKIPUSBDRIVEPROMPT=1
#Run Format
/DietPi/dietpi/dietpi-external_drive_setup 1
#Enable USB drive for this system.
Dedicated_Usb_Drive_Enable
fi
#Define Install indexs
#DietPi-Automated (from dietpi.txt)
if (( $AUTOINSTALL_INDEX == 1 )); then
echo -e " - DietPi-Automated\n"
/DietPi/dietpi/dietpi-funtime 0
#Override automation options?
# - Leave this down to the user and their settings in dietpi.txt
#Find if user has enabled at least 1 installation option in dietpi.txt
if (( $(cat /DietPi/dietpi.txt | grep '^AUTO_DietpiSoftware_Install' | grep -ci -m1 '=1') )); then
#Save current vars to .installed file
Write_InstallFileList
#Obtain the .installed names of all software which has been selected for install
cat /DietPi/dietpi.txt | grep '^AUTO_DietpiSoftware_Install' | grep '=1' | sed 's/AUTO_DietpiSoftware_Install_//' | sed 's/1.*//' > /tmp/.dietpi-software_autoinstall_choices
while read line
do
#Update.installed file and set to 1 (to be installed)
sed -i "/^$line/c $line\1" "$FP_INSTALLED_FILE"
done < /tmp/.dietpi-software_autoinstall_choices
rm /tmp/.dietpi-software_autoinstall_choices
#Read the .installed file to update vars.
Read_InstallFileList
fi
#Grasshopper
elif (( $AUTOINSTALL_INDEX == 2 )); then
echo -e " - Grasshopper\n"
/DietPi/dietpi/dietpi-funtime 0
#Required DietPi Software
GRASSHOPPER=1
#Override automation options
AUTOINSTALL_SKIPUSBDRIVEPROMPT=1
AUTOINSTALL_SKIPQUESTIONS=1
AUTOINSTALL_SSHINDEX=-2
AUTOINSTALL_LOGGINGINDEX=-2
#Inform user to setup STATIC IP
WHIP_TITLE='DietPi - Setup static IP'
WHIP_QUESTION='DietPi-Config will now be launched, this will allow you to setup a STATIC IP for this device.\nSimply 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" 19 70
#Launch DietPi-config networking menu
/DietPi/dietpi/dietpi-config 8 1
elif (( $AUTOINSTALL_INDEX == 3 )); then
echo -e " - Pi-hole\n"
/DietPi/dietpi/dietpi-funtime 0
#Required DietPi Software
PIHOLE=1
#Override automation options
AUTOINSTALL_SKIPUSBDRIVEPROMPT=1
AUTOINSTALL_SKIPQUESTIONS=1
#Inform user to setup STATIC IP
WHIP_TITLE='DietPi - Setup static IP'
WHIP_QUESTION='DietPi-Config will now be launched, this will allow you to setup a STATIC IP for this device.\nSimply 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" 19 70
#Launch DietPi-config networking menu
/DietPi/dietpi/dietpi-config 8 1
fi
fi
#Further Automated options. (Applied regardless of AUTOINSTALL_INDEX)
INDEX_SSHSERVER_TARGET=$AUTOINSTALL_SSHINDEX
INDEX_FILESERVER_TARGET=$AUTOINSTALL_FILESERVERINDEX
INDEX_LOGGING_TARGET=$AUTOINSTALL_LOGGINGINDEX
INDEX_WEBSERVER_TARGET=$AUTOINSTALL_WEBSERVERINDEX
#VM - Disable external drive question/setup
if (( $HW_MODEL == 20 )); then
AUTOINSTALL_SKIPUSBDRIVEPROMPT=1
AUTOINSTALL_SKIPQUESTIONS=1
fi
}
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
#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
clear
/DietPi/dietpi/dietpi-banner 0
WHIP_TITLE='DietPi Update Completed'
#Prompt user for reboot, if not overridden by automation flag
if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_DietpiSoftware_SkipUpdateRebootPrompt=1') == 0 )); then
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
#Make sure apt-get_update thread is finished
/DietPi/dietpi/dietpi-apt-get_update 1
#Reboot required NOW, exit this script NOW
reboot
exit
fi
}
FirstRun_Questions(){
#Questions Start (Ask our inital questions, before allowing access to the software selection menus)
if (( $AUTOINSTALL_SKIPQUESTIONS == 0 )); then
WHIP_TITLE='DietPi - Welcome'
whiptail --title "$WHIP_TITLE" --msgbox "Welcome to the DietPi Installation System. \n \nBefore we can begin, we need to ask you a few questions regarding this installation. \n \nPress Enter to begin." 14 70
fi
#Request for Dedicated External Drive installation.
if (( $USBDRIVE == 0 )) &&
(( $AUTOINSTALL_SKIPUSBDRIVEPROMPT == 0 )); then
WHIP_TITLE='Setup USB Dedicated Drive?'
WHIP_QUESTION='Will you be using a dedicated USB hard drive with this DietPi installation? \n \n(NOTICE) Your decision now is final and cannot be changed at a later date. DietPi will automatically setup your future software installations to utilize the USB drive instead of MicroSD.\nAs USB hard drives are generally faster than MicroSD, using a USB drive can vastly improve system performance.\n\n This is recommended for: \n - BitTorrent (Store downloads) \n - OwnCloud \n - Kodi (Store Media Files)\n - Hifi (Store Music)'
whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" --defaultno 22 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Run external drive setup script
/DietPi/dietpi/dietpi-external_drive_setup
#Enable USB drive for this system.
Dedicated_Usb_Drive_Enable
fi
fi
#Questions End
if (( $AUTOINSTALL_SKIPQUESTIONS == 0 )) &&
(( $AUTOINSTALL_INDEX == 0 )); then
WHIP_TITLE='DietPi - Questions Completed'
whiptail --title "$WHIP_TITLE" --msgbox "The DietPi-Software menu will now appear with the following options: \n\n- Select DietPi Optimized Software\nThis will allow you to select Optimized and Ready to Run software.\nhttp://dietpi.com/software\n\n- Select Additional Linux Software.\nThis will allow you to select standard linux software relative to this installation. \n\n- DietPi-Config\nA feature rich configuration tool for your device.\n \n- Go Start Install\nThis will start the installation process for your selected items." 21 75
fi
}
#/////////////////////////////////////////////////////////////////////////////////////
# Error Functions
#/////////////////////////////////////////////////////////////////////////////////////
Error_Display(){
#Automation | Save to logfile if errors are being ignored
if (( $DIETPI_INSTALL_STAGE == 0 )) && (( $AUTOINSTALL_IGNOREERRORS == 1 )); then
echo -e "Error: $ERROR_TEXT" >> "$FP_DIETPIAUTOMATION_LOG"
else
whiptail --title "Error" --msgbox "$ERROR_TEXT" 16 70
fi
}
Error_NoConnection_NoInstall(){
ERROR_TEXT="Unable to Install $INSTALL_DESCRIPTION \n\n$INSTALL_URL_ADDRESS is offline and/or unreachable."
Error_Display
}
Error_AptGet_Failed(){
ERROR_TEXT="Apt-get has failed:\n - Apt string = $string\n - Error code = $result\n - Software Title = $INSTALL_DESCRIPTION"
Error_Display
}
Error_Create_UserDataDirectory(){
ERROR_TEXT="DietPi was unable to create your custom user/personal data directory (dietpi_userdata_basedirectory= set in dietpi.txt):\n\n - $(cat /DietPi/dietpi.txt | grep -m1 'dietpi_userdata_basedirectory=' | sed 's/.*=//')\n\nDietPi-Software will now exit. Please correct the value of dietpi_userdata_basedirectory in dietpi.txt before trying again."
Error_Display
}
#/////////////////////////////////////////////////////////////////////////////////////
# WHIPTAIL MENU Functions
#/////////////////////////////////////////////////////////////////////////////////////
Menu_No_Internet(){
#Ask to check settings,
whiptail --title "No Internet Connection!" --yesno "Internet access is required to start the DietPi Installation Program.\nWould you like to change your network settings and try again?\n\nIf problems persist:\n$INTERNET_URL_TEST may be offline and/or unreachable." --yes-button "Ok" --no-button "Exit" --defaultno --backtitle "$WHIP_BACKTITLE" 15 70
CHOICE=$?
#run dietpi config
if (( $CHOICE == 0 )); then
whiptail --title "Launching DietPi-Config" --msgbox "DietPi-Config will now be started.\nUse the Network Options menu to change and test your network settings.\n\nWhen completed, Exit DietPi-Config to resume setup." --backtitle "Launching DietPi-Config" 14 60
/DietPi/dietpi/dietpi-config 8 1
#User aborted setup
else
Banner_Aborted
#Exit Script NOW
exit
fi
}
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=""
#User/Personal Data override
local user_data_path=$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_userdata_basedirectory=' | sed 's/.*=//')
# - Add location info for Auto
local user_data_auto_location=""
if [ "$user_data_path" = "Auto" ]; then
if (( $USBDRIVE == 2 )); then
user_data_auto_location="| USB Drive | /mnt/usb_1"
else
user_data_auto_location="| Flash (SD/EMMC) | /root"
fi
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 address: $(sed -n 4p /DietPi/dietpi/.network)"
OPTION=$(whiptail --title "$WHIP_TITLE" --backtitle "$WHIP_BACKTITLE" --menu " Hardware Detected : $HW_MODEL_DESCRIPTION" --default-item "$MENU_MAIN_LASTITEM" --cancel-button "Exit" 17 75 10 \
"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_path $user_data_auto_location" \
"DietPi-Config" "Feature-rich configuration tool for your device." \
"Help!" "Links to online guides and information." \
"Go" ">> Start Installation." 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
MENU_MAIN_LASTITEM="$OPTION"
case "$OPTION" in
"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=false
if (( $INDEX_SSHSERVER_TARGET != $INDEX_SSHSERVER_CURRENT )); then
INSTALL_SSHSERVER_CHOICESMADE=true
#Inform user
WHIP_TITLE="SSH Server Change"
WHIP_QUESTION="$OPTION has been selected:\n- Your choice will be applied when >> Go Start Install << 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 or sharing files and folders on this device.\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=false
if (( $INDEX_FILESERVER_TARGET != $INDEX_FILESERVER_CURRENT )); then
INSTALL_FILESERVER_CHOICESMADE=true
#Inform user
WHIP_TITLE="Fileserver Choice Change"
WHIP_QUESTION="$OPTION has been selected:\n- Your choice will be applied when >> Go Start Install << 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=false
if (( $INDEX_LOGGING_TARGET != $INDEX_LOGGING_CURRENT )); then
INSTALL_LOGGING_CHOICESMADE=true
#Inform user
WHIP_TITLE="Logging System Change"
WHIP_QUESTION="$OPTION has been selected:\n- Your choice will be applied when >> Go Start Install << 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'
OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Choose where to store your user/personal data. User/personal data includes software such as Owncloud data, BitTorrent downloads etc. Your fileserver choice (eg: samba, proftp) will also point to this location.\n\nNB: Changes will only affect NEW software that you install with DietPi-Software. Existing software will use the previous location.\n\n > Auto $user_data_auto_location\nIf a dedicated USB drive was setup on this system, DietPi will use that device. If not, Flash Storage will be used.\n\n> Manual\nInput a custom directory that will be used for your user/personal data." --cancel-button "Back" --default-item "$index_fileserver_text" 22 75 2 \
"Auto" "Default (recommended)." \
"Manual" "Input a custom directory." 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
if [ "$OPTION" = "Auto" ]; then
sed -i "/^dietpi_userdata_basedirectory=/c\dietpi_userdata_basedirectory=Auto" /DietPi/dietpi.txt
elif [ "$OPTION" = "Manual" ]; then
local default_item=$user_data_path
if [ "$default_item" = "Auto" ]; then
default_item=""
fi
OPTION=$(whiptail --inputbox "Please input a location. Your user/personal data will be stored inside this location.\n - eg: /mnt/MyDrive/MyData" 11 60 "$default_item" --title "User/Personal Data Directory" --backtitle "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3)
CHOICE=$?
if (( $CHOICE == 0 )); then
local path_valid=0
#Check for / at start of value
if [ "${OPTION:0:1}" = "/" ]; then
# - Generate dir, check for valid.
mkdir -p "$OPTION"
if [ -d "$OPTION" ]; then
path_valid=1
sed -i "/^dietpi_userdata_basedirectory=/c\dietpi_userdata_basedirectory=$OPTION" /DietPi/dietpi.txt
fi
fi
# - Invalid path
if (( $path_valid == 0 )); then
whiptail --title "Error: Invalid Path" --msgbox "Unable to create directory:\n - $OPTION\n\nNo changes have been applied." 11 60
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-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")
#Launch DietPi-config
/DietPi/dietpi/dietpi-config
;;
"Help!")
whiptail --title "DietPi - Help" --msgbox "Welcome to DietPi.\n\nEasy to follow, step by step guides for installing DietPi:\nhttp://dietpi.com/phpbb/viewtopic.php?f=8&t=9\n\nFor a list of all installation options and their details:\nhttp://dietpi.com/software" --backtitle "$WHIP_BACKTITLE" 16 75
;;
Go)
Menu_StartInstall
;;
esac
#Exit/Abort Setup
else
Menu_Exit
fi
}
Menu_Exit(){
#1st run install
if (( $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
else
#Return to Main Menu
TARGETMENUID=0
fi
#Standard exit
elif (( $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
else
#Return to Main Menu
TARGETMENUID=0
fi
fi
}
Menu_ConfirmInstall(){
##create temp file with list of software selected for install.
#Write_InstallFileList 1
##Load data into a 1 line string
#local string_output=$(cat /tmp/dietpi-software_selected | grep -m1 ' 1' | sed 's/ 1//g' | paste -s -d' ')
#rm /tmp/dietpi-software_selected
#Leave this until we have a SQL database to read the list from.
#Confirm Software install
WHIP_TITLE='DietPi - Start Installation?'
WHIP_QUESTION="DietPi is now ready to install your software choices.\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" 13 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" = false ] &&
[ "$INSTALL_LINUX_CHOICESMADE" = false ] &&
[ "$INSTALL_SSHSERVER_CHOICESMADE" = false ] &&
[ "$INSTALL_FILESERVER_CHOICESMADE" = false ] &&
[ "$INSTALL_LOGGING_CHOICESMADE" = false ]; then
#1st run install
if (( $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 (( $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
# Confirm install with user
else
Menu_ConfirmInstall
fi
}
#TARGETMENUID=1
Menu_Dietpi_Software(){
#Reset Choices made flag
INSTALL_DIETPI_CHOICESMADE=false
#Obtain On/Off state for whiptail menu
local grasshopper_w="off"
if (( $GRASSHOPPER > 0 )); then
grasshopper_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $GRASSHOPPER == 1 )); then
GRASSHOPPER=0
fi
fi
local emoncms_w="off"
if (( $EMONCMS > 0 )); then
emoncms_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $EMONCMS == 1 )); then
EMONCMS=0
fi
fi
local emonhub_w="off"
if (( $EMONHUB > 0 )); then
emonhub_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $EMONHUB == 1 )); then
EMONHUB=0
fi
fi
local desktop_w="off"
if (( $DESKTOP_LXDE > 0 )); then
desktop_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $DESKTOP_LXDE == 1 )); then
DESKTOP_LXDE=0
fi
fi
local transmission_w="off"
if (( $TRANSMISSION > 0 )); then
transmission_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $TRANSMISSION == 1 )); then
TRANSMISSION=0
fi
fi
local openbazaar_w="off"
if (( $OPENBAZAAR > 0 )); then
openbazaar_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $OPENBAZAAR == 1 )); then
OPENBAZAAR=0
fi
fi
local owncloud_w="off"
if (( $OWNCLOUD > 0 )); then
owncloud_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $OWNCLOUD == 1 )); then
OWNCLOUD=0
fi
fi
local phpbb_w="off"
if (( $PHPBB > 0 )); then
phpbb_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $PHPBB == 1 )); then
PHPBB=0
fi
fi
local webserver_lamp_w="off"
if (( $WEBSERVER_LAMP > 0 )); then
webserver_lamp_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_LAMP == 1 )); then
WEBSERVER_LAMP=0
fi
fi
local webserver_lasp_w="off"
if (( $WEBSERVER_LASP > 0 )); then
webserver_lasp_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_LASP == 1 )); then
WEBSERVER_LASP=0
fi
fi
local webserver_laap_w="off"
if (( $WEBSERVER_LAAP > 0 )); then
webserver_laap_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_LAAP == 1 )); then
WEBSERVER_LAAP=0
fi
fi
local webserver_lemp_w="off"
if (( $WEBSERVER_LEMP > 0 )); then
webserver_lemp_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_LEMP == 1 )); then
WEBSERVER_LEMP=0
fi
fi
local webserver_lesp_w="off"
if (( $WEBSERVER_LESP > 0 )); then
webserver_lesp_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_LESP == 1 )); then
WEBSERVER_LESP=0
fi
fi
local webserver_leap_w="off"
if (( $WEBSERVER_LEAP > 0 )); then
webserver_leap_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_LEAP == 1 )); then
WEBSERVER_LEAP=0
fi
fi
local webserver_llmp_w="off"
if (( $WEBSERVER_LLMP > 0 )); then
webserver_llmp_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_LLMP == 1 )); then
WEBSERVER_LLMP=0
fi
fi
local webserver_llsp_w="off"
if (( $WEBSERVER_LLSP > 0 )); then
webserver_llsp_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_LLSP == 1 )); then
WEBSERVER_LLSP=0
fi
fi
local webserver_llap_w="off"
if (( $WEBSERVER_LLAP > 0 )); then
webserver_llap_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_LLAP == 1 )); then
WEBSERVER_LLAP=0
fi
fi
local webserver_phpmyadmin_w="off"
if (( $WEBSERVER_MYADMINPHP > 0 )); then
webserver_phpmyadmin_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_MYADMINPHP == 1 )); then
WEBSERVER_MYADMINPHP=0
fi
fi
local webserver_redis_w="off"
if (( $WEBSERVER_REDIS > 0 )); then
webserver_redis_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBSERVER_REDIS == 1 )); then
WEBSERVER_REDIS=0
fi
fi
local fileserver_proftp_w="off"
if (( $FILESERVER_PROFTP > 0 )); then
fileserver_proftp_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $FILESERVER_PROFTP == 1 )); then
FILESERVER_PROFTP=0
fi
fi
local fileserver_samba_w="off"
if (( $FILESERVER_SAMBA > 0 )); then
fileserver_samba_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $FILESERVER_SAMBA == 1 )); then
FILESERVER_SAMBA=0
fi
fi
local fileserver_vsftpd_w="off"
if (( $FILESERVER_VSFTPD > 0 )); then
fileserver_vsftpd_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $FILESERVER_VSFTPD == 1 )); then
FILESERVER_VSFTPD=0
fi
fi
local hifi_w="off"
if (( $HIFI > 0 )); then
hifi_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $HIFI == 1 )); then
HIFI=0
fi
fi
local kodi_w="off"
if (( $KODI > 0 )); then
kodi_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $KODI == 1 )); then
KODI=0
fi
fi
local minidlna_w="off"
if (( $MINIDLNA > 0 )); then
minidlna_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $MINIDLNA == 1 )); then
MINIDLNA=0
fi
fi
local noipdyndns_w="off"
if (( $NOIPDYNDNS > 0 )); then
noipdyndns_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $NOIPDYNDNS == 1 )); then
NOIPDYNDNS=0
fi
fi
local opentyrian_w="off"
if (( $OPENTYRIAN > 0 )); then
opentyrian_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $OPENTYRIAN == 1 )); then
OPENTYRIAN=0
fi
fi
local dietpicam_w="off"
if (( $DIETPICAM > 0 )); then
dietpicam_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $DIETPICAM == 1 )); then
DIETPICAM=0
fi
fi
local deluge_w="off"
if (( $DELUGE > 0 )); then
deluge_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $DELUGE == 1 )); then
DELUGE=0
fi
fi
local raspcontrol_w="off"
if (( $RASPCONTROL > 0 )); then
raspcontrol_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $RASPCONTROL == 1 )); then
RASPCONTROL=0
fi
fi
local linuxdash_w="off"
if (( $LINUXDASH > 0 )); then
linuxdash_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $LINUXDASH == 1 )); then
LINUXDASH=0
fi
fi
local pihole_w="off"
if (( $PIHOLE > 0 )); then
pihole_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $PIHOLE == 1 )); then
PIHOLE=0
fi
fi
local subsonic_w="off"
if (( $SUBSONIC > 0 )); then
subsonic_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $SUBSONIC == 1 )); then
SUBSONIC=0
fi
fi
local webiopi_w="off"
if (( $WEBIOPI > 0 )); then
webiopi_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEBIOPI == 1 )); then
WEBIOPI=0
fi
fi
local weaved_w="off"
if (( $WEAVED > 0 )); then
weaved_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WEAVED == 1 )); then
WEAVED=0
fi
fi
local dietpicloudshell_w="off"
if (( $DIETPICLOUDSHELL > 0 )); then
dietpicloudshell_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $DIETPICLOUDSHELL == 1 )); then
DIETPICLOUDSHELL=0
fi
fi
local haproxy_w="off"
if (( $HAPROXY > 0 )); then
haproxy_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $HAPROXY == 1 )); then
HAPROXY=0
fi
fi
local squeezeboxserver_w="off"
if (( $SQUEEZEBOXSERVER > 0 )); then
squeezeboxserver_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $SQUEEZEBOXSERVER == 1 )); then
SQUEEZEBOXSERVER=0
fi
fi
local wordpress_w="off"
if (( $WORDPRESS > 0 )); then
wordpress_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WORDPRESS == 1 )); then
WORDPRESS=0
fi
fi
local tightvncserver_w="off"
if (( $TIGHTVNCSERVER > 0 )); then
tightvncserver_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $TIGHTVNCSERVER == 1 )); then
TIGHTVNCSERVER=0
fi
fi
local fail2ban_w="off"
if (( $FAIL2BAN > 0 )); then
fail2ban_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $FAIL2BAN == 1 )); then
FAIL2BAN=0
fi
fi
local phpsysinfo_w="off"
if (( $PHPSYSINFO > 0 )); then
phpsysinfo_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $PHPSYSINFO == 1 )); then
PHPSYSINFO=0
fi
fi
local phpimagegallery_w="off"
if (( $PHPIMAGEGALLERY > 0 )); then
phpimagegallery_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $PHPIMAGEGALLERY == 1 )); then
PHPIMAGEGALLERY=0
fi
fi
local ampache_w="off"
if (( $AMPACHE > 0 )); then
ampache_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $AMPACHE == 1 )); then
AMPACHE=0
fi
fi
local openvpnserver_w="off"
if (( $OPENVPNSERVER > 0 )); then
openvpnserver_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $OPENVPNSERVER == 1 )); then
OPENVPNSERVER=0
fi
fi
local letsencrypt_w="off"
if (( $LETSENCRYPT > 0 )); then
letsencrypt_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $LETSENCRYPT == 1 )); then
LETSENCRYPT=0
fi
fi
local wiringpi_w="off"
if (( $WIRINGPI > 0 )); then
wiringpi_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WIRINGPI == 1 )); then
WIRINGPI=0
fi
fi
local rpigpio_w="off"
if (( $RPIGPIO > 0 )); then
rpigpio_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $RPIGPIO == 1 )); then
RPIGPIO=0
fi
fi
local rpii2c_w="off"
if (( $RPII2C > 0 )); then
rpii2c_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $RPII2C == 1 )); then
RPII2C=0
fi
fi
local wifihotspot_w="off"
if (( $WIFIHOTSPOT > 0 )); then
wifihotspot_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $WIFIHOTSPOT == 1 )); then
WIFIHOTSPOT=0
fi
fi
local torhotspot_w="off"
if (( $TORHOTSPOT > 0 )); then
torhotspot_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $TORHOTSPOT == 1 )); then
TORHOTSPOT=0
fi
fi
local shairportsync_w="off"
if (( $SHAIRPORTSYNC > 0 )); then
shairportsync_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $SHAIRPORTSYNC == 1 )); then
SHAIRPORTSYNC=0
fi
fi
local brutefir_w="off"
if (( $BRUTEFIR > 0 )); then
brutefir_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $BRUTEFIR == 1 )); then
BRUTEFIR=0
fi
fi
local pydio_w="off"
if (( $PYDIO > 0 )); then
pydio_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $PYDIO == 1 )); then
PYDIO=0
fi
fi
local squeezelite_w="off"
if (( $SQUEEZELITE > 0 )); then
squeezelite_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $SQUEEZELITE == 1 )); then
SQUEEZELITE=0
fi
fi
#RPIMONITOR
local rpimonitor_w="off"
if (( $RPIMONITOR > 0 )); then
rpimonitor_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $RPIMONITOR == 1 )); then
RPIMONITOR=0
fi
fi
#BAIKAL
local baikal_w="off"
if (( $BAIKAL > 0 )); then
baikal_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $BAIKAL == 1 )); then
BAIKAL=0
fi
fi
#NETDATA
local netdata_w="off"
if (( $NETDATA > 0 )); then
netdata_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $NETDATA == 1 )); then
NETDATA=0
fi
fi
#MUMBLESERVER
local mumbleserver_w="off"
if (( $MUMBLESERVER > 0 )); then
mumbleserver_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $MUMBLESERVER == 1 )); then
MUMBLESERVER=0
fi
fi
#-----------------------------------------------------------------------------
WHIP_TITLE='DietPi Optimized Software Selection'
#-----------------------------------------------------------------------------
#OrangePi Software Installation
if (( $HW_MODEL == 30 )); then
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" 20 78 12 \
"" "────Desktops────────────────────────────────" "off" \
"LXDE: Desktop" "Ultra lightweight desktop." $desktop_w \
"LXDE: VNC Server" "LXDE Desktop for remote connection." $tightvncserver_w \
"" "────Media Systems───────────────────────────" "off" \
"HiFi" "Web interface music / radio player." $hifi_w \
"MiniDLNA" "Media streaming server (DLNA, UPnP)." $minidlna_w \
"SubSonic" "Web interface media streaming server." $subsonic_w \
"Ampache" "Web interface media streaming server." $ampache_w \
"Shairport Sync" "AirPlay audio player with multiroom sync" $shairportsync_w \
"Murmur" "Mumble VoIP server." $mumbleserver_w \
"" "────BitTorrent──────────────────────────────" "off" \
"Transmission" "BitTorrent server with web interface." $transmission_w \
"Deluge" "BitTorrent server with web interface." $deluge_w \
"" "────Cloud / Backups─────────────────────────" "off" \
"OpenBazaar" "Your very own store (eg: ebay)." $openbazaar_w \
"OwnCloud" "Your very own cloud (eg: dropbox)." $owncloud_w \
"Pydio" "Feature-rich backup and sync server" $pydio_w \
"" "────Social Media───────────────────────────" "off" \
"Forums" "Your very own website forums (Phpbb3)." $phpbb_w \
"Wordpress" "Website Blog and Publishing platform." $wordpress_w \
"Image Gallery" "Website to host / browse your images." $phpimagegallery_w \
"BaiKal" "Lightweight CalDAV + CardDAV server." $baikal_w \
"" "────Remote Access───────────────────────────" "off" \
"Weaved" "Access your device over the internet." $weaved_w \
"" "────System Stats / Management──────────────" "off" \
"DietPi-Cloudshell" "System stats for your LCD display or monitor." $dietpicloudshell_w \
"LinuxDash" "Web interface system stats." $linuxdash_w \
"PhpSysInfo" "Web interface system stats." $phpsysinfo_w \
"netdata" "real-time performance monitoring" $netdata_w \
"" "────System Security────────────────────────" "off" \
"Fail2Ban" "Prevents brute-force attacks with IP ban." $fail2ban_w \
"" "────Webserver Stacks───────────────────────" "off" \
"LAMP" "Webserver: Apache2 | MySql | Php." $webserver_lamp_w \
"LASP" "Webserver: Apache2 | SQLite | Php." $webserver_lasp_w \
"LAAP" "Webserver: Apache2 | MariaDB | Php." $webserver_laap_w \
"LEMP" "Webserver: Nginx | MySql | Php." $webserver_lemp_w \
"LESP" "Webserver: Nginx | SQLite | Php." $webserver_lesp_w \
"LEAP" "Webserver: Nginx | MariaDB | Php." $webserver_leap_w \
"LLMP" "Webserver: Lighttpd | MySql | Php." $webserver_llmp_w \
"LLSP" "Webserver: Lighttpd | SQLite | Php." $webserver_llsp_w \
"LLAP" "Webserver: Lighttpd | MariaDB | Php." $webserver_llap_w \
"phpMyAdmin" "Optional MySql admin tools." $webserver_phpmyadmin_w \
"LetsEncrypt" "Free, auto SSL cert install allowing https://" $letsencrypt_w \
"" "────DNS Servers────────────────────────────" "off" \
"Pi-hole" "Block adverts for any device on your network." $pihole_w \
"" "────File Servers───────────────────────────" "off" \
"ProFTP" "Lightweight FTP / file server." $fileserver_proftp_w \
"vsFTPD" "Alternative FTP / file server." $fileserver_vsftpd_w \
"Samba" "Feature-rich file server." $fileserver_samba_w \
"" "────VPN Servers────────────────────────────" "off" \
"OpenVPN" "VPN server." $openvpnserver_w \
"" "────Network Load Balancing─────────────────" "off" \
"HaProxy" "High performance TCP/HTTP load balancer." $haproxy_w \
"" "────Website URLs───────────────────────────" "off" \
"NoIp" "URL website address for your device." $noipdyndns_w 2>/tmp/dietpi-software_results
#-----------------------------------------------------------------------------
#VM Software Installation
elif (( $HW_MODEL == 20 )); then
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" 20 78 12 \
"" "────Desktops───────────────────────────────" "off" \
"LXDE: Desktop" "Ultra lightweight desktop." $desktop_w \
"LXDE: VNC Server" "LXDE Desktop for remote connection." $tightvncserver_w \
"" "────Media Systems──────────────────────────" "off" \
"MiniDLNA" "Media streaming server (DLNA, UPnP)." $minidlna_w \
"SubSonic" "Web interface media streaming server." $subsonic_w \
"Ampache" "Web interface media streaming server." $ampache_w \
"Murmur" "Mumble VoIP server." $mumbleserver_w \
"" "────BitTorrent─────────────────────────────" "off" \
"Transmission" "BitTorrent server with web interface." $transmission_w \
"Deluge" "BitTorrent server with web interface." $deluge_w \
"" "────Cloud / Backups────────────────────────" "off" \
"OpenBazaar" "Your very own store (eg: ebay)." $openbazaar_w \
"OwnCloud" "Your very own cloud (eg: dropbox)." $owncloud_w \
"Pydio" "Feature-rich backup and sync server" $pydio_w \
"" "────Social Media───────────────────────────" "off" \
"Forums" "Your very own website forums (Phpbb3)." $phpbb_w \
"Wordpress" "Website Blog and Publishing platform." $wordpress_w \
"Image Gallery" "Website to host / browse your images." $phpimagegallery_w \
"BaiKal" "Lightweight CalDAV + CardDAV server." $baikal_w \
"" "────System Stats / Management──────────────" "off" \
"DietPi-Cloudshell" "System stats for your LCD display or monitor." $dietpicloudshell_w \
"LinuxDash" "Web interface system stats." $linuxdash_w \
"PhpSysInfo" "Web interface system stats." $phpsysinfo_w \
"" "────System Security────────────────────────" "off" \
"Fail2Ban" "Prevents brute-force attacks with IP ban." $fail2ban_w \
"" "────Webserver Stacks───────────────────────" "off" \
"LAMP" "Webserver: Apache2 | MySql | Php." $webserver_lamp_w \
"LASP" "Webserver: Apache2 | SQLite | Php." $webserver_lasp_w \
"LAAP" "Webserver: Apache2 | MariaDB | Php." $webserver_laap_w \
"LEMP" "Webserver: Nginx | MySql | Php." $webserver_lemp_w \
"LESP" "Webserver: Nginx | SQLite | Php." $webserver_lesp_w \
"LEAP" "Webserver: Nginx | MariaDB | Php." $webserver_leap_w \
"LLMP" "Webserver: Lighttpd | MySql | Php." $webserver_llmp_w \
"LLSP" "Webserver: Lighttpd | SQLite | Php." $webserver_llsp_w \
"LLAP" "Webserver: Lighttpd | MariaDB | Php." $webserver_llap_w \
"phpMyAdmin" "Optional MySql admin tools." $webserver_phpmyadmin_w \
"LetsEncrypt" "Free, auto SSL cert install allowing https://" $letsencrypt_w \
"" "────DNS Servers────────────────────────────" "off" \
"Pi-hole" "Block adverts for any device on your network." $pihole_w \
"" "────File Servers───────────────────────────" "off" \
"ProFTP" "Lightweight FTP / file server." $fileserver_proftp_w \
"vsFTPD" "Alternative FTP / file server." $fileserver_vsftpd_w \
"Samba" "Feature-rich file server." $fileserver_samba_w \
"" "────VPN Servers────────────────────────────" "off" \
"OpenVPN" "VPN server." $openvpnserver_w \
"" "────Network Load Balancing─────────────────" "off" \
"HaProxy" "High performance TCP/HTTP load balancer." $haproxy_w \
"" "────Website URLs───────────────────────────" "off" \
"NoIp" "URL website address for your device." $noipdyndns_w 2>/tmp/dietpi-software_results
#-----------------------------------------------------------------------------
#Odroid XU4 + C1/C2 Software Installation
elif (( $HW_MODEL >= 10 )) && (( $HW_MODEL < 20 )); then
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" 20 78 12 \
"" "────Desktops────────────────────────────────" "off" \
"LXDE: Desktop" "Ultra lightweight desktop." $desktop_w \
"LXDE: VNC Server" "LXDE Desktop for remote connection." $tightvncserver_w \
"" "────Media Systems───────────────────────────" "off" \
"Kodi" "Your very own media centre / player." $kodi_w \
"MiniDLNA" "Media streaming server (DLNA, UPnP)." $minidlna_w \
"SubSonic" "Web interface media streaming server." $subsonic_w \
"Ampache" "Web interface media streaming server." $ampache_w \
"Shairport Sync" "AirPlay audio player with multiroom sync" $shairportsync_w \
"Murmur" "Mumble VoIP server." $mumbleserver_w \
"" "────BitTorrent──────────────────────────────" "off" \
"Transmission" "BitTorrent server with web interface." $transmission_w \
"Deluge" "BitTorrent server with web interface." $deluge_w \
"" "────Cloud / Backups─────────────────────────" "off" \
"OpenBazaar" "Your very own store (eg: ebay)." $openbazaar_w \
"OwnCloud" "Your very own cloud (eg: dropbox)." $owncloud_w \
"Pydio" "Feature-rich backup and sync server" $pydio_w \
"" "────Social Media───────────────────────────" "off" \
"Forums" "Your very own website forums (Phpbb3)." $phpbb_w \
"Wordpress" "Website Blog and Publishing platform." $wordpress_w \
"Image Gallery" "Website to host / browse your images." $phpimagegallery_w \
"BaiKal" "Lightweight CalDAV + CardDAV server." $baikal_w \
"" "────WiFi Hotspot────────────────────────────" "off" \
"WiFi Hotspot" "Turn your device into a WiFi hotspot." $wifihotspot_w \
"Tor Hotspot" "Optional: Route HotSpot traffic through Tor." $torhotspot_w \
"" "────Remote Access───────────────────────────" "off" \
"Weaved" "Access your device over the internet." $weaved_w \
"" "────System Stats / Management──────────────" "off" \
"DietPi-Cloudshell" "System stats for your LCD display or monitor." $dietpicloudshell_w \
"LinuxDash" "Web interface system stats." $linuxdash_w \
"PhpSysInfo" "Web interface system stats." $phpsysinfo_w \
"netdata" "real-time performance monitoring" $netdata_w \
"" "────System Security────────────────────────" "off" \
"Fail2Ban" "Prevents brute-force attacks with IP ban." $fail2ban_w \
"" "────Webserver Stacks───────────────────────" "off" \
"LAMP" "Webserver: Apache2 | MySql | Php." $webserver_lamp_w \
"LASP" "Webserver: Apache2 | SQLite | Php." $webserver_lasp_w \
"LAAP" "Webserver: Apache2 | MariaDB | Php." $webserver_laap_w \
"LEMP" "Webserver: Nginx | MySql | Php." $webserver_lemp_w \
"LESP" "Webserver: Nginx | SQLite | Php." $webserver_lesp_w \
"LEAP" "Webserver: Nginx | MariaDB | Php." $webserver_leap_w \
"LLMP" "Webserver: Lighttpd | MySql | Php." $webserver_llmp_w \
"LLSP" "Webserver: Lighttpd | SQLite | Php." $webserver_llsp_w \
"LLAP" "Webserver: Lighttpd | MariaDB | Php." $webserver_llap_w \
"phpMyAdmin" "Optional MySql admin tools." $webserver_phpmyadmin_w \
"LetsEncrypt" "Free, auto SSL cert install allowing https://" $letsencrypt_w \
"" "────DNS Servers────────────────────────────" "off" \
"Pi-hole" "Block adverts for any device on your network." $pihole_w \
"" "────File Servers───────────────────────────" "off" \
"ProFTP" "Lightweight FTP / file server." $fileserver_proftp_w \
"vsFTPD" "Alternative FTP / file server." $fileserver_vsftpd_w \
"Samba" "Feature-rich file server." $fileserver_samba_w \
"" "────VPN Servers────────────────────────────" "off" \
"OpenVPN" "VPN server." $openvpnserver_w \
"" "────Network Load Balancing─────────────────" "off" \
"HaProxy" "High performance TCP/HTTP load balancer." $haproxy_w \
"" "────Website URLs───────────────────────────" "off" \
"NoIp" "URL website address for your device." $noipdyndns_w 2>/tmp/dietpi-software_results
#-----------------------------------------------------------------------------
#Rpi Software Installation
elif (( $HW_MODEL < 10 )); then
#Jessie
if (( $DISTRO == 3 )); then
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" 20 78 12 \
"" "────Desktops────────────────────────────────" "off" \
"LXDE: Desktop" "Ultra lightweight desktop." $desktop_w \
"LXDE: VNC Server" "LXDE Desktop for remote connection." $tightvncserver_w \
"" "────Media Systems───────────────────────────" "off" \
"Kodi" "Your very own media centre / player." $kodi_w \
"HiFi" "Web interface music / radio player." $hifi_w \
"MiniDLNA" "Media streaming server (DLNA, UPnP)." $minidlna_w \
"SubSonic" "Web interface media streaming server." $subsonic_w \
"SqueezeBox" "Logitech Media Server (LMS)." $squeezeboxserver_w \
"SqueezeLite" "Audio player for LMS" $squeezelite_w \
"Ampache" "Web interface media streaming server." $ampache_w \
"Shairport Sync" "AirPlay audio player with multiroom sync" $shairportsync_w \
"BruteFIR" "EQ and Digital Room Correction via ALSA." $brutefir_w \
"Murmur" "Mumble VoIP server." $mumbleserver_w \
"" "────BitTorrent──────────────────────────────" "off" \
"Transmission" "BitTorrent server with web interface." $transmission_w \
"Deluge" "BitTorrent server with web interface." $deluge_w \
"" "────Cloud / Backups─────────────────────────" "off" \
"OpenBazaar" "Your very own store (eg: ebay)." $openbazaar_w \
"OwnCloud" "Your very own cloud (eg: dropbox)." $owncloud_w \
"Pydio" "Feature-rich backup and sync server" $pydio_w \
"" "────Gaming──────────────────────────────────" "off" \
"OpenTyrian" "Gaming: A classic retro game, addictive." $opentyrian_w \
"" "────Social Media───────────────────────────" "off" \
"Forums" "Your very own website forums (Phpbb3)." $phpbb_w \
"Wordpress" "Website Blog and Publishing platform." $wordpress_w \
"Image Gallery" "Website to host / browse your images." $phpimagegallery_w \
"BaiKal" "Lightweight CalDAV + CardDAV server." $baikal_w \
"" "────Camera / Surveillance───────────────────" "off" \
"DietPi Cam" "RPi Cam Control / Web Interface Surveillance." $dietpicam_w \
"" "────WiFi Hotspot────────────────────────────" "off" \
"WiFi Hotspot" "Turn your device into a WiFi hotspot." $wifihotspot_w \
"Tor Hotspot" "Optional: Route HotSpot traffic through Tor." $torhotspot_w \
"" "────Home Automation─────────────────────────" "off" \
"EmonPi" "Energy usage addon board with web interface." $emonhub_w \
"Grasshopper" "Web App to control Bticino MyHome." $grasshopper_w \
"" "────RPi Hardware Projects───────────────────" "off" \
"RPi.GPIO" "GPIO Interface library for RPi (python)." $rpigpio_w \
"WiringPi" "GPIO Interface library for RPi (c)." $wiringpi_w \
"WebIOPi" "Web interface to control RPi.GPIO." $webiopi_w \
"I2c" "Enables support for I2c based hardware." $rpii2c_w \
"" "────Remote Access───────────────────────────" "off" \
"Weaved" "Access your device over the internet." $weaved_w \
"" "────System Stats / Management──────────────" "off" \
"DietPi-Cloudshell" "System stats for your LCD display or monitor." $dietpicloudshell_w \
"LinuxDash" "Web interface system stats." $linuxdash_w \
"PhpSysInfo" "Web interface system stats." $phpsysinfo_w \
"netdata" "real-time performance monitoring" $netdata_w \
"RPi-Monitor" "Web interface system stats." $rpimonitor_w \
"" "────System Security────────────────────────" "off" \
"Fail2Ban" "Prevents brute-force attacks with IP ban." $fail2ban_w \
"" "────Webserver Stacks───────────────────────" "off" \
"LAMP" "Webserver: Apache2 | MySql | Php." $webserver_lamp_w \
"LASP" "Webserver: Apache2 | SQLite | Php." $webserver_lasp_w \
"LAAP" "Webserver: Apache2 | MariaDB | Php." $webserver_laap_w \
"LEMP" "Webserver: Nginx | MySql | Php." $webserver_lemp_w \
"LESP" "Webserver: Nginx | SQLite | Php." $webserver_lesp_w \
"LEAP" "Webserver: Nginx | MariaDB | Php." $webserver_leap_w \
"LLMP" "Webserver: Lighttpd | MySql | Php." $webserver_llmp_w \
"LLSP" "Webserver: Lighttpd | SQLite | Php." $webserver_llsp_w \
"LLAP" "Webserver: Lighttpd | MariaDB | Php." $webserver_llap_w \
"phpMyAdmin" "Optional MySql admin tools." $webserver_phpmyadmin_w \
"Redis" "Optional non-SQL database store." $webserver_redis_w \
"LetsEncrypt" "Free, auto SSL cert install allowing https://" $letsencrypt_w \
"" "────DNS Servers────────────────────────────" "off" \
"Pi-hole" "Block adverts for any device on your network." $pihole_w \
"" "────File Servers───────────────────────────" "off" \
"ProFTP" "Lightweight FTP / file server." $fileserver_proftp_w \
"vsFTPD" "Alternative FTP / file server." $fileserver_vsftpd_w \
"Samba" "Feature-rich file server." $fileserver_samba_w \
"" "────VPN Servers────────────────────────────" "off" \
"OpenVPN" "VPN server." $openvpnserver_w \
"" "────Network Load Balancing─────────────────" "off" \
"HaProxy" "High performance TCP/HTTP load balancer." $haproxy_w \
"" "────Website URLs───────────────────────────" "off" \
"NoIp" "URL website address for your device." $noipdyndns_w 2>/tmp/dietpi-software_results
#Wheezy
elif (( $DISTRO == 1 )); then
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" 20 78 12 \
"" "────Desktops────────────────────────────────" "off" \
"LXDE: Desktop" "Ultra lightweight desktop." $desktop_w \
"LXDE: VNC Server" "LXDE Desktop for remote connection." $tightvncserver_w \
"" "────Media Systems───────────────────────────" "off" \
"Kodi" "Your very own media centre / player." $kodi_w \
"HiFi" "Web interface music / radio player." $hifi_w \
"MiniDLNA" "Media streaming server (DLNA, UPnP)." $minidlna_w \
"SubSonic" "Web interface media streaming server." $subsonic_w \
"SqueezeBox" "Logitech Media Server (LMS)." $squeezeboxserver_w \
"Ampache" "Web interface media streaming server." $ampache_w \
"" "────BitTorrent──────────────────────────────" "off" \
"Transmission" "BitTorrent server with web interface." $transmission_w \
"Deluge" "BitTorrent server with web interface." $deluge_w \
"" "────Gaming──────────────────────────────────" "off" \
"OpenTyrian" "Gaming: A classic retro game, addictive." $opentyrian_w \
"" "────Cloud / Backups─────────────────────────" "off" \
"OpenBazaar" "Your very own store (eg: ebay)." $openbazaar_w \
"OwnCloud" "Your very own cloud (eg: dropbox)." $owncloud_w \
"" "────Social Media───────────────────────────" "off" \
"Forums" "Your very own website forums (Phpbb3)." $phpbb_w \
"Wordpress" "Website Blog and Publishing platform." $wordpress_w \
"Image Gallery" "Website to host / browse your images." $phpimagegallery_w \
"" "────Camera / Surveillance───────────────────" "off" \
"DietPi Cam" "RPi Cam Control / Web Interface Surveillance." $dietpicam_w \
"" "────WiFi Hotspot────────────────────────────" "off" \
"WiFi Hotspot" "Turn your device into a WiFi hotspot." $wifihotspot_w \
"" "────Home Automation─────────────────────────" "off" \
"Grasshopper" "Web App to control Bticino MyHome." $grasshopper_w \
"" "────RPi Hardware Projects───────────────────" "off" \
"RPi.GPIO" "GPIO Interface library for RPi (python)." $rpigpio_w \
"WiringPi" "GPIO Interface library for RPi (c)." $wiringpi_w \
"WebIOPi" "Web interface to control RPi.GPIO." $webiopi_w \
"I2c" "Enables support for I2c based hardware." $rpii2c_w \
"" "────Remote Access──────────────────────────" "off" \
"Weaved" "Access your device over the internet." $weaved_w \
"" "────System Stats / Management──────────────" "off" \
"DietPi-Cloudshell" "System stats for your LCD display or monitor." $dietpicloudshell_w \
"Raspcontrol" "Web interface system stats." $raspcontrol_w \
"LinuxDash" "Web interface system stats." $linuxdash_w \
"PhpSysInfo" "Web interface system stats." $phpsysinfo_w \
"" "────System Security────────────────────────" "off" \
"Fail2Ban" "Prevents brute-force attacks with IP ban." $fail2ban_w \
"" "────Webserver Stacks───────────────────────" "off" \
"LAMP" "Webserver: Apache2 | MySql | Php." $webserver_lamp_w \
"LASP" "Webserver: Apache2 | SQLite | Php." $webserver_lasp_w \
"LEMP" "Webserver: Nginx | MySql | Php." $webserver_lemp_w \
"LESP" "Webserver: Nginx | SQLite | Php." $webserver_lesp_w \
"phpMyAdmin" "Optional MySql admin tools." $webserver_phpmyadmin_w \
"" "────DNS Servers────────────────────────────" "off" \
"Pi-hole" "Block adverts for any device on your network." $pihole_w \
"" "────File Servers───────────────────────────" "off" \
"ProFTP" "Lightweight FTP / file server." $fileserver_proftp_w \
"vsFTPD" "Alternative FTP / file server." $fileserver_vsftpd_w \
"Samba" "Feature-rich file server." $fileserver_samba_w \
"" "────VPN Servers────────────────────────────" "off" \
"OpenVPN" "VPN server." $openvpnserver_w \
"" "────Network Load Balancing─────────────────" "off" \
"HaProxy" "High performance TCP/HTTP load balancer." $haproxy_w \
"" "────Website URLs───────────────────────────" "off" \
"NoIp" "URL website address for your device." $noipdyndns_w 2>/tmp/dietpi-software_results
fi
fi
#disabled options
# "EmonCMS" "Web interface for Open Energy Monitor data" $emoncms_w \
while read choice
do
case $choice in
Murmur)
if (( $MUMBLESERVER == 0 )); then
MUMBLESERVER=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
"Tor Hotspot")
if (( $TORHOTSPOT == 0 )); then
TORHOTSPOT=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
BaiKal)
if (( $BAIKAL == 0 )); then
BAIKAL=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
"RPi-Monitor")
if (( $RPIMONITOR == 0 )); then
RPIMONITOR=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
EmonHUB|EmonPi)
if (( $EMONHUB == 0 )); then
EMONHUB=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
EmonCMS)
if (( $EMONCMS == 0 )); then
EMONCMS=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
Redis)
if (( $WEBSERVER_REDIS == 0 )); then
WEBSERVER_REDIS=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
SqueezeLite)
if (( $SQUEEZELITE == 0 )); then
SQUEEZELITE=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
Pydio)
if (( $PYDIO == 0 )); then
PYDIO=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
BruteFIR)
if (( $BRUTEFIR == 0 )); then
BRUTEFIR=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
"Shairport Sync")
if (( $SHAIRPORTSYNC == 0 )); then
SHAIRPORTSYNC=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
"WiFi Hotspot")
if (( $WIFIHOTSPOT == 0 )); then
WIFIHOTSPOT=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
RPi.GPIO)
if (( $RPIGPIO == 0 )); then
RPIGPIO=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
I2c)
if (( $RPII2C == 0 )); then
RPII2C=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
WiringPi)
if (( $WIRINGPI == 0 )); then
WIRINGPI=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LetsEncrypt)
if (( $LETSENCRYPT == 0 )); then
LETSENCRYPT=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
OpenVPN)
if (( $OPENVPNSERVER == 0 )); then
OPENVPNSERVER=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Ampache)
if (( $AMPACHE == 0 )); then
AMPACHE=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
"Image Gallery")
if (( $PHPIMAGEGALLERY == 0 )); then
PHPIMAGEGALLERY=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
PhpSysInfo)
if (( $PHPSYSINFO == 0 )); then
PHPSYSINFO=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Fail2Ban)
if (( $FAIL2BAN == 0 )); then
FAIL2BAN=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
"LXDE: VNC Server")
if (( $TIGHTVNCSERVER == 0 )); then
TIGHTVNCSERVER=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Wordpress)
if (( $WORDPRESS == 0 )); then
WORDPRESS=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
SqueezeBox)
if (( $SQUEEZEBOXSERVER == 0 )); then
SQUEEZEBOXSERVER=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
HaProxy)
if (( $HAPROXY == 0 )); then
HAPROXY=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
"DietPi-Cloudshell")
if (( $DIETPICLOUDSHELL == 0 )); then
DIETPICLOUDSHELL=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
WebIOPi)
if (( $WEBIOPI == 0 )); then
WEBIOPI=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Weaved)
if (( $WEAVED == 0 )); then
WEAVED=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
SubSonic)
if (( $SUBSONIC == 0 )); then
SUBSONIC=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
"Pi-hole")
if (( $PIHOLE == 0 )); then
PIHOLE=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Grasshopper)
if (( $GRASSHOPPER == 0 )); then
GRASSHOPPER=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LinuxDash)
if (( $LINUXDASH == 0 )); then
LINUXDASH=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
"LXDE: Desktop")
if (( $DESKTOP_LXDE == 0 )); then
DESKTOP_LXDE=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Kodi)
if (( $KODI == 0 )); then
KODI=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
OpenTyrian)
if (( $OPENTYRIAN == 0 )); then
OPENTYRIAN=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Transmission)
if (( $TRANSMISSION == 0 )); then
TRANSMISSION=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Deluge)
if (( $DELUGE == 0 )); then
DELUGE=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
OpenBazaar)
if (( $OPENBAZAAR == 0 )); then
OPENBAZAAR=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
OwnCloud)
if (( $OWNCLOUD == 0 )); then
OWNCLOUD=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
"DietPi Cam")
if (( $DIETPICAM == 0 )); then
DIETPICAM=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
MiniDLNA)
if (( $MINIDLNA == 0 )); then
MINIDLNA=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
HiFi)
if (( $HIFI == 0 )); then
HIFI=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Forums)
if (( $PHPBB == 0 )); then
PHPBB=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LAMP)
if (( $WEBSERVER_LAMP == 0 )); then
WEBSERVER_LAMP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LASP)
if (( $WEBSERVER_LASP == 0 )); then
WEBSERVER_LASP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LAAP)
if (( $WEBSERVER_LAAP == 0 )); then
WEBSERVER_LAAP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LEMP)
if (( $WEBSERVER_LEMP == 0 )); then
WEBSERVER_LEMP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LESP)
if (( $WEBSERVER_LESP == 0 )); then
WEBSERVER_LESP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LEAP)
if (( $WEBSERVER_LEAP == 0 )); then
WEBSERVER_LEAP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LLMP)
if (( $WEBSERVER_LLMP == 0 )); then
WEBSERVER_LLMP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LLSP)
if (( $WEBSERVER_LLSP == 0 )); then
WEBSERVER_LLSP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
LLAP)
if (( $WEBSERVER_LLAP == 0 )); then
WEBSERVER_LLAP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
phpMyAdmin)
if (( $WEBSERVER_MYADMINPHP == 0 )); then
WEBSERVER_MYADMINPHP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
ProFTP)
if (( $FILESERVER_PROFTP == 0 )); then
FILESERVER_PROFTP=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Samba)
if (( $FILESERVER_SAMBA == 0 )); then
FILESERVER_SAMBA=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
vsFTPD)
if (( $FILESERVER_VSFTPD == 0 )); then
FILESERVER_VSFTPD=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
NoIp)
if (( $NOIPDYNDNS == 0 )); then
NOIPDYNDNS=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
Raspcontrol)
if (( $RASPCONTROL == 0 )); then
RASPCONTROL=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
netdata)
if (( $NETDATA == 0 )); then
NETDATA=1
INSTALL_DIETPI_CHOICESMADE=true
fi
;;
esac
done < /tmp/dietpi-software_results
rm /tmp/dietpi-software_results &> /dev/null
#-----------------------------------------------------------------------------
#Install Info/Warnings
#Webserver stacks, please let DietPi install them for you...
# - == 1 to prevent installed stacks appearing
if (( $WEBSERVER_LAMP == 1 || $WEBSERVER_LASP == 1 || $WEBSERVER_LAAP == 1 ||
$WEBSERVER_LEMP == 1 || $WEBSERVER_LESP == 1 || $WEBSERVER_LEAP == 1 ||
$WEBSERVER_LLMP == 1 || $WEBSERVER_LLSP == 1 || $WEBSERVER_LLAP == 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
fi
#DietPiCam - warn user of locking out camera: https://github.com/Fourdee/DietPi/issues/249
if (( $DIETPICAM == 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 (( $EMONHUB == 1 )); then
# - Enter API KEY
# - Grab key from dietpi.txt
USER_EMONHUB_APIKEY_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_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 "/^dietpi_emonhub_apikey=/c\dietpi_emonhub_apikey=$USER_EMONHUB_APIKEY_CURRENT" /DietPi/dietpi.txt
USER_EMONHUB_APIKEY_COMPLETED=1
fi
fi
done
fi
#Pi-hole. prompt for static ip.
if (( $PIHOLE == 1 )); then
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 (( $WIFIHOTSPOT == 1 )) ||
(( $TORHOTSPOT == 1 )); then
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
WIFIHOTSPOT=0
TORHOTSPOT=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 (( $WEAVED == 1 )); then
WHIP_TITLE=' Weaved - 1st run setup'
WHIP_QUESTION='Weaved 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 (( $LETSENCRYPT == 1 )); then
WHIP_TITLE='Lets Encrypt Info'
WHIP_QUESTION='Currently, the DietPi installation of Lets Encrypt supports Apache2 (LAMP / LASP) 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 Lets Encrypt 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
#RPi
if (( $HW_MODEL < 10 )); then
#Wheezy
if (( $DISTRO == 1 )); then
#Give full credit to Micheal and his Repo.
if (( $KODI == 1 )); then
WHIP_TITLE=' Kodi - Thanks to Michael Groven'
WHIP_QUESTION=' DietPi uses the Kodi installation which is provided by Michael Grovens excellent Repository \n \n For more information and to thank Michael for his hard work, please goto http://michael.gorven.za.net/raspberrypi/xbmc'
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 14 70
fi
fi
fi
#-----------------------------------------------------------------------------
#dietpi-config can be used to install/configure the following software. Ask user.
#NoIp -
if (( $NOIPDYNDNS == 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 "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 15 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Launch DietPi-config
/DietPi/dietpi/dietpi-config 16 1
#DietPi-Config will change .installed file, so reload new value into var
. "$FP_INSTALLED_FILE"
fi
fi
#-----------------------------------------------------------------------------
#Installations that might require File server to access data.
#Lets inform the user of File Server option
local inform_user_fileserver=0
if (( $INDEX_FILESERVER_TARGET == 0 )); then
if (( $TRANSMISSION == 1 )); then
inform_user_fileserver=1
elif (( $DELUGE == 1 )); then
inform_user_fileserver=1
elif (( $MINIDLNA == 1 )); then
inform_user_fileserver=1
elif (( $HIFI == 1 )); then
inform_user_fileserver=1
elif (( $SQUEEZEBOXSERVER == 1 )); then
inform_user_fileserver=1
elif (( $SUBSONIC == 1 )); then
inform_user_fileserver=1
elif (( $AMPACHE == 1 )); then
inform_user_fileserver=1
fi
if (( $inform_user_fileserver == 1 )); then
WHIP_TITLE='File Server Recommended'
WHIP_QUESTION="Your installation choices may benefit from a File Server. This would allow you to access and transfer files on this DietPi system.\n\nWhen you return to the main menu, select:\n- File Server\n\nThis will allow you to see the complete list of available fileserver choices."
whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 16 70
fi
fi
#-----------------------------------------------------------------------------
#Boot Choices
local bootchoices_available=0
if (( $DESKTOP_LXDE == 1 )); then
bootchoices_available=1
elif (( $KODI == 1 )); then
bootchoices_available=1
elif (( $OPENTYRIAN == 1 )); then
bootchoices_available=1
elif (( $TIGHTVNCSERVER == 1 )); then
bootchoices_available=1
fi
if (( $bootchoices_available == 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
#Return to Main Menu
TARGETMENUID=0
}
#TARGETMENUID=2
Menu_Linux_Software(){
#Inform User that DietPi software will automatically install additional linux software when required.
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
#Reset Choices made flag
INSTALL_LINUX_CHOICESMADE=false
#Obtain On/Off state for whiptail menu
local vimfull_w="off"
if (( $VIMFULL > 0 )); then
vimfull_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $VIMFULL == 1 )); then
VIMFULL=0
fi
fi
local sshclient_w="off"
if (( $SSHCLIENT > 0 )); then
sshclient_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $SSHCLIENT == 1 )); then
SSHCLIENT=0
fi
fi
local smbclient_w="off"
if (( $SMBCLIENT > 0 )); then
smbclient_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $SMBCLIENT == 1 )); then
SMBCLIENT=0
fi
fi
local gitclient_w="off"
if (( $GITCLIENT > 0 )); then
gitclient_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $GITCLIENT == 1 )); then
GITCLIENT=0
fi
fi
local buildessential_w="off"
if (( $BUILDESSENTIAL > 0 )); then
buildessential_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $BUILDESSENTIAL == 1 )); then
BUILDESSENTIAL=0
fi
fi
local alsabase_w="off"
if (( $ALSABASE > 0 )); then
alsabase_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $ALSABASE == 1 )); then
ALSABASE=0
fi
fi
#XSERVERXORG
local xserverxorg_w="off"
if (( $XSERVERXORG > 0 )); then
xserverxorg_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $XSERVERXORG == 1 )); then
XSERVERXORG=0
fi
fi
#CURLFTPFS
local curlftpfs_w="off"
if (( $CURLFTPFS > 0 )); then
curlftpfs_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $CURLFTPFS == 1 )); then
CURLFTPFS=0
fi
fi
#FFMPEG
local ffmpeg_w="off"
if (( $FFMPEG > 0 )); then
ffmpeg_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $FFMPEG == 1 )); then
FFMPEG=0
fi
fi
#ORACLEJAVA
local oraclejava_w="off"
if (( $ORACLEJAVA > 0 )); then
oraclejava_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $ORACLEJAVA == 1 )); then
ORACLEJAVA=0
fi
fi
local nodejs_w="off"
if (( $NODEJS > 0 )); then
nodejs_w="on"
#Reset to 0. Menu checklists will apply back to 1
if (( $NODEJS == 1 )); then
NODEJS=0
fi
fi
WHIP_TITLE='Linux - Software Selection'
whiptail --title "$WHIP_TITLE" --checklist --separate-output "Press the spacebar to select additional software for installation." --backtitle "$WHIP_BACKTITLE" 19 71 12 \
"" "────SSH Clients──────────────────────────────" "off" \
"OpenSSH" "SSH Client: OpenSSH." $sshclient_w \
"" "────Fileserver Clients───────────────────────" "off" \
"Samba" "Samba Client: Access Network Shares." $smbclient_w \
"Curlftpfs" "FTP Client: Allows filesystem mount." $curlftpfs_w \
"" "────Development / Programming────────────────" "off" \
"Vim" "Text editor: Console." $vimfull_w \
"Build" "Build-Essentials." $buildessential_w \
"Git" "Git Client." $gitclient_w \
"" "────Shared Libraries──────────────────────────" "off" \
"FFmpeg" "Audio / Visual libary." $ffmpeg_w \
"Java" "Oracle Java 8 jdk/jre libary." $oraclejava_w \
"Node.js" "Javascript Runtime." $nodejs_w \
"" "────System───────────────────────────────────" "off" \
"ALSA" "Linux Sound System" $alsabase_w \
"Xserver" "Xinit / Xauth." $xserverxorg_w 2>/tmp/dietpi-software_results
while read choice
do
case $choice in
"Node.js")
if (( $NODEJS == 0 )); then
NODEJS=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
Java)
if (( $ORACLEJAVA == 0 )); then
ORACLEJAVA=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
FFmpeg)
if (( $FFMPEG == 0 )); then
FFMPEG=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
Vim)
if (( $VIMFULL == 0 )); then
VIMFULL=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
OpenSSH)
if (( $SSHCLIENT == 0 )); then
SSHCLIENT=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
Samba)
if (( $SMBCLIENT == 0 )); then
SMBCLIENT=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
Curlftpfs)
if (( $CURLFTPFS == 0 )); then
CURLFTPFS=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
Build)
if (( $BUILDESSENTIAL == 0 )); then
BUILDESSENTIAL=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
Git)
if (( $GITCLIENT == 0 )); then
GITCLIENT=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
ALSA)
if (( $ALSABASE == 0 )); then
ALSABASE=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
Xserver)
if (( $XSERVERXORG == 0 )); then
XSERVERXORG=1
INSTALL_LINUX_CHOICESMADE=true
fi
;;
esac
done < /tmp/dietpi-software_results
rm /tmp/dietpi-software_results &> /dev/null
#-----------------------------------------------------------------------------
#dietpi-config can be used to install/configure the following software. Ask user.
#CurlFTPfs -
if (( $CURLFTPFS == 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 "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 13 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Launch DietPi-config
/DietPi/dietpi/dietpi-config 16 1
#DietPi-Config will change .installed file, so reload new value into var
. "$FP_INSTALLED_FILE"
fi
fi
#SMBCLIENT -
if (( $SMBCLIENT == 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 "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 13 70
CHOICE=$?
if (( $CHOICE == 0 )); then
#Launch DietPi-config
/DietPi/dietpi/dietpi-config 16 1
#DietPi-Config will change .installed file, so reload new value into var
. "$FP_INSTALLED_FILE"
fi
fi
#-----------------------------------------------------------------------------
#Return to Main Menu
TARGETMENUID=0
}
#/////////////////////////////////////////////////////////////////////////////////////
# Banner Print
#/////////////////////////////////////////////////////////////////////////////////////
Banner_Setup(){
/DietPi/dietpi/dietpi-banner 0
echo -e "\n DietPi-Software \n"
}
Banner_Installing(){
/DietPi/dietpi/dietpi-banner 0
echo -e "\n Installing Software: $INSTALL_DESCRIPTION \n Please Wait, this may take some time... \n "
/DietPi/dietpi/dietpi-funtime 0
}
Banner_Apt_Update(){
/DietPi/dietpi/dietpi-banner 0
echo -e "\n Please Wait: \n Updating and Upgrading APT, this may take some time... \n"
sleep 1
}
Banner_Reboot(){
/DietPi/dietpi/dietpi-banner 0
echo -e "\n The system will now reboot. \n This completes the DietPi-Software installation.\n"
/DietPi/dietpi/dietpi-funtime 0
sleep 3
}
Banner_Configs(){
/DietPi/dietpi/dietpi-banner 0
echo -e "\n Please Wait: \n Applying DietPi optimizations and configurations for $HW_MODEL_DESCRIPTION \n"
/DietPi/dietpi/dietpi-funtime 0
}
Banner_Aborted(){
#1st run abort
if (( $DIETPI_INSTALL_STAGE == 0 )); then
/DietPi/dietpi/dietpi-banner 0
echo -e "\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
#/////////////////////////////////////////////////////////////////////////////////////
#--------------------------------------------------------------------------------------
Banner_Setup
#--------------------------------------------------------------------------------------
#Check Internet before starting anything.
#NB: Contains EXIT path
Check_Internet_Connection
#--------------------------------------------------------------------------------------
#Check for DietPi updates on 1st run
#NB: Contains EXIT path
if (( $(cat /DietPi/dietpi/.update_stage) == -1 )); then
FirstRun_DietPi_Update
fi
clear
#--------------------------------------------------------------------------------------
#load .installed file, update vars, if it exists
Read_InstallFileList
#Generate blank .installed file if it doesnt exist on a fresh image or update with current values.
Write_InstallFileList
#--------------------------------------------------------------------------------------
#DietPi-Software, 1st run.
if (( $DIETPI_INSTALL_STAGE == 0 )); then
#Load and apply Automated install settings from dietpi.txt.
FirstRun_Automation
#1st run Questions for user.
FirstRun_Questions
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
fi
done
#--------------------------------------------------------------------------------------
#Start DietPi-Software installs
if (( $GOSTARTINSTALL == 1 )); then
Check_Internet_Connection
if (( $INTERNET_CONNECTED == 1 )); then
#Start installations for software
Run_Installations
#Upload DietPi-Survey Data
/DietPi/dietpi/dietpi-survey &> /dev/null
#Reboot
Banner_Reboot
reboot
fi
fi
#-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}