|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -if [[ "$(lsb_release -c -s)" != "jessie" ]]; then |
4 | | - echo "This script only works on Debian/Jessie" |
5 | | - exit 1 |
| 3 | +case "$(lsb_release -c -s)" in |
| 4 | + jessie) |
| 5 | + RELEASE="erasmus" |
| 6 | + EXTRAS_URL="https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master/openmediavault-omvextrasorg_latest_all3.deb" |
| 7 | + ;; |
| 8 | + |
| 9 | + stretch) |
| 10 | + RELEASE="arrakis" |
| 11 | + EXTRAS_URL="https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master/openmediavault-omvextrasorg_latest_all4.deb" |
| 12 | + ;; |
| 13 | + |
| 14 | + *) |
| 15 | + echo "This script only works on Debian/Jessie|Stretch" |
| 16 | + exit 1 |
| 17 | +esac |
| 18 | + |
| 19 | +echo "OpenMediaVault installation script" |
| 20 | +echo "Script is based on Armbian, OMV and tkaiser work: https://github.com/armbian/build/blob/master/config/templates/customize-image.sh.template" |
| 21 | +echo "" |
| 22 | +echo "This script overwrites network interfaces." |
| 23 | +echo "Make sure that you configured them in OpenMediaVault interface before rebooting." |
| 24 | +echo "" |
| 25 | + |
| 26 | +if [[ -t 0 ]]; then |
| 27 | + echo "In order to continue type YES or cancel:" |
| 28 | + while read PROMPT; do |
| 29 | + if [[ "$PROMPT" == "YES" ]]; then |
| 30 | + break |
| 31 | + fi |
| 32 | + done |
6 | 33 | fi |
7 | 34 |
|
8 | 35 | set -xe |
9 | 36 |
|
10 | | -# Based on https://github.com/armbian/build/blob/b13e92911e91e34b0b9189c704f3186a0b3788f0/scripts/customize-image.sh.template#L31 |
11 | | - |
12 | 37 | #Add OMV source.list and Update System |
13 | 38 | cat > /etc/apt/sources.list.d/openmediavault.list <<- EOF |
14 | | -# deb http://packages.openmediavault.org/public erasmus main |
15 | | -deb https://openmediavault.github.io/packages/ erasmus main |
| 39 | +# deb http://packages.openmediavault.org/public $RELEASE main |
| 40 | +deb https://openmediavault.github.io/packages/ $RELEASE main |
16 | 41 | ## Uncomment the following line to add software from the proposed repository. |
17 | | -# deb http://packages.openmediavault.org/public erasmus-proposed main |
18 | | -deb https://openmediavault.github.io/packages/ erasmus-proposed main |
| 42 | +# deb http://packages.openmediavault.org/public $RELEASE-proposed main |
| 43 | +deb https://openmediavault.github.io/packages/ $RELEASE-proposed main |
19 | 44 |
|
20 | 45 | ## This software is not part of OpenMediaVault, but is offered by third-party |
21 | 46 | ## developers as a service to OpenMediaVault users. |
22 | | -# deb http://packages.openmediavault.org/public erasmus partner |
| 47 | +# deb http://packages.openmediavault.org/public $RELEASE partner |
23 | 48 | EOF |
24 | 49 |
|
25 | 50 | # Add OMV and OMV Plugin developer keys |
| 51 | +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 24863F0C716B980B 7E7A6C592EF35D13 7AA630A1EDEE7D73 |
26 | 52 | apt-get update -y |
27 | | -apt-get --yes --force-yes --allow-unauthenticated install openmediavault-keyring |
28 | | -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7AA630A1EDEE7D73 |
29 | 53 |
|
30 | 54 | # install debconf-utils, postfix and OMV |
31 | 55 | debconf-set-selections <<< "postfix postfix/mailname string openmediavault" |
32 | 56 | debconf-set-selections <<< "postfix postfix/main_mailer_type string 'No configuration'" |
33 | | -apt-get -y install \ |
34 | | - debconf-utils postfix |
| 57 | +apt-get -y install debconf-utils postfix |
35 | 58 |
|
36 | 59 | # install openmediavault |
37 | | -apt-get --yes install openmediavault |
| 60 | +apt-get --yes install openmediavault openmediavault-keyring |
38 | 61 |
|
39 | 62 | # install OMV extras, enable folder2ram, tweak some settings |
40 | 63 | FILE=$(mktemp) |
41 | | -wget http://omv-extras.org/openmediavault-omvextrasorg_latest_all3.deb -qO $FILE && dpkg -i $FILE && rm $FILE |
| 64 | +wget "$EXTRAS_URL" -qO $FILE |
| 65 | +dpkg -i $FILE |
42 | 66 | /usr/sbin/omv-update |
43 | 67 |
|
44 | | -# use folder2ram instead of log2ram with OMV |
| 68 | +# FIX TFTPD ipv4 |
| 69 | +[ -f /etc/default/tftpd-hpa ] && sed -i 's/--secure/--secure --ipv4/' /etc/default/tftpd-hpa |
| 70 | + |
| 71 | +# load OMV helpers |
| 72 | +. /usr/share/openmediavault/scripts/helper-functions |
| 73 | + |
| 74 | +# use folder2ram |
45 | 75 | apt-get -y install openmediavault-flashmemory |
46 | | -sed -i -e '/<flashmemory>/,/<\/flashmemory>/ s/<enable>0/<enable>1/' \ |
47 | | - -e '/<ssh>/,/<\/ssh>/ s/<enable>0/<enable>1/' \ |
48 | | - -e '/<ntp>/,/<\/ntp>/ s/<enable>0/<enable>1/' \ |
| 76 | +xmlstarlet ed -L -u "/config/services/flashmemory/enable" -v "1" ${OMV_CONFIG_FILE} |
| 77 | + |
| 78 | +# enable ssh, but disallow root login |
| 79 | +xmlstarlet ed -L -u "/config/services/ssh/enable" -v "1" ${OMV_CONFIG_FILE} |
| 80 | +xmlstarlet ed -L -u "/config/services/ssh/permitrootlogin" -v "0" ${OMV_CONFIG_FILE} |
| 81 | + |
| 82 | +# enable ntp |
| 83 | +xmlstarlet ed -L -u "/config/system/time/ntp/enable" -v "1" ${OMV_CONFIG_FILE} |
| 84 | + |
| 85 | +# improve netatalk performance |
| 86 | +apt-get -y install openmediavault-netatalk |
| 87 | +AFP_Options="mimic model = Macmini" |
| 88 | +xmlstarlet ed -L -u "/config/services/afp/extraoptions" -v "$(echo -e "${AFP_Options}")" ${OMV_CONFIG_FILE} |
| 89 | + |
| 90 | +# improve samba performance |
| 91 | +SMB_Options="min receivefile size = 16384\nwrite cache size = 524288\ngetwd cache = yes\nsocket options = TCP_NODELAY IPTOS_LOWDELAY" |
| 92 | +xmlstarlet ed -L -u "/config/services/smb/extraoptions" -v "$(echo -e "${SMB_Options}")" ${OMV_CONFIG_FILE} |
| 93 | + |
| 94 | +# fix timezone |
| 95 | +xmlstarlet ed -L -u "/config/system/time/timezone" -v "UTC" ${OMV_CONFIG_FILE} |
| 96 | + |
| 97 | +# fix hostname |
| 98 | +xmlstarlet ed -L -u "/config/system/network/dns/hostname" -v "$(cat /etc/hostname)" ${OMV_CONFIG_FILE} |
| 99 | + |
| 100 | +# disable monitoring |
| 101 | +xmlstarlet ed -L -u "/config/system/monitoring/perfstats/enable" -v "0" ${OMV_CONFIG_FILE} |
| 102 | + |
| 103 | +# disable journal for rrdcached |
| 104 | +sed -i 's|-j /var/lib/rrdcached/journal/ ||' /etc/init.d/rrdcached |
| 105 | + |
| 106 | +# add eth0 interface |
| 107 | +xmlstarlet ed -L \ |
| 108 | + -s /config/system/network/interfaces -t elem -n interface \ |
| 109 | + -s /config/system/network/interfaces/interface -t elem -n uuid -v 4fa8fd59-e5be-40f6-a76d-be6a73ed1407 \ |
| 110 | + -s /config/system/network/interfaces/interface -t elem -n type -v ethernet \ |
| 111 | + -s /config/system/network/interfaces/interface -t elem -n devicename -v eth0 \ |
| 112 | + -s /config/system/network/interfaces/interface -t elem -n method -v dhcp \ |
| 113 | + -s /config/system/network/interfaces/interface -t elem -n method6 -v manual \ |
49 | 114 | /etc/openmediavault/config.xml |
50 | 115 |
|
| 116 | +# configure cpufreq |
| 117 | +cat <<EOF >>/etc/default/openmediavault |
| 118 | +OMV_CPUFREQUTILS_GOVERNOR=ondemand |
| 119 | +OMV_CPUFREQUTILS_MINSPEED=0 |
| 120 | +OMV_CPUFREQUTILS_MAXSPEED=0 |
| 121 | +EOF |
| 122 | + |
| 123 | +cat <<EOF >>/etc/rsyslog.d/omv-armbian.conf |
| 124 | +:msg, contains, "do ionice -c1" ~ |
| 125 | +:msg, contains, "action " ~ |
| 126 | +:msg, contains, "netsnmp_assert" ~ |
| 127 | +:msg, contains, "Failed to initiate sched scan" ~ |
| 128 | +EOF |
| 129 | + |
| 130 | +# update configs |
| 131 | +/usr/sbin/omv-mkconf monit |
| 132 | +/usr/sbin/omv-mkconf netatalk |
| 133 | +/usr/sbin/omv-mkconf samba |
| 134 | +/usr/sbin/omv-mkconf timezone |
| 135 | +/usr/sbin/omv-mkconf collectd |
51 | 136 | /usr/sbin/omv-mkconf flashmemory |
| 137 | +/usr/sbin/omv-mkconf ssh |
52 | 138 | /usr/sbin/omv-mkconf ntp |
| 139 | +/usr/sbin/omv-mkconf cpufrequtils |
| 140 | +/usr/sbin/omv-mkconf interfaces |
53 | 141 |
|
54 | | -systemctl disable log2ram |
55 | | -/sbin/folder2ram -enablesystemd |
56 | | -sed -i 's|-j /var/lib/rrdcached/journal/ ||' /etc/init.d/rrdcached |
| 142 | +# make sure that rrdcached/php does exist |
| 143 | +mkdir -p /var/lib/rrdcached /var/lib/php |
57 | 144 |
|
58 | | -#FIX TFTPD ipv4 |
59 | | -[ -f /etc/default/tftpd-hpa ] && sed -i 's/--secure/--secure --ipv4/' /etc/default/tftpd-hpa |
| 145 | +# disable rrdcached |
| 146 | +systemctl disable rrdcached |
| 147 | + |
| 148 | +/sbin/folder2ram -enablesystemd |
| 149 | +/sbin/folder2ram -mountall || true |
| 150 | +/sbin/folder2ram -umountall || true |
60 | 151 |
|
61 | 152 | # init OMV |
62 | 153 | # /usr/sbin/omv-initsystem |
|
0 commit comments