Commit 51c7db5a authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

Cleanup #1

parent 6a3e4b41
......@@ -5,7 +5,7 @@
# Very basic stuff
apt-get -y -qq install dialog whiptail lsb-release
apt-get -y -qq install dialog whiptail lsb-release bc
# gather some info
distribution=$(lsb_release -cs)
......@@ -15,9 +15,7 @@ set ${serverIP//./ }
SUBNET="$1.$2.$3."
hostnamefqdn=$(hostname -f)
mysql_pass=""
tv_user="admin"
tv_pass="1234"
backtitle="Micro home server (c) Igor Pecovnik"
backtitle="Armbian post deployment scripts, http://www.armbian.com"
logfile="/tmp/microhomeserver.log"
echo "Start:" > $logfile
......@@ -82,8 +80,7 @@ apt-get -y upgrade | dialog --backtitle "$backtitle" \
--progressbox "Force upgrade ..." $TTY_Y $TTY_X
apt-get -y autoremove | dialog --backtitle "$backtitle" \
--progressbox "Remove packages that are no more needed ..." $TTY_Y $TTY_X
install_packet "debconf-utils dnsutils unzip build-essential alsa-base alsa-utils stunnel4 html2text apt-transport-https"\
"Downloading basic packages"
install_packet "debconf-utils unzip build-essential html2text apt-transport-https" "Downloading basic packages"
}
......@@ -100,17 +97,18 @@ tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15
$DIALOG --backtitle "$backtitle" \
--title "Installing to $family $distribution" --clear --checklist "\nChoose what you want to install:\n " 20 70 15 \
"Samba" "Windows compatible file sharing " off \
--title "Installing to $family $distribution" --clear --checklist "\nChoose what you want to install:\n " 22 70 15 \
"Tasksel" "Stock $family $distribution app installer" off \
"TV headend" "TV streaming / proxy" off \
"Syncthing" "Personal cloud @syncthing.net" off \
"CUPS" "Printing" off \
"VPN server" "VPN server" off \
"Scanner" "Control your scanner with buttons + OCR" off \
"Rpi monitor" "Status page and statistics" off \
"Armbianmonitor" "Status page and statistics" off \
"OMV" "OpenMediaVault NAS solution" off \
"Minidlna" "Lightweight DLNA/UPnP-AV server" off \
"Pi hole" "Ad blocker" off \
"Transmission" "Torrent downloading" off \
"ISPConfig" "WWW, PHP, SQL, SMTP, IMAP, POP3" off 2> $tempfile
"ISPConfig" "Advanced LAMP + SMTP, IMAP, POP3" off 2> $tempfile
retval=$?
......@@ -161,6 +159,12 @@ echo ""
}
check_port (){
[[ -z $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".$1"') ]] && dialog --backtitle "$backtitle" --title "Checking service" --infobox "\nIt looks good.\n\nThere is $2 service on port $1" 7 52
sleep 3
}
install_basic (){
#--------------------------------------------------------------------------------------------------------------------------------
# Set hostname, FQDN, add to sources list
......@@ -209,106 +213,33 @@ EOF
}
install_sugarcrm (){
#--------------------------------------------------------------------------------------------------------------------------------
# Community edition CRM
#--------------------------------------------------------------------------------------------------------------------------------
cd /tmp
wget http://downloads.sourceforge.net/project/sugarcrm/1%20-%20SugarCRM%206.5.X/WebPI/SugarCE-6.5.18-WebPI.zip
unzip SugarCE-6.5.18-WebPI.zip
cd SugarCE-Full-6.5.18
mv * /usr/share/nginx/www
}
install_varnish (){
install_omv (){
#--------------------------------------------------------------------------------------------------------------------------------
# Install high-performance HTTP accelerator
#--------------------------------------------------------------------------------------------------------------------------------
wget -O - https://repo.varnish-cache.org/GPG-key.txt | apt-key add -
cat > /etc/apt/sources.list.d/varnish-cache.list<<EOF
deb-src https://repo.varnish-cache.org/debian/ jessie varnish-4.1
EOF
apt-get update
apt-get build-dep varnish -y
cd /tmp
apt-get source varnish -y
rm varnish_*.dsc
rm varnish_*.orig.tar.gz
rm varnish_*.diff.gz
cd varnish-4*
./configure --prefix=/usr
make -j$(ncpu)
make install
cp debian/varnish.init /etc/init.d/varnish
chmod +x /etc/init.d/varnish
cp debian/varnish.default /etc/default/varnish
update-rc.d varnish defaults
mkdir -p /etc/varnish
cp etc/example.vcl /etc/varnish/default.vcl
dd if=/dev/random of=/etc/varnish/secret count=1
service varnish start
}
wget -qO - packages.openmediavault.org/public/archive.key | apt-key add -
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7AA630A1EDEE7D73
cat > /etc/apt/sources.list.d/openmediavault.list << EOF
deb http://packages.openmediavault.org/public erasmus main
install_rpimonitor (){
#--------------------------------------------------------------------------------------------------------------------------------
# Install rpimonitor with custom config
#--------------------------------------------------------------------------------------------------------------------------------
if !(grep -qs XavierBerger "/etc/apt/sources.list");then
cat >> /etc/apt/sources.list <<EOF
# RPi-Monitor official repository
deb https://github.com XavierBerger/RPi-Monitor-deb/raw/master/repo/
EOF
fi
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2C0D3C0F
debconf-apt-progress -- apt-get update
debconf-apt-progress -- apt-get -y install rpimonitor
service rpimonitor stop
# add my own configuration which is not default
cd /etc/rpimonitor
wget https://github.com/igorpecovnik/Debian-micro-home-server/blob/next/src/rpimonitor-myconfig.tgz?raw=true -O - | tar -xhz
cd /usr/local/bin
wget https://github.com/igorpecovnik/Debian-micro-home-server/blob/next/src/temp-pir-daemon.sh?raw=true -O temp-pir-daemon.sh
chmod +x /usr/local/bin/temp-pir-daemon.sh
sed -e 's/exit 0//g' -i /etc/rc.local
cat >> /etc/rc.local <<"EOF"
nohup /usr/local/bin/temp-pir-daemon.sh &
exit 0
EOF
rm -rf /var/lib/rpimonitor/stat
mkdir -p /var/log/rpimonitor
nohup /usr/local/bin/temp-pir-daemon.sh &
service rpimonitor start
/usr/share/rpimonitor/scripts/updatePackagesStatus.pl
}
## Uncomment the following line to add software from the proposed repository.
# deb http://packages.openmediavault.org/public erasmus-proposed main
install_bmc180 (){
#--------------------------------------------------------------------------------------------------------------------------------
# Install temp and pressure sensor read utility
#--------------------------------------------------------------------------------------------------------------------------------
cd /tmp
git clone https://github.com/maasdoel/bmp180
cd bmp180
# let's change bus number to suits our need
sed -i "s/dev\/i2c-1/dev\/i2c-2/" bmp180dev3.c
gcc -Wall -o bmp180 ./bmp180dev3.c -lm
cp bmp180 /usr/local/bin
rm -r /tmp/bmp180
}
## This software is not part of OpenMediaVault, but is offered by third-party
## developers as a service to OpenMediaVault users.
# deb http://packages.openmediavault.org/public erasmus partner
install_tsl2561 (){
#--------------------------------------------------------------------------------------------------------------------------------
# Install light sensor read utility
#--------------------------------------------------------------------------------------------------------------------------------
cd /tmp
wget https://github.com/igorpecovnik/Debian-micro-home-server/blob/next/src/tsl2561-src.tgz?raw=true -O - | tar -xz
gcc -Wall -O2 -o TSL2561.o -c TSL2561.c
gcc -Wall -O2 -o TSL2561_test.o -c TSL2561_test.c
gcc -Wall -O2 -o TSL2561_test TSL2561.o TSL2561_test.o
cp TSL2561_test /usr/local/bin/tsl2561
EOF
debconf-apt-progress -- apt-get update
install_packet "openmediavault postfix openmediavault-flashmemory" "Install network attached storage (NAS) solution"
URL='http://omv-extras.org/openmediavault-omvextrasorg_latest_all3.deb'; FILE=`mktemp`; wget "$URL" -qO $FILE && sudo dpkg -i $FILE; rm $FILE
/usr/sbin/omv-update
sed -i '/<flashmemory>/,/<\/flashmemory>/ s/<enable>0/<enable>1/' /etc/openmediavault/config.xml
/usr/sbin/omv-mkconf flashmemory
check_port 80
}
......@@ -316,14 +247,16 @@ install_tvheadend (){
#--------------------------------------------------------------------------------------------------------------------------------
# TVheadend https://tvheadend.org/
#--------------------------------------------------------------------------------------------------------------------------------
install_packet "debconf-utils unzip build-essential html2text apt-transport-https" "Downloading dependendies"
if !(grep -qs tvheadend "/etc/apt/sources.list.d/tvheadend.list");then
echo "deb https://dl.bintray.com/tvheadend/deb $distribution release" >> /etc/apt/sources.list.d/tvheadend.list
echo "deb https://dl.bintray.com/tvheadend/deb $distribution stable" >> /etc/apt/sources.list.d/tvheadend.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 >/dev/null 2>&1
fi
debconf-apt-progress -- apt-get update
install_packet "libssl-doc libssl1.0.0 zlib1g-dev tvheadend xmltv-util"
install -m 755 scripts/tv_grab_file /usr/bin/tv_grab_file
sed -i 's/name": ".*"/name": "'$tv_user'"/' /home/hts/.hts/tvheadend/superuser
sed -i 's/word": ".*"/word": "'$tv_pass'"/' /home/hts/.hts/tvheadend/superuser
dpkg-reconfigure tvheadend
service tvheadend restart
}
......@@ -332,43 +265,16 @@ install_transmission (){
#--------------------------------------------------------------------------------------------------------------------------------
# transmission
#--------------------------------------------------------------------------------------------------------------------------------
install_packet "debconf-utils unzip build-essential html2text apt-transport-https" "Downloading dependendies"
install_packet "transmission-cli transmission-common transmission-daemon" "Install torrent server"
}
install_samba (){
#---------------------------------------------------------------------------------------------------------------------------------
# install Samba file sharing
#---------------------------------------------------------------------------------------------------------------------------------
# Read samba user / pass / group
local SECTION="Samba"
SMBUSER=$(whiptail --inputbox "What is your samba username?" 8 78 $SMBUSER --title "$SECTION" 3>&1 1>&2 2>&3)
exitstatus=$?; if [ $exitstatus = 1 ]; then exit 1; fi
SMBPASS=$(whiptail --inputbox "What is your samba password?" 8 78 $SMBPASS --title "$SECTION" 3>&1 1>&2 2>&3)
exitstatus=$?; if [ $exitstatus = 1 ]; then exit 1; fi
SMBGROUP=$(whiptail --inputbox "What is your samba group?" 8 78 $SMBGROUP --title "$SECTION" 3>&1 1>&2 2>&3)
exitstatus=$?; if [ $exitstatus = 1 ]; then exit 1; fi
#
debconf-apt-progress -- apt-get -y install samba samba-common-bin
useradd $SMBUSER
echo -ne "$SMBPASS\n$SMBPASS\n" | passwd $SMBUSER >/dev/null 2>&1
echo -ne "$SMBPASS\n$SMBPASS\n" | smbpasswd -a -s $SMBUSER >/dev/null 2>&1
service samba stop | service smbd stop >/dev/null 2>&1
cp scripts/smb.conf /etc/samba/smb.conf
sed -i "s/SMBGROUP/$SMBGROUP/" /etc/samba/smb.conf
sed -i "s/SMBUSER/$SMBUSER/" /etc/samba/smb.conf
sed -i "s/SUBNET/$SUBNET/" /etc/samba/smb.conf
mkdir -p /ext
chmod -R 777 /ext
service samba start | service smbd start >/dev/null 2>&1
}
install_cups (){
#--------------------------------------------------------------------------------------------------------------------------------
# Install printer system
#--------------------------------------------------------------------------------------------------------------------------------
debconf-apt-progress -- apt-get -y install cups lpr foomatic-filters
install_packet "cups lpr cups-filters" "Installing CUPS"
# cups-filters if jessie
sed -e 's/Listen localhost:631/Listen 631/g' -i /etc/cups/cupsd.conf
sed -e 's/<Location \/>/<Location \/>\nallow $SUBNET/g' -i /etc/cups/cupsd.conf
......@@ -379,51 +285,23 @@ service samba restart | service smbd restart >/dev/null 2>&1
}
install_scaner_and_scanbuttons (){
#--------------------------------------------------------------------------------------------------------------------------------
# Install Scanner buttons
#--------------------------------------------------------------------------------------------------------------------------------
install_packet "pdftk libusb-dev sane sane-utils libudev-dev imagemagick libtiff-tools" "Install Scanner buttons"
# wget http://wp.psyx.us/wp-content/uploads/2010/10/scanbuttond-0.2.3.genesys.tar.gz
wget https://github.com/igorpecovnik/Debian-micro-home-server/raw/master/src/scanbuttond-0.2.3.genesys.tar.gz
tar xvfz scanbuttond-0.2.3.genesys.tar.gz
rm scanbuttond-0.2.3.genesys.tar.gz
cd scanbuttond-0.2.3.genesys
chmod +x configure
make clean
./configure --prefix=/usr --sysconfdir=/etc
make
make install
echo "sane-find-scanner" >> /etc/scanbuttond/initscanner.sh
sed -e 's/does nothing./does nothing.\n\/usr\/bin\/scanbuttond/g' -i /etc/rc.local
}
install_ocr (){
#--------------------------------------------------------------------------------------------------------------------------------
# Install OCR
# get script from here https://github.com/gkovacs/pdfocr
#--------------------------------------------------------------------------------------------------------------------------------
wget https://raw2.github.com/gkovacs/pdfocr/master/pdfocr.rb
mv pdfocr.rb /usr/local/bin/pdfocr
chmod +x /usr/local/bin/pdfocr
apt-get -y install ruby tesseract-ocr libtiff-tools
}
install_syncthing (){
#--------------------------------------------------------------------------------------------------------------------------------
# Install Personal cloud https://syncthing.net/
#--------------------------------------------------------------------------------------------------------------------------------
curl -s https://syncthing.net/release-key.txt | apt-key add -
echo "deb http://apt.syncthing.net/ syncthing release" | tee /etc/apt/sources.list.d/syncthing-release.list
apt-get update | dialog --backtitle $backtitle --progressbox "Force package list update ..." $TTY_X $TTY_Y
install_packet "syncthing" "Install Personal cloud https://syncthing.net/"
sed -e 's/exit 0//g' -i /etc/rc.local
cat >> /etc/rc.local <<"EOF"
if !(grep -qs syncthing "/etc/apt/sources.list.d/syncthing.list");then
echo "deb http://apt.syncthing.net/ syncthing release" | tee /etc/apt/sources.list.d/syncthing.list
debconf-apt-progress -- apt-get update
install_packet "syncthing" "Install Personal cloud https://syncthing.net/"
sed -e 's/exit 0//g' -i /etc/rc.local
cat >> /etc/rc.local <<"EOF"
syncthing
exit 0
EOF
syncthing >/dev/null 2>&1 &
sleep 5
fi
}
......
......@@ -37,10 +37,9 @@ fi
# Choose what to install
what_to_install
before_install
for i in "${choice[@]}"
for menu_choice in "${choice[@]}"
do
if [[ "$i" == ISPConfig* ]] ; then
if [[ "$menu_choice" == ISPConfig* ]] ; then
server_conf
if [[ "$MYSQL_PASS" == "" ]]; then
dialog --msgbox "Mysql password can't be blank. Exiting..." 7 70
......@@ -50,33 +49,42 @@ do
create_ispconfig_configuration; install_PureFTPD; install_Fail2BanDovecot; install_Fail2BanRulesDovecot;
install_ISPConfig
fi
if [[ "$i" == Samba* ]] ; then
install_samba
if [[ "$menu_choice" == *Tasksel* ]] ; then
tasksel
fi
if [[ "$i" == *headend* ]] ; then
if [[ "$menu_choice" == *headend* ]] ; then
install_tvheadend
check_port 9981
echo $menu_choice;
fi
if [[ "$i" == Syncthing* ]] ; then
if [[ "$menu_choice" == *Syncthing* ]] ; then
install_syncthing
check_port 8384 "Syncthing"
fi
if [[ "$i" == CUPS* ]] ; then
if [[ "$menu_choice" == CUPS* ]] ; then
install_cups
fi
if [[ "$i" == *server* ]] ; then
if [[ "$menu_choice" == *server* ]] ; then
install_vpn_server
fi
if [[ "$i" == Scanner* ]] ; then
if [[ "$menu_choice" == Scanner* ]] ; then
install_scaner_and_scanbuttons
fi
if [[ "$i" == *monitor* ]] ; then
install_rpimonitor
if [[ "$menu_choice" == *monitor* ]] ; then
armbianmonitor -r
fi
if [[ "$i" == *hole* ]] ; then
if [[ "$menu_choice" == *OMV* ]] ; then
install_omv
fi
if [[ "$menu_choice" == *hole* ]] ; then
curl -L install.pi-hole.net | bash
fi
if [[ "$i" == Transmission* ]] ; then
if [[ "$menu_choice" == *Minidlna* ]] ; then
install_packet "minidlna" "Install lightweight DLNA/UPnP-AV server"
check_port 8200
fi
if [[ "$menu_choice" == *Transmission* ]] ; then
install_transmission
check_port 9091
fi
done
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment