mirror of
https://github.com/YunoHost/install_script.git
synced 2024-09-03 20:06:25 +02:00
Avoid error output on some tests, no avahi workaround if avahi is already installed
This commit is contained in:
parent
bfe8baaa69
commit
7206d06708
1 changed files with 47 additions and 23 deletions
|
@ -19,11 +19,35 @@ print() {
|
|||
printf "%s\n" "$*";
|
||||
}
|
||||
|
||||
die() {
|
||||
notify_about_install_logs() {
|
||||
print "
|
||||
Yunohost installation error :
|
||||
Installation logs are located in /var/log/yunohost.log
|
||||
" 1>&2
|
||||
|
||||
$1" 1>&2
|
||||
}
|
||||
|
||||
success() {
|
||||
tput setf 2
|
||||
print "
|
||||
Success !
|
||||
"
|
||||
tput sgr 0
|
||||
notify_about_install_logs
|
||||
}
|
||||
|
||||
die() {
|
||||
print "\
|
||||
=================================================="
|
||||
|
||||
tput setf 4
|
||||
print "
|
||||
Failure !
|
||||
The following error was caught during Yunohost installation :
|
||||
|
||||
$1
|
||||
" 1>&2
|
||||
tput sgr 0
|
||||
notify_about_install_logs
|
||||
exit ${2:-1}
|
||||
}
|
||||
|
||||
|
@ -97,7 +121,7 @@ set_domain() {
|
|||
# Configure hostname to yunohost.yunohost.org if not already set
|
||||
# NOTE: This is done also during postinstall "to avoid amavis bug"
|
||||
# so we might not need it here
|
||||
[ "$(hostname -d)" != "" ] || hostname yunohost.yunohost.org > /dev/null 2>&1
|
||||
[ "$(hostname -d > /dev/null 2>&1)" != "" ] || hostname yunohost.yunohost.org > /dev/null 2>&1
|
||||
}
|
||||
|
||||
confirm_installation() {
|
||||
|
@ -135,7 +159,7 @@ setup_package_source() {
|
|||
fi
|
||||
|
||||
# Add YunoHost repository key to the keyring
|
||||
wget -O- http://repo.yunohost.org/yunohost.asc -q | apt-key add - -qq
|
||||
wget -O- http://repo.yunohost.org/yunohost.asc -q | apt-key add - -qq > /dev/null
|
||||
}
|
||||
|
||||
apt_update() {
|
||||
|
@ -155,21 +179,25 @@ register_debconf() {
|
|||
}
|
||||
|
||||
workaround_avahi_installation() {
|
||||
|
||||
# When attempting several installation of Yunohost on the same host
|
||||
# with a light VM system like LXC
|
||||
# we hit a bug with avahi-daemon postinstallation
|
||||
# This is described in detail in https://github.com/lxc/lxc/issues/25
|
||||
#
|
||||
# It makes the configure step of avahii-daemon fail, because the service does
|
||||
# start correctly. Then all other packages depending on avahi-daemon refuse to
|
||||
#
|
||||
# It makes the configure step of avahi-daemon fail, because the service does
|
||||
# start correctly. Then all other packages depending on avahi-daemon refuse to
|
||||
# configure themselves.
|
||||
#
|
||||
#
|
||||
# The workaround we use is to generate a random uid for the avahi user, and
|
||||
# create the user with this id beforehand, so that the avahi-daemon postinst
|
||||
# script does not do it on its own. Our randomized uid has far less chances to
|
||||
# be already in use in another system than the automated one (which tries to use
|
||||
# consecutive uids).
|
||||
|
||||
|
||||
# Return without error if avahi already exists
|
||||
[ $(id avahi > /dev/null 2>&1) ] || return 0
|
||||
|
||||
# Get a random unused uid between 500 and 999 (system-user)
|
||||
local avahi_id=$((500 + $RANDOM % 500))
|
||||
while [ $(cat /etc/passwd | cut -d ':' -f 3 | grep $avahi_id) ] ;
|
||||
|
@ -191,7 +219,10 @@ install_yunohost_packages() {
|
|||
-- \
|
||||
apt-get -o Dpkg::Options::="--force-confold" \
|
||||
-y install \
|
||||
yunohost
|
||||
yunohost yunohost-config \
|
||||
yunohost-config-postfix \
|
||||
postfix postfix-ldap \
|
||||
postfix-policyd-spf-perl
|
||||
}
|
||||
|
||||
restart_services() {
|
||||
|
@ -205,6 +236,9 @@ restart_services() {
|
|||
}
|
||||
|
||||
post_install() {
|
||||
# Remove whiptail and dialog remains...
|
||||
clear
|
||||
|
||||
local text="
|
||||
Yunohost packages have been installed successfully!
|
||||
|
||||
|
@ -237,7 +271,7 @@ Yunohost post-installation has failed.
|
|||
Do you want to try again now?
|
||||
"
|
||||
whiptail --title "Post-installation" --yesno "$text_retry" 12 78 --defaultno \
|
||||
&& return $POSTINSTALL_EXIT_CODE
|
||||
|| return $POSTINSTALL_EXIT_CODE
|
||||
|
||||
/usr/bin/yunohost tools postinstall
|
||||
POSTINSTALL_EXIT_CODE="$?"
|
||||
|
@ -254,47 +288,38 @@ if ! ensure_root ; then
|
|||
die "This script must be run as root" 1
|
||||
fi
|
||||
|
||||
echo installscript_dependencies
|
||||
if ! installscript_dependencies ; then
|
||||
die "Unable to install dependencies to install script" 2
|
||||
fi
|
||||
|
||||
echo create_custom_config
|
||||
if ! create_custom_config ; then
|
||||
die "Creating custom configuration file /etc/yunohost/yunohost.conf failed" 3
|
||||
fi
|
||||
|
||||
echo set_domain
|
||||
if ! set_domain ; then
|
||||
die "Setting hostname failed" 4
|
||||
fi
|
||||
|
||||
echo confirm_installation
|
||||
if ! confirm_installation ; then
|
||||
die "Installation cancelled at your request" 5
|
||||
fi
|
||||
|
||||
echo setup_package_source
|
||||
if ! setup_package_source "$@" ; then
|
||||
die "Setting up deb package sources failed" 6
|
||||
fi
|
||||
|
||||
echo apt_update
|
||||
if ! apt_update ; then
|
||||
die "Error caught during 'apt-get update'" 7
|
||||
fi
|
||||
|
||||
echo register_debconf
|
||||
if ! register_debconf ; then
|
||||
die "Unable to insert new values into debconf database" 8
|
||||
fi
|
||||
|
||||
echo workaround_avahi_installation
|
||||
if ! workaround_avahi_installation ; then
|
||||
die "Unable to install workaround for avahi installation" 20
|
||||
fi
|
||||
|
||||
echo install_yunohost_packages
|
||||
if ! install_yunohost_packages ; then
|
||||
die "\
|
||||
Installation of Yunohost packages failed
|
||||
|
@ -303,16 +328,15 @@ You can check the install logs saved in /var/log/yunohost.log
|
|||
" 9
|
||||
fi
|
||||
|
||||
echo restart_services
|
||||
if ! restart_services ; then
|
||||
die "Error caught during services restart" 10
|
||||
fi
|
||||
|
||||
echo post_install
|
||||
if ! post_install ; then
|
||||
die "Post-installation failed" 11
|
||||
fi
|
||||
|
||||
# Success !
|
||||
success
|
||||
exit 0
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue