Try to fix OMV installation

Unresolved: 'apt-get install -f' needed in 'firstrun'  since 'newaliases' fails in chroot environment.
This commit is contained in:
Thomas Kaiser 2017-04-03 15:50:20 +02:00 committed by GitHub
parent edaaeb5ef4
commit 3b8025fdea

View File

@ -28,6 +28,50 @@ Main() {
esac
} # Main
InstallOpenMediaVault() {
# use this routine to create a Debian Jessie based fully functional
# OpenMediaVault 3 OS image. Use of mainline kernel highly recommended!
# After exchanging userpatches/customize-image.sh or at least uncommenting
# InstallOpenMediaVault line above you would then run this for a NEO 2
# for example: ./compile.sh RELEASE=jessie BRANCH=dev BOARD=nanopineo2
#
# Please note that this variant changes Armbian default security
# policies since you end up with root password 'openmediavault' which
# you have to change yourself later.
#
# This routine is based on idea/code courtesy Benny Stark. For fixes,
# discussion and feature requests please refer to
# https://forum.armbian.com/index.php?/topic/2644-openmediavault-3x-customize-imagesh/
#!/bin/bash
# arguments: $RELEASE $LINUXFAMILY $BOARD $BUILD_DESKTOP
#
# This is the image customization script
#
# NOTE: It is copied to /tmp directory inside the image
# and executed there inside chroot environment
# so don't reference any files that are not already installed
RELEASE=$1
LINUXFAMILY=$2
BOARD=$3
BUILD_DESKTOP=$4
Main() {
case $RELEASE in
jessie)
# your code here
InstallOpenMediaVault # uncomment to get an OMV 3 image
;;
xenial)
# your code here
;;
stretch)
# your code here
;;
esac
} # Main
InstallOpenMediaVault() {
# use this routine to create a Debian Jessie based fully functional
# OpenMediaVault 3 OS image. Use of mainline kernel highly recommended!
@ -45,6 +89,7 @@ InstallOpenMediaVault() {
echo root:openmediavault | chpasswd
rm /root/.not_logged_in_yet
cp -p /etc/default/cpufrequtils /etc/default/cpufrequtils.bak
echo "openmediavault" > /etc/hostname
sed -i -e "s/^::1 localhost.*/::1 localhost openmediavault ip6-localhost ip6-loopback/" \
-e "s/^127.0.0.1 localhost.*/127.0.0.1 localhost openmediavault/" /etc/hosts
@ -52,55 +97,56 @@ InstallOpenMediaVault() {
locale-gen "C"
export LANG=C
export LC_ALL="en_US.UTF-8"
export DEBIAN_FRONTEND=noninteractive
#Add OMV source.list and Update System
cat > /etc/apt/sources.list.d/openmediavault.list << EOF
deb http://packages.openmediavault.org/public erasmus main
## Uncomment the following line to add software from the proposed repository.
# deb http://packages.openmediavault.org/public erasmus-proposed main
## 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
EOF
apt-get update
cat > /etc/apt/sources.list.d/openmediavault.list <<- EOF
deb http://packages.openmediavault.org/public erasmus main
## Uncomment the following line to add software from the proposed repository.
# deb http://packages.openmediavault.org/public erasmus-proposed main
## 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
EOF
# Add OMV and OMV Plugin developer keys
debconf-apt-progress -- apt-get update
apt-get --yes --force-yes --allow-unauthenticated install openmediavault-keyring
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7AA630A1EDEE7D73
#install debconf-utils, postfix and OMV for postfix configuration
# install debconf-utils, postfix and OMV
debconf-set-selections <<< "postfix postfix/mailname string openmediavault"
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'No configuration'"
apt-get --yes --force-yes --allow-unauthenticated --fix-missing --no-install-recommends \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install \
debconf-utils postfix openmediavault
debconf-utils postfix
sed -i -e "s/^mydestination =.*/mydestination = openmediavault, localhost.localdomain, localhost/" \
-e "s/^myhostname =.*/myhostname = openmediavault/" /etc/postfix/main.cf
export DEBIAN_FRONTEND=noninteractive
apt-get --yes --force-yes --allow-unauthenticated --fix-missing --no-install-recommends \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install \
openmediavault
#install OMV extras
wget http://omv-extras.org/openmediavault-omvextrasorg_latest_all3.deb -O /tmp/omvextras3.deb
dpkg -i /tmp/omvextras3.deb && rm -f /tmp/omvextras3.deb
FILE=$(mktemp)
wget http://omv-extras.org/openmediavault-omvextrasorg_latest_all3.deb -qO $FILE && dpkg -i $FILE && rm $FILE
/usr/sbin/omv-update
# Tidy up
apt-get autoremove
apt-get autoclean
#remove/enabled some services
systemctl disable tftpd-hpa
systemctl disable proftpd
systemctl disable nfs-kernel-server
systemctl disable nfs-common
systemctl disable snmpd
systemctl disable nmbd
systemctl disable samba-ad-dc
systemctl disable smbd
systemctl enable ssh
sed -i '/<ssh>/,/<\/ssh>/ s/<enable>0/<enable>1/' /etc/openmediavault/config.xml
# apt-get -y install openmediavault-flashmemory
sed -i -e '/<flashmemory>/,/<\/flashmemory>/ s/<enable>0/<enable>1/' \
-e '/<ssh>/,/<\/ssh>/ s/<enable>0/<enable>1/' /etc/openmediavault/config.xml
# /usr/sbin/omv-mkconf flashmemory
#FIX TFTPD ipv4
sed -i 's/--secure/--secure --ipv4/' /etc/default/tftpd-hpa
[ -f /etc/default/tftpd-hpa ] && sed -i 's/--secure/--secure --ipv4/' /etc/default/tftpd-hpa
#adding omv-initsystem to firstrun -- q&d but shouldn't matter
echo "/usr/sbin/omv-initsystem" >> /etc/init.d/firstrun
sed -i '/systemctl\ disable\ firstrun/i \
\texport DEBIAN_FRONTEND=noninteractive \
\tapt-get install -f || exit 0 \
\t/usr/sbin/omv-initsystem \
\tmv /etc/default/cpufrequtils.bak /etc/default/cpufrequtils' /etc/init.d/firstrun
sed -i '/systemctl\ disable\ firstrun/a \
\tsync && sleep 30 && reboot' /etc/init.d/firstrun
} # InstallOpenMediaVault
Main "$@"