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

Cleanup #1

parent 6a3e4b41
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# Very basic stuff # 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 # gather some info
distribution=$(lsb_release -cs) distribution=$(lsb_release -cs)
...@@ -15,9 +15,7 @@ set ${serverIP//./ } ...@@ -15,9 +15,7 @@ set ${serverIP//./ }
SUBNET="$1.$2.$3." SUBNET="$1.$2.$3."
hostnamefqdn=$(hostname -f) hostnamefqdn=$(hostname -f)
mysql_pass="" mysql_pass=""
tv_user="admin" backtitle="Armbian post deployment scripts, http://www.armbian.com"
tv_pass="1234"
backtitle="Micro home server (c) Igor Pecovnik"
logfile="/tmp/microhomeserver.log" logfile="/tmp/microhomeserver.log"
echo "Start:" > $logfile echo "Start:" > $logfile
...@@ -82,8 +80,7 @@ apt-get -y upgrade | dialog --backtitle "$backtitle" \ ...@@ -82,8 +80,7 @@ apt-get -y upgrade | dialog --backtitle "$backtitle" \
--progressbox "Force upgrade ..." $TTY_Y $TTY_X --progressbox "Force upgrade ..." $TTY_Y $TTY_X
apt-get -y autoremove | dialog --backtitle "$backtitle" \ apt-get -y autoremove | dialog --backtitle "$backtitle" \
--progressbox "Remove packages that are no more needed ..." $TTY_Y $TTY_X --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"\ install_packet "debconf-utils unzip build-essential html2text apt-transport-https" "Downloading basic packages"
"Downloading basic packages"
} }
...@@ -100,17 +97,18 @@ tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ ...@@ -100,17 +97,18 @@ tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15 trap "rm -f $tempfile" 0 1 2 5 15
$DIALOG --backtitle "$backtitle" \ $DIALOG --backtitle "$backtitle" \
--title "Installing to $family $distribution" --clear --checklist "\nChoose what you want to install:\n " 20 70 15 \ --title "Installing to $family $distribution" --clear --checklist "\nChoose what you want to install:\n " 22 70 15 \
"Samba" "Windows compatible file sharing " off \ "Tasksel" "Stock $family $distribution app installer" off \
"TV headend" "TV streaming / proxy" off \ "TV headend" "TV streaming / proxy" off \
"Syncthing" "Personal cloud @syncthing.net" off \ "Syncthing" "Personal cloud @syncthing.net" off \
"CUPS" "Printing" off \ "CUPS" "Printing" off \
"VPN server" "VPN server" off \ "VPN server" "VPN server" off \
"Scanner" "Control your scanner with buttons + OCR" off \ "Armbianmonitor" "Status page and statistics" off \
"Rpi monitor" "Status page and statistics" off \ "OMV" "OpenMediaVault NAS solution" off \
"Minidlna" "Lightweight DLNA/UPnP-AV server" off \
"Pi hole" "Ad blocker" off \ "Pi hole" "Ad blocker" off \
"Transmission" "Torrent downloading" 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=$? retval=$?
...@@ -161,6 +159,12 @@ echo "" ...@@ -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 (){ install_basic (){
#-------------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------------
# Set hostname, FQDN, add to sources list # Set hostname, FQDN, add to sources list
...@@ -209,106 +213,33 @@ EOF ...@@ -209,106 +213,33 @@ EOF
} }
install_sugarcrm (){ install_omv (){
#--------------------------------------------------------------------------------------------------------------------------------
# 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 high-performance HTTP accelerator # Install high-performance HTTP accelerator
#-------------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------------
wget -O - https://repo.varnish-cache.org/GPG-key.txt | apt-key add - wget -qO - packages.openmediavault.org/public/archive.key | apt-key add -
cat > /etc/apt/sources.list.d/varnish-cache.list<<EOF apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7AA630A1EDEE7D73
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
}
cat > /etc/apt/sources.list.d/openmediavault.list << EOF
deb http://packages.openmediavault.org/public erasmus main
install_rpimonitor (){ ## Uncomment the following line to add software from the proposed repository.
#-------------------------------------------------------------------------------------------------------------------------------- # deb http://packages.openmediavault.org/public erasmus-proposed main
# 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
}
install_bmc180 (){ ## This software is not part of OpenMediaVault, but is offered by third-party
#-------------------------------------------------------------------------------------------------------------------------------- ## developers as a service to OpenMediaVault users.
# 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
}
# deb http://packages.openmediavault.org/public erasmus partner
install_tsl2561 (){ EOF
#-------------------------------------------------------------------------------------------------------------------------------- debconf-apt-progress -- apt-get update
# Install light sensor read utility 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
cd /tmp /usr/sbin/omv-update
wget https://github.com/igorpecovnik/Debian-micro-home-server/blob/next/src/tsl2561-src.tgz?raw=true -O - | tar -xz sed -i '/<flashmemory>/,/<\/flashmemory>/ s/<enable>0/<enable>1/' /etc/openmediavault/config.xml
gcc -Wall -O2 -o TSL2561.o -c TSL2561.c /usr/sbin/omv-mkconf flashmemory
gcc -Wall -O2 -o TSL2561_test.o -c TSL2561_test.c check_port 80
gcc -Wall -O2 -o TSL2561_test TSL2561.o TSL2561_test.o
cp TSL2561_test /usr/local/bin/tsl2561
} }
...@@ -316,14 +247,16 @@ install_tvheadend (){ ...@@ -316,14 +247,16 @@ install_tvheadend (){
#-------------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------------
# TVheadend https://tvheadend.org/ # 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 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 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 >/dev/null 2>&1
fi fi
debconf-apt-progress -- apt-get update
install_packet "libssl-doc libssl1.0.0 zlib1g-dev tvheadend xmltv-util" install_packet "libssl-doc libssl1.0.0 zlib1g-dev tvheadend xmltv-util"
install -m 755 scripts/tv_grab_file /usr/bin/tv_grab_file install -m 755 scripts/tv_grab_file /usr/bin/tv_grab_file
sed -i 's/name": ".*"/name": "'$tv_user'"/' /home/hts/.hts/tvheadend/superuser dpkg-reconfigure tvheadend
sed -i 's/word": ".*"/word": "'$tv_pass'"/' /home/hts/.hts/tvheadend/superuser
service tvheadend restart service tvheadend restart
} }
...@@ -332,43 +265,16 @@ install_transmission (){ ...@@ -332,43 +265,16 @@ install_transmission (){
#-------------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------------
# 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_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_cups (){
#-------------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------------
# Install printer system # 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 # cups-filters if jessie
sed -e 's/Listen localhost:631/Listen 631/g' -i /etc/cups/cupsd.conf 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 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 ...@@ -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_syncthing (){
#-------------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------------
# Install Personal cloud https://syncthing.net/ # Install Personal cloud https://syncthing.net/
#-------------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------------
curl -s https://syncthing.net/release-key.txt | apt-key add - 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 if !(grep -qs syncthing "/etc/apt/sources.list.d/syncthing.list");then
apt-get update | dialog --backtitle $backtitle --progressbox "Force package list update ..." $TTY_X $TTY_Y echo "deb http://apt.syncthing.net/ syncthing release" | tee /etc/apt/sources.list.d/syncthing.list
install_packet "syncthing" "Install Personal cloud https://syncthing.net/" debconf-apt-progress -- apt-get update
sed -e 's/exit 0//g' -i /etc/rc.local install_packet "syncthing" "Install Personal cloud https://syncthing.net/"
cat >> /etc/rc.local <<"EOF" sed -e 's/exit 0//g' -i /etc/rc.local
cat >> /etc/rc.local <<"EOF"
syncthing syncthing
exit 0 exit 0
EOF EOF
syncthing >/dev/null 2>&1 &
sleep 5
fi
} }
......
...@@ -37,10 +37,9 @@ fi ...@@ -37,10 +37,9 @@ fi
# Choose what to install # Choose what to install
what_to_install what_to_install
before_install for menu_choice in "${choice[@]}"
for i in "${choice[@]}"
do do
if [[ "$i" == ISPConfig* ]] ; then if [[ "$menu_choice" == ISPConfig* ]] ; then
server_conf server_conf
if [[ "$MYSQL_PASS" == "" ]]; then if [[ "$MYSQL_PASS" == "" ]]; then
dialog --msgbox "Mysql password can't be blank. Exiting..." 7 70 dialog --msgbox "Mysql password can't be blank. Exiting..." 7 70
...@@ -50,33 +49,42 @@ do ...@@ -50,33 +49,42 @@ do
create_ispconfig_configuration; install_PureFTPD; install_Fail2BanDovecot; install_Fail2BanRulesDovecot; create_ispconfig_configuration; install_PureFTPD; install_Fail2BanDovecot; install_Fail2BanRulesDovecot;
install_ISPConfig install_ISPConfig
fi fi
if [[ "$i" == Samba* ]] ; then if [[ "$menu_choice" == *Tasksel* ]] ; then
install_samba tasksel
fi fi
if [[ "$i" == *headend* ]] ; then if [[ "$menu_choice" == *headend* ]] ; then
install_tvheadend install_tvheadend
check_port 9981
echo $menu_choice;
fi fi
if [[ "$i" == Syncthing* ]] ; then if [[ "$menu_choice" == *Syncthing* ]] ; then
install_syncthing install_syncthing
check_port 8384 "Syncthing"
fi fi
if [[ "$i" == CUPS* ]] ; then if [[ "$menu_choice" == CUPS* ]] ; then
install_cups install_cups
fi fi
if [[ "$i" == *server* ]] ; then if [[ "$menu_choice" == *server* ]] ; then
install_vpn_server install_vpn_server
fi fi
if [[ "$i" == Scanner* ]] ; then if [[ "$menu_choice" == Scanner* ]] ; then
install_scaner_and_scanbuttons install_scaner_and_scanbuttons
fi fi
if [[ "$i" == *monitor* ]] ; then if [[ "$menu_choice" == *monitor* ]] ; then
install_rpimonitor armbianmonitor -r
fi 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 curl -L install.pi-hole.net | bash
fi 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 install_transmission
check_port 9091
fi fi
done 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