From 05008d9678ed66c5cda30b5593a960be69539a91 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Tue, 1 Sep 2015 09:45:13 +0200 Subject: [PATCH 01/25] Beautify install script --- install_yunohostv2 | 401 ++++++++++++++++++++++++++------------------- 1 file changed, 232 insertions(+), 169 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 8442e01..56df523 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -1,71 +1,76 @@ #!/bin/bash -SUCCESS=0 -ERR_FAIL_RESTORE=1 -ERR_FAIL_UPDATE=2 -ERR_FAIL_INSTALL=3 -ERR_CANCEL_INSTALL=4 -ERR_IMPOSSIBLE=-1 - -function bck { - FULLPATH="$(readlink -f "$1")" - DST="${2%/}/$(dirname $FULLPATH)" - mkdir -p "$DST" - cp -r --preserve=all "$FULLPATH" "$DST/$(basename $FULLPATH)" +print() { + printf "%s\n" "$*"; } -function rst { - [[ ! -d "$LEGACY" ]] && echo >&2 "Rollback failed : Unknown folder $LEGACY" && exit $ERR_FAIL_RESTORE - cp -rf "$LEGACY"/* / - [[ $? -ne 0 ]] && echo >&2 "Rollback failed" && exit $ERR_FAIL_RESTORE +die() { + print " +Yunohost installation error : + +$1" 1>&2 + exit ${2:-1} } -set -u +this_script_path() { + # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in + local SOURCE="${BASH_SOURCE[0]}" + while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + local DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located + done + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + echo $DIR +} -echo "======== Get path of current script =======" +ensure_root() { + if [ "$(id -u)" != "0" ] ; + then + return 1 + fi + return 0 +} -# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +installscript_dependencies() { + # install dependencies of the install script itself + local packages="lsb-release wget whiptail" -echo "Running from $DIR" + debconf-apt-progress \ + --logfile /var/log/yunohost-update.log \ + -- \ + apt-get update \ + || return 1 + debconf-apt-progress \ + --logfile /var/log/yunohost.log \ + -- \ + apt-get -o Dpkg::Options::="--force-confold" \ + -y install \ + $packages \ + || return 2 -echo "======== Check rights ========" + # on Jessie, we need python-xmpp + # TODO : add a comment for why we need this + if [ "$(lsb_release -c | awk '{print $2}')" == "jessie" ] ; + then + debconf-apt-progress \ + --logfile /var/log/yunohost.log \ + -- \ + apt-get -o Dpkg::Options::="--force-confold" \ + -y install \ + python-xmpp \ + || return 3 + fi -if [ "$(id -u)" != "0" ]; then - echo "This script must be run as root" 1>&2 - exit 1 -fi + return 0 +} -echo "======== YunoHost Installation ========" -echo "======== Check dependencies ========" - -apt-get update -qq -for i in lsb-release wget dialog whiptail -do - dpkg -l | grep -q $i - if [[ $? -eq 1 ]] - then - apt-get install $i -y - fi -done - -# Fix install on jessie -if [ $(lsb_release -c | awk '{print $2}') = jessie ]; -then - apt-get install python-xmpp -y -fi - -if [[ ! -f /etc/yunohost/yunohost.conf ]] -then -mkdir /etc/yunohost/ -touch /etc/yunohost/from_script -cat << EOF > /etc/yunohost/yunohost.conf +create_custom_config() { + if [[ ! -f /etc/yunohost/yunohost.conf ]] + then + mkdir /etc/yunohost/ + touch /etc/yunohost/from_script + cat << EOF > /etc/yunohost/yunohost.conf # Yunohost custom config # If you want to keep a custom service configuration replace "no" by "yes" # for the concerned service @@ -83,122 +88,180 @@ slapd=no ssh=yes ssowat=no EOF + fi +} + +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 +} + +confirm_installation() { + local text=" +Caution ! + +Your configuration files for : + - postfix + - dovecot + - mysql + - nginx + - metronome +will be overwritten ! + +Are you sure you want to proceed with the installation of Yunohost? +" + whiptail --title "Yunohost Installation" --yesno "$text" 20 78 +} + +setup_package_source() { + local CUSTOMAPT=/etc/apt/sources.list.d/yunohost.list + + # In any case we need the main stable repo + echo "deb http://repo.yunohost.org/ megusta main" > $CUSTOMAPT + + # Also add repositories for 'testing' and/or 'unstable' if the script has been called with those arguments + if [ $# -gt 0 ]; then + if [[ "$1" == "test" ]] || [[ "$1" == "testing" ]] ; then + echo "deb http://repo.yunohost.org/ testing main" >> $CUSTOMAPT + fi + if [[ "$1" == "daily" ]] || [[ "$1" == "unstable" ]] ; then + echo "deb http://repo.yunohost.org/ testing main" >> $CUSTOMAPT + echo "deb http://repo.yunohost.org/ unstable main" >> $CUSTOMAPT + fi + fi + + # Add YunoHost repository key to the keyring + wget -O- http://repo.yunohost.org/yunohost.asc -q | apt-key add - -qq +} + +apt_update() { + debconf-apt-progress \ + --logfile /var/log/yunohost-update.log \ + -- \ + apt-get update +} + +register_debconf() { + if [ $(lsb_release -c | awk '{print $2}') = jessie ]; + then + debconf-set-selections $(this_script_path)/debconfjessie + else + debconf-set-selections $(this_script_path)/debconfv2 + fi +} + +install_yunohost_packages() { + debconf-apt-progress \ + --logfile /var/log/yunohost.log \ + -- \ + apt-get -o Dpkg::Options::="--force-confold" \ + -y install \ + yunohost +} + +restart_services() { + service slapd restart +# service yunohost-firewall start +# service nscd restart +# service nslcd restart + + # NOTE : We don't fail if slapd fails to restart... + return 0 +} + +post_install() { + local text=" +Yunohost packages have been installed successfully! + +You can now proceed with Yunohost post-installation. +This is where you will be asked for : +- the main DNS domain name of your server +- the administration password + +You can also perform this step later on your own : +- either from a shell, by running 'yunohost tools postinstall' + as root +- either from your web browser, by accessing https://yunohost.local + +Please refer to https://yunohost.org/#/postinstall +for additionnal information. + +Do you want to proceed with YunoHost post-installation now? +" + whiptail --title "Post-installation" --yesno "$text" 25 78 \ + || return 0 + + /usr/bin/yunohost tools postinstall + + local POSTINSTALL_EXIT_CODE="$?" + while [ "$POSTINSTALL_EXIT_CODE" -gt 0 ] ; + do + local text_retry=" +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 + + /usr/bin/yunohost tools postinstall + POSTINSTALL_EXIT_CODE="$?" + done + return 0 +} + +set -u + +if ! ensure_root ; then + die "This script must be run as root" 1 fi -echo "======== Checking domain ========" -DOMAIN=$(hostname -d) -if [[ "${DOMAIN:-1}" = 1 ]] -then - hostname yunohost.yunohost.org - DOMAIN='yunohost.org' +if ! installscript_dependencies ; then + die "Unable to install dependencies to install script" 2 fi -whiptail --title "Yunohost Installation" --yesno "Caution : your config files for postfix,dovecot,mysql,nginx,metronome will be overwritten\nDo you want to proceed install of Yunohost?" 8 78 -YESNO=$? - -if [[ $YESNO -eq 0 ]] -then - # Backup folder for legacy config files - LEGACY=/etc/yunohost/.legacy - mkdir -p "$LEGACY" - - echo "======== Adding repositories ========" - - CUSTOMAPT=/etc/apt/sources.list - - grep -qri "yunohost" $CUSTOMAPT - if [[ $? -eq 1 ]] - then - echo "deb http://repo.yunohost.org/ megusta main" >> $CUSTOMAPT - fi - - if [ $# -gt 0 ]; then - if [[ "$1" == "test" ]] || [[ "$1" == "testing" ]] ; then - echo "deb http://daily.yunohost.org/ testing main" >> $CUSTOMAPT - fi - if [[ "$1" == "daily" ]] || [[ "$1" == "unstable" ]] ; then - echo "deb http://daily.yunohost.org/ testing main" >> $CUSTOMAPT - echo "deb http://daily.yunohost.org/ unstable main" >> $CUSTOMAPT - fi - fi - - #Get gpg key - wget -O- http://repo.yunohost.org/yunohost.asc -q | apt-key add - -qq - - #Update repo - debconf-apt-progress \ - --logfile /var/log/yunohost-update.log \ - -- \ - apt-get update - - if [[ $? -ne 0 ]] - then - echo "Update Repo Failure : Rolling back" - rst "$LEGACY" - exit $ERR_FAIL_UPDATE - fi - - echo "======== Install ========" - #add answer in debconf db - if [ $(lsb_release -c | awk '{print $2}') = jessie ]; - then - debconf-set-selections $DIR/debconfjessie - else - debconf-set-selections $DIR/debconfv2 - fi - - #Install yunohost packages - debconf-apt-progress \ - --logfile /var/log/yunohost.log \ - -- \ - apt-get -o Dpkg::Options::="--force-confold" \ - -y install \ - yunohost \ - yunohost-config \ - yunohost-config-postfix \ - postfix postfix-ldap \ - postfix-policyd-spf-perl - - if [[ $? -ne 0 ]] - then - echo "======== Installation failed ========" - echo "Rolling back have to be done manually !" - echo "Check your legacy configuration files => '$LEGACY'" - echo "Check install logs => '/var/log/yunohost.log' and '/var/log/yunohost.error'" - exit $ERR_FAIL_INSTALL - else - service slapd restart - if [ -f /etc/init.d/yunohost-firewall ]; - then - service yunohost-firewall start - fi - service nscd restart - service nslcd restart - - echo -e "\n" - whiptail --title "Post-installation" --yesno "Proceed to post-installation?" 8 78 - YESNO=$? - RESULT=1 - while [ $RESULT -gt 0 ]; do - if [[ $YESNO -eq 0 ]]; then - echo -e "\n" - /usr/bin/yunohost tools postinstall - let RESULT=$? - if [ $RESULT -gt 0 ]; then - echo -e "\n" - whiptail --title "Post-installation" --yesno "Post-installation failed, retry ?" 8 78 - let YESNO=$? - fi - else - exit 0 - fi - done - fi - -else - echo "======== Installation cancelled ========" - exit $ERR_CANCEL_INSTALL +if ! create_custom_config ; then + die "Creating custom configuration file /etc/yunohost/yunohost.conf failed" 3 fi -# Security : we shouldn't be able to exit here -exit $ERR_IMPOSSIBLE +if ! set_domain ; then + die "Setting hostname failed" 4 +fi + +if ! confirm_installation ; then + die "Installation cancelled at your request" 5 +fi + +if ! setup_package_source "$@" ; then + die "Setting up deb package sources failed" 6 +fi + +if ! apt_update ; then + die "Error caught during 'apt-get update'" 7 +fi + +if ! register_debconf ; then + die "Unable to insert new values into debconf database" 8 +fi + +if ! install_yunohost_packages ; then + die "\ +Installation of Yunohost packages failed + +You can check the install logs saved in /var/log/yunohost.log +" 9 +fi + +if ! restart_services ; then + die "Error caught during services restart" 10 +fi + +if ! post_install ; then + die "Post-installation failed" 11 +fi + +# Success ! +exit 0 + From f95eca0ada3c21b366817a875b5aa80b673eb45d Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Tue, 1 Sep 2015 13:04:04 +0200 Subject: [PATCH 02/25] Add avahi-daemon workaround --- install_yunohostv2 | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 56df523..884ef65 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -37,7 +37,7 @@ installscript_dependencies() { local packages="lsb-release wget whiptail" debconf-apt-progress \ - --logfile /var/log/yunohost-update.log \ + --logfile /var/log/yunohost.log \ -- \ apt-get update \ || return 1 @@ -95,7 +95,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 + [ "$(hostname -d)" != "" ] || hostname yunohost.yunohost.org > /dev/null 2>&1 } confirm_installation() { @@ -138,7 +138,7 @@ setup_package_source() { apt_update() { debconf-apt-progress \ - --logfile /var/log/yunohost-update.log \ + --logfile /var/log/yunohost.log \ -- \ apt-get update } @@ -152,6 +152,37 @@ register_debconf() { fi } +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 + # 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). + + # 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) ] ; + do + avahi_id=$((500 + $RANDOM % 500)) + done + + # Use the same adduser parameter as in the avahi-daemon postinst script + # Just specify --uid explicitely + adduser --disabled-password --quiet --system \ + --home /var/run/avahi-daemon --no-create-home \ + --gecos "Avahi mDNS daemon" --group avahi \ + --uid $avahi_id +} + install_yunohost_packages() { debconf-apt-progress \ --logfile /var/log/yunohost.log \ @@ -196,7 +227,7 @@ Do you want to proceed with YunoHost post-installation now? /usr/bin/yunohost tools postinstall local POSTINSTALL_EXIT_CODE="$?" - while [ "$POSTINSTALL_EXIT_CODE" -gt 0 ] ; + while [ "$POSTINSTALL_EXIT_CODE" -ne 0 ] ; do local text_retry=" Yunohost post-installation has failed. @@ -212,6 +243,9 @@ Do you want to try again now? return 0 } +# Treat unset variables as an error when performing +# parameter expansion. An error message will be written +# to the standard error, and a non-interactive shell will exit. set -u if ! ensure_root ; then @@ -246,6 +280,10 @@ if ! register_debconf ; then die "Unable to insert new values into debconf database" 8 fi +if ! workaround_avahi_installation ; then + die "Unable to install workaround for avahi installation" 20 +fi + if ! install_yunohost_packages ; then die "\ Installation of Yunohost packages failed From 95ebff1142d93408ace423b5d4b950ce38da9dce Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Tue, 1 Sep 2015 13:22:25 +0200 Subject: [PATCH 03/25] Remove jessie workaround for python-xmpp, not needed anymore since haste is removed --- install_yunohostv2 | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 884ef65..f702bde 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -49,19 +49,6 @@ installscript_dependencies() { $packages \ || return 2 - # on Jessie, we need python-xmpp - # TODO : add a comment for why we need this - if [ "$(lsb_release -c | awk '{print $2}')" == "jessie" ] ; - then - debconf-apt-progress \ - --logfile /var/log/yunohost.log \ - -- \ - apt-get -o Dpkg::Options::="--force-confold" \ - -y install \ - python-xmpp \ - || return 3 - fi - return 0 } @@ -252,38 +239,47 @@ 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 @@ -292,10 +288,12 @@ 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 From bfe8baaa69486a568c00dfa233d743d6cd90b5c3 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 2 Sep 2015 00:07:57 +0200 Subject: [PATCH 04/25] Add copyright and license --- install_yunohostv2 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/install_yunohostv2 b/install_yunohostv2 index f702bde..feb0eca 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -1,5 +1,20 @@ #!/bin/bash +# Copyright (C) 2015 kload, beudbeud +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + print() { printf "%s\n" "$*"; } From 7206d06708f8ec82a13aadba499ed673779795ec Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Wed, 2 Sep 2015 00:19:11 +0200 Subject: [PATCH 05/25] Avoid error output on some tests, no avahi workaround if avahi is already installed --- install_yunohostv2 | 70 +++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index feb0eca..dac3403 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -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 From 8f4a1533f3eebcd278ccc9fdbd414dc183202aaf Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Thu, 3 Sep 2015 18:17:03 +0200 Subject: [PATCH 06/25] Fix tests which were badly written. Use double brackets consistently --- install_yunohostv2 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index dac3403..b2c9a8d 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -54,7 +54,7 @@ $1 this_script_path() { # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in local SOURCE="${BASH_SOURCE[0]}" - while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + while [[ -h "$SOURCE" ]]; do # resolve $SOURCE until the file is no longer a symlink local DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located @@ -64,7 +64,7 @@ this_script_path() { } ensure_root() { - if [ "$(id -u)" != "0" ] ; + if [[ "$(id -u)" != "0" ]] ; then return 1 fi @@ -121,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 > /dev/null 2>&1)" != "" ] || hostname yunohost.yunohost.org > /dev/null 2>&1 + [[ "$(hostname -d > /dev/null 2>&1)" != "" ]] || hostname yunohost.yunohost.org > /dev/null 2>&1 } confirm_installation() { @@ -148,7 +148,7 @@ setup_package_source() { echo "deb http://repo.yunohost.org/ megusta main" > $CUSTOMAPT # Also add repositories for 'testing' and/or 'unstable' if the script has been called with those arguments - if [ $# -gt 0 ]; then + if [[ "$#" > "0" ]]; then if [[ "$1" == "test" ]] || [[ "$1" == "testing" ]] ; then echo "deb http://repo.yunohost.org/ testing main" >> $CUSTOMAPT fi @@ -170,7 +170,7 @@ apt_update() { } register_debconf() { - if [ $(lsb_release -c | awk '{print $2}') = jessie ]; + if [[ $(lsb_release -c | awk '{print $2}') == jessie ]]; then debconf-set-selections $(this_script_path)/debconfjessie else @@ -196,11 +196,11 @@ workaround_avahi_installation() { # consecutive uids). # Return without error if avahi already exists - [ $(id avahi > /dev/null 2>&1) ] || return 0 + 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) ] ; + while ! cat /etc/passwd | cut -d ':' -f 3 | grep -q $avahi_id ; do avahi_id=$((500 + $RANDOM % 500)) done @@ -263,7 +263,7 @@ Do you want to proceed with YunoHost post-installation now? /usr/bin/yunohost tools postinstall local POSTINSTALL_EXIT_CODE="$?" - while [ "$POSTINSTALL_EXIT_CODE" -ne 0 ] ; + while [[ "$POSTINSTALL_EXIT_CODE" != "0" ]] ; do local text_retry=" Yunohost post-installation has failed. From 0b5ffbc9a7966873e5551dc9c47b5ac36960e86e Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Thu, 3 Sep 2015 18:23:14 +0200 Subject: [PATCH 07/25] Only redirect standard error otherwise the test always fails --- install_yunohostv2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index b2c9a8d..cba4fa4 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -121,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 > /dev/null 2>&1)" != "" ]] || hostname yunohost.yunohost.org > /dev/null 2>&1 + [[ "$(hostname -d 2>/dev/null)" != "" ]] || hostname yunohost.yunohost.org > /dev/null 2>&1 } confirm_installation() { From 97234cfcedc9335a450c30b9a15817c611032b85 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Sun, 6 Sep 2015 22:36:49 +0200 Subject: [PATCH 08/25] Apply shellcheck advices --- install_yunohostv2 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index cba4fa4..414ea2d 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -48,7 +48,7 @@ $1 " 1>&2 tput sgr 0 notify_about_install_logs - exit ${2:-1} + exit "${2:-1}" } this_script_path() { @@ -60,7 +60,7 @@ this_script_path() { [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - echo $DIR + echo "$DIR" } ensure_root() { @@ -85,7 +85,7 @@ installscript_dependencies() { -- \ apt-get -o Dpkg::Options::="--force-confold" \ -y install \ - $packages \ + "$packages" \ || return 2 return 0 @@ -148,7 +148,7 @@ setup_package_source() { echo "deb http://repo.yunohost.org/ megusta main" > $CUSTOMAPT # Also add repositories for 'testing' and/or 'unstable' if the script has been called with those arguments - if [[ "$#" > "0" ]]; then + if [[ "$#" -gt "0" ]]; then if [[ "$1" == "test" ]] || [[ "$1" == "testing" ]] ; then echo "deb http://repo.yunohost.org/ testing main" >> $CUSTOMAPT fi @@ -172,9 +172,9 @@ apt_update() { register_debconf() { if [[ $(lsb_release -c | awk '{print $2}') == jessie ]]; then - debconf-set-selections $(this_script_path)/debconfjessie + debconf-set-selections "$(this_script_path)/debconfjessie" else - debconf-set-selections $(this_script_path)/debconfv2 + debconf-set-selections "$(this_script_path)/debconfv2" fi } @@ -199,10 +199,10 @@ workaround_avahi_installation() { 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 -q $avahi_id ; + local avahi_id=$((500 + RANDOM % 500)) + while ! cut -d ':' -f 3 /etc/passwd | grep -q $avahi_id ; do - avahi_id=$((500 + $RANDOM % 500)) + avahi_id=$((500 + RANDOM % 500)) done # Use the same adduser parameter as in the avahi-daemon postinst script From edbde8450a0101554805e0149b634e75cc66e50f Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Sun, 6 Sep 2015 23:11:19 +0200 Subject: [PATCH 09/25] Integrate the debconf settings into the script to make it self-supporting --- install_yunohostv2 | 56 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 414ea2d..9c15ae8 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -172,9 +172,44 @@ apt_update() { register_debconf() { if [[ $(lsb_release -c | awk '{print $2}') == jessie ]]; then - debconf-set-selections "$(this_script_path)/debconfjessie" + cat << EOF > debconf-set-selections +slapd slapd/password1 password yunohost +slapd slapd/password2 password yunohost +slapd slapd/domain string yunohost.org +slapd shared/organization string yunohost.org +slapd slapd/allow_ldap_v2 boolean false +slapd slapd/invalid_config boolean true +slapd slapd/backend select MDB +postfix postfix/main_mailer_type select Internet Site +postfix postfix/mailname string /etc/mailname +mysql-server-5.5 mysql-server/root_password password yunohost +mysql-server-5.5 mysql-server/root_password_again password yunohost +nslcd nslcd/ldap-bindpw password +nslcd nslcd/ldap-starttls boolean false +nslcd nslcd/ldap-reqcert select +nslcd nslcd/ldap-uris string ldap://localhost/ +nslcd nslcd/ldap-binddn string +nslcd nslcd/ldap-base string dc=yunohost,dc=org +libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow +EOF else - debconf-set-selections "$(this_script_path)/debconfv2" + cat << EOF > debconf-set-selections +slapd slapd/password1 password yunohost +slapd slapd/password2 password yunohost +slapd slapd/domain string yunohost.org +slapd shared/organization string yunohost.org +postfix postfix/main_mailer_type select Internet Site +postfix postfix/mailname string /etc/mailname +mysql-server-5.5 mysql-server/root_password password yunohost +mysql-server-5.5 mysql-server/root_password_again password yunohost +nslcd nslcd/ldap-bindpw password +nslcd nslcd/ldap-starttls boolean false +nslcd nslcd/ldap-reqcert select +nslcd nslcd/ldap-uris string ldap://localhost/ +nslcd nslcd/ldap-binddn string +nslcd nslcd/ldap-base string dc=yunohost,dc=org +libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow +EOF fi } @@ -184,21 +219,21 @@ workaround_avahi_installation() { # 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 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) + + # Get a random unused uid between 500 and 999 (system-user) local avahi_id=$((500 + RANDOM % 500)) while ! cut -d ':' -f 3 /etc/passwd | grep -q $avahi_id ; do @@ -261,7 +296,7 @@ Do you want to proceed with YunoHost post-installation now? || return 0 /usr/bin/yunohost tools postinstall - + local POSTINSTALL_EXIT_CODE="$?" while [[ "$POSTINSTALL_EXIT_CODE" != "0" ]] ; do @@ -276,7 +311,7 @@ Do you want to try again now? /usr/bin/yunohost tools postinstall POSTINSTALL_EXIT_CODE="$?" done - return 0 + return 0 } # Treat unset variables as an error when performing @@ -289,7 +324,7 @@ if ! ensure_root ; then fi if ! installscript_dependencies ; then - die "Unable to install dependencies to install script" 2 + die "Unable to install dependencies to install script" 2 fi if ! create_custom_config ; then @@ -339,4 +374,3 @@ fi # Success ! success exit 0 - From f796569d97b04a2e4ef421855eea518d8a4e2b37 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Mon, 7 Sep 2015 00:00:43 +0200 Subject: [PATCH 10/25] Add automode, Use getopts, show usage with -h --- install_yunohostv2 | 58 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 9c15ae8..a1a207a 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -125,6 +125,8 @@ set_domain() { } confirm_installation() { + [[ "AUTOMODE" == "1" ]] && return 0 + local text=" Caution ! @@ -148,14 +150,12 @@ setup_package_source() { echo "deb http://repo.yunohost.org/ megusta main" > $CUSTOMAPT # Also add repositories for 'testing' and/or 'unstable' if the script has been called with those arguments - if [[ "$#" -gt "0" ]]; then - if [[ "$1" == "test" ]] || [[ "$1" == "testing" ]] ; then - echo "deb http://repo.yunohost.org/ testing main" >> $CUSTOMAPT - fi - if [[ "$1" == "daily" ]] || [[ "$1" == "unstable" ]] ; then - echo "deb http://repo.yunohost.org/ testing main" >> $CUSTOMAPT - echo "deb http://repo.yunohost.org/ unstable main" >> $CUSTOMAPT - fi + if [[ "$DISTRIB" == "test" ]] || [[ "$DISTRIB" == "testing" ]] ; then + echo "deb http://repo.yunohost.org/ testing main" >> $CUSTOMAPT + fi + if [[ "$DISTRIB" == "daily" ]] || [[ "$DISTRIB" == "unstable" ]] ; then + echo "deb http://repo.yunohost.org/ testing main" >> $CUSTOMAPT + echo "deb http://repo.yunohost.org/ unstable main" >> $CUSTOMAPT fi # Add YunoHost repository key to the keyring @@ -271,6 +271,9 @@ restart_services() { } post_install() { + # No postinstall in auto mode + [[ "AUTOMODE" == "1" ]] && return 0 + # Remove whiptail and dialog remains... clear @@ -314,11 +317,50 @@ Do you want to try again now? return 0 } +usage() { + print " +Usage `basename $0` [-a] [-d ] [-h] + +Options : + -a Enable automatic mode. No questions are asked. + This does not do the post-install step. + -d Choose the distribution to install ('stable', 'testing', 'unstable'). + Defaults to 'stable' + -h Prints this help +" +} + # Treat unset variables as an error when performing # parameter expansion. An error message will be written # to the standard error, and a non-interactive shell will exit. set -u +AUTOMODE=0 +DISTRIB=stable +while getopts ":ad:h" option; do + case $option in + a) + AUTOMODE=1 + export DEBIAN_FRONTEND=noninteractive + ;; + d) + DISTRIB=$OPTARG + ;; + h) + usage + exit 0 + ;; + :) + usage + exit 1 + ;; + \?) + usage + exit 1 + ;; + esac +done + if ! ensure_root ; then die "This script must be run as root" 1 fi From 46f3ae18a1d41535ba2ebf87325d40381d365846 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Tue, 8 Sep 2015 17:13:06 +0200 Subject: [PATCH 11/25] Support automatic installations --- install_yunohostv2 | 125 ++++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index a1a207a..b6e765b 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -15,13 +15,15 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +YUNOHOST_LOG="/var/log/yunohost.log" + print() { printf "%s\n" "$*"; } notify_about_install_logs() { print " -Installation logs are located in /var/log/yunohost.log +Installation logs are located in $YUNOHOST_LOG " 1>&2 } @@ -36,6 +38,15 @@ Success ! } die() { + # Print to log file + print " +Failure ! +The following error was caught during Yunohost installation : + +$1 +" >> $YUNOHOST_LOG + + # Print to terminal print "\ ==================================================" @@ -51,16 +62,12 @@ $1 exit "${2:-1}" } -this_script_path() { - # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in - local SOURCE="${BASH_SOURCE[0]}" - while [[ -h "$SOURCE" ]]; do # resolve $SOURCE until the file is no longer a symlink - local DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located - done - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - echo "$DIR" +step() { + echo "------ [ $(date --rfc-3339=seconds) ] - [ start $1 ] -------------------------------------" >> $YUNOHOST_LOG + $* + local return_code="$?" + echo "------ [ $(date --rfc-3339=seconds) ] - [ end $1 ] -------------------------------------" >> $YUNOHOST_LOG + return $return_code } ensure_root() { @@ -71,24 +78,27 @@ ensure_root() { return 0 } +apt_get_wrapper() { + if [[ "$AUTOMODE" == "0" ]] ; + then + debconf-apt-progress \ + --logfile $YUNOHOST_LOG \ + -- \ + apt-get $* + else + apt-get $* >> $YUNOHOST_LOG 2>&1 + fi +} + installscript_dependencies() { # install dependencies of the install script itself - local packages="lsb-release wget whiptail" + apt_get_wrapper update \ + || return 1 - debconf-apt-progress \ - --logfile /var/log/yunohost.log \ - -- \ - apt-get update \ - || return 1 - debconf-apt-progress \ - --logfile /var/log/yunohost.log \ - -- \ - apt-get -o Dpkg::Options::="--force-confold" \ - -y install \ - "$packages" \ - || return 2 - - return 0 + apt_get_wrapper -o Dpkg::Options::="--force-confold" \ + -y install \ + lsb-release wget whiptail \ + || return 2 } create_custom_config() { @@ -125,7 +135,7 @@ set_domain() { } confirm_installation() { - [[ "AUTOMODE" == "1" ]] && return 0 + [[ "$AUTOMODE" == "1" ]] && return 0 local text=" Caution ! @@ -163,10 +173,7 @@ setup_package_source() { } apt_update() { - debconf-apt-progress \ - --logfile /var/log/yunohost.log \ - -- \ - apt-get update + apt_get_wrapper update } register_debconf() { @@ -231,7 +238,10 @@ workaround_avahi_installation() { # consecutive uids). # Return without error if avahi already exists - id avahi > /dev/null 2>&1 || return 0 + if id avahi > /dev/null 2>&1 ; then + print "User avahi already exists (with uid $(id avahi)), skipping avahi workaround" >> $YUNOHOST_LOG + return 0 + fi # Get a random unused uid between 500 and 999 (system-user) local avahi_id=$((500 + RANDOM % 500)) @@ -240,6 +250,8 @@ workaround_avahi_installation() { avahi_id=$((500 + RANDOM % 500)) done + print "Workaround for avahi : creating avahi user with uid $avahi_id" >> $YUNOHOST_LOG + # Use the same adduser parameter as in the avahi-daemon postinst script # Just specify --uid explicitely adduser --disabled-password --quiet --system \ @@ -249,15 +261,13 @@ workaround_avahi_installation() { } install_yunohost_packages() { - debconf-apt-progress \ - --logfile /var/log/yunohost.log \ - -- \ - apt-get -o Dpkg::Options::="--force-confold" \ - -y install \ - yunohost yunohost-config \ - yunohost-config-postfix \ - postfix postfix-ldap \ - postfix-policyd-spf-perl + apt_get_wrapper \ + -o Dpkg::Options::="--force-confold" \ + -y install \ + yunohost yunohost-config \ + yunohost-config-postfix \ + postfix postfix-ldap \ + postfix-policyd-spf-perl } restart_services() { @@ -272,7 +282,7 @@ restart_services() { post_install() { # No postinstall in auto mode - [[ "AUTOMODE" == "1" ]] && return 0 + [[ "$AUTOMODE" == "1" ]] && return 0 # Remove whiptail and dialog remains... clear @@ -319,14 +329,15 @@ Do you want to try again now? usage() { print " -Usage `basename $0` [-a] [-d ] [-h] +Usage : + `basename $0` [-a] [-d ] [-h] Options : -a Enable automatic mode. No questions are asked. This does not do the post-install step. -d Choose the distribution to install ('stable', 'testing', 'unstable'). Defaults to 'stable' - -h Prints this help + -h Prints this help and exit " } @@ -361,55 +372,55 @@ while getopts ":ad:h" option; do esac done -if ! ensure_root ; then +if ! step ensure_root ; then die "This script must be run as root" 1 fi -if ! installscript_dependencies ; then +if ! step installscript_dependencies ; then die "Unable to install dependencies to install script" 2 fi -if ! create_custom_config ; then +if ! step create_custom_config ; then die "Creating custom configuration file /etc/yunohost/yunohost.conf failed" 3 fi -if ! set_domain ; then +if ! step set_domain ; then die "Setting hostname failed" 4 fi -if ! confirm_installation ; then +if ! step confirm_installation ; then die "Installation cancelled at your request" 5 fi -if ! setup_package_source "$@" ; then +if ! step setup_package_source ; then die "Setting up deb package sources failed" 6 fi -if ! apt_update ; then +if ! step apt_update ; then die "Error caught during 'apt-get update'" 7 fi -if ! register_debconf ; then +if ! step register_debconf ; then die "Unable to insert new values into debconf database" 8 fi -if ! workaround_avahi_installation ; then +if ! step workaround_avahi_installation ; then die "Unable to install workaround for avahi installation" 20 fi -if ! install_yunohost_packages ; then +if ! step install_yunohost_packages ; then die "\ Installation of Yunohost packages failed -You can check the install logs saved in /var/log/yunohost.log +You can check the install logs saved in $YUNOHOST_LOG " 9 fi -if ! restart_services ; then +if ! step restart_services ; then die "Error caught during services restart" 10 fi -if ! post_install ; then +if ! step post_install ; then die "Post-installation failed" 11 fi From 2e7274682963e310992964033a8b63ea89f20ba4 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Tue, 8 Sep 2015 17:13:43 +0200 Subject: [PATCH 12/25] Remove unnecessary files --- autoinstall_yunohostv2 | 174 ----------------------------------- debconfjessie | 18 ---- debconfv1 | 14 --- debconfv2 | 15 ---- install_yunohostv1 | 199 ----------------------------------------- 5 files changed, 420 deletions(-) delete mode 100755 autoinstall_yunohostv2 delete mode 100644 debconfjessie delete mode 100644 debconfv1 delete mode 100644 debconfv2 delete mode 100755 install_yunohostv1 diff --git a/autoinstall_yunohostv2 b/autoinstall_yunohostv2 deleted file mode 100755 index d8f754c..0000000 --- a/autoinstall_yunohostv2 +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/bash - -SUCCESS=0 -ERR_FAIL_RESTORE=1 -ERR_FAIL_UPDATE=2 -ERR_FAIL_INSTALL=3 -ERR_CANCEL_INSTALL=4 -ERR_IMPOSSIBLE=-1 -NO_ERR=0 - -function bck { - FULLPATH="$(readlink -f "$1")" - DST="${2%/}/$(dirname $FULLPATH)" - mkdir -p "$DST" - cp -r --preserve=all "$FULLPATH" "$DST/$(basename $FULLPATH)" -} - -function rst { - [[ ! -d "$LEGACY" ]] && echo >&2 "Rollback failed : Unknown folder $LEGACY" && exit $ERR_FAIL_RESTORE - cp -rf "$LEGACY"/* / - [[ $? -ne 0 ]] && echo >&2 "Rollback failed" && exit $ERR_FAIL_RESTORE -} - -set -u -echo "Check rights" - -if [ "$(id -u)" != "0" ]; then - echo "This script must be run as root" 1>&2 - exit 1 -fi - -# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - -echo "Running from $DIR" - -echo "Check dependencies" - -apt-get update -qq -for i in lsb-release wget dialog whiptail -do - dpkg -l | grep -q $i - if [[ $? -eq 1 ]] - then - apt-get install $i -y - fi -done - -# Fix install on jessie -if [ $(lsb_release -c | awk '{print $2}') = jessie ]; -then - apt-get install python-xmpp -y -fi - -if [[ ! -f /etc/yunohost/yunohost.conf ]] -then -mkdir /etc/yunohost/ -touch /etc/yunohost/from_script -cat << EOF > /etc/yunohost/yunohost.conf -# Yunohost custom config -# If you want to keep a custom service configuration replace "no" by "yes" -# for the concerned service - -amavis=no -avahi=no -dovecot=no -iptables=no -metronome=no -mysql=no -nginx=no -postfix=no -samba=no -slapd=no -ssh=yes -ssowat=no -EOF -fi - -echo "Checking domain" -DOMAIN=$(hostname -d) -if [[ "${DOMAIN:-1}" = 1 ]] -then - hostname yunohost.yunohost.org - DOMAIN='yunohost.org' -fi - -YESNO=0 - -if [[ $YESNO -eq 0 ]] -then - # Backup folder for legacy config files - LEGACY=/etc/yunohost/.legacy - mkdir -p "$LEGACY" - - echo "Adding repositories" - - CUSTOMAPT=/etc/apt/sources.list - - grep -qri "yunohost" $CUSTOMAPT - if [[ $? -eq 1 ]] - then - echo "deb http://repo.yunohost.org/ megusta main" >> $CUSTOMAPT - fi - - if [ $# -gt 0 ]; then - if [[ "$1" == "test" ]] || [[ "$1" == "testing" ]] ; then - echo "deb http://daily.yunohost.org/ testing main" >> $CUSTOMAPT - fi - if [[ "$1" == "daily" ]] || [[ "$1" == "unstable" ]] ; then - echo "deb http://daily.yunohost.org/ testing main" >> $CUSTOMAPT - echo "deb http://daily.yunohost.org/ unstable main" >> $CUSTOMAPT - fi - fi - - #Get gpg key - wget -O- http://repo.yunohost.org/yunohost.asc -q | apt-key add - -qq - - #Update repo - apt-get update -qq - - if [[ $? -ne 0 ]] - then - echo "Update Repo Failure : Rolling back" - rst "$LEGACY" - exit $ERR_FAIL_UPDATE - fi - - chmod 755 / * - - echo "Installation" - #add answer in debconf db - if [ $(lsb_release -c | awk '{print $2}') = jessie ]; - then - debconf-set-selections $DIR/debconfjessie - else - debconf-set-selections $DIR/debconfv2 - fi - - #Install yunohost packages - apt-get -o Dpkg::Options::="--force-confold" \ - -y install \ - -qq \ - yunohost \ - yunohost-config \ - yunohost-config-postfix \ - postfix postfix-ldap \ - postfix-policyd-spf-perl - - if [[ $? -ne 0 ]] - then - echo "Installation failed !" - echo "Rolling back have to be done manually" - echo "Check your legacy configuration files => '$LEGACY'" - echo "Check install logs => '/var/log/yunohost.log' and '/var/log/yunohost.error'" - exit $ERR_FAIL_INSTALL - else - service slapd restart - - echo -e "\n" - fi - -else - echo "Installation cancelled" - exit $ERR_CANCEL_INSTALL -fi - -# Security : we shouldn't be able to exit here -exit $NO_ERR diff --git a/debconfjessie b/debconfjessie deleted file mode 100644 index 391b44e..0000000 --- a/debconfjessie +++ /dev/null @@ -1,18 +0,0 @@ -slapd slapd/password1 password yunohost -slapd slapd/password2 password yunohost -slapd slapd/domain string yunohost.org -slapd shared/organization string yunohost.org -slapd slapd/allow_ldap_v2 boolean false -slapd slapd/invalid_config boolean true -slapd slapd/backend select MDB -postfix postfix/main_mailer_type select Internet Site -postfix postfix/mailname string /etc/mailname -mysql-server-5.5 mysql-server/root_password password yunohost -mysql-server-5.5 mysql-server/root_password_again password yunohost -nslcd nslcd/ldap-bindpw password -nslcd nslcd/ldap-starttls boolean false -nslcd nslcd/ldap-reqcert select -nslcd nslcd/ldap-uris string ldap://localhost/ -nslcd nslcd/ldap-binddn string -nslcd nslcd/ldap-base string dc=yunohost,dc=org -libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow diff --git a/debconfv1 b/debconfv1 deleted file mode 100644 index 3f20d02..0000000 --- a/debconfv1 +++ /dev/null @@ -1,14 +0,0 @@ -postfix postfix/main_mailer_type select Internet Site -postfix postfix/mailname string /etc/mailname -mysql-server-5.1 mysql-server/root_password password yunohost -mysql-server-5.1 mysql-server/root_password_again password yunohost -samba-common samba-common/workgroup string WORKGROUP -samba-common samba-common/workgroup boolean true -nslcd nslcd/ldap-bindpw password -nslcd nslcd/ldap-starttls boolean false -nslcd nslcd/ldap-reqcert select -nslcd nslcd/ldap-uris string ldap://localhost/ -nslcd nslcd/ldap-binddn string -nslcd nslcd/ldap-base string dc=yunohost,dc=org -proftpd-basic shared/proftpd/inetd_or_standalone select standalone -libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow diff --git a/debconfv2 b/debconfv2 deleted file mode 100644 index 6b0bfb9..0000000 --- a/debconfv2 +++ /dev/null @@ -1,15 +0,0 @@ -slapd slapd/password1 password yunohost -slapd slapd/password2 password yunohost -slapd slapd/domain string yunohost.org -slapd shared/organization string yunohost.org -postfix postfix/main_mailer_type select Internet Site -postfix postfix/mailname string /etc/mailname -mysql-server-5.5 mysql-server/root_password password yunohost -mysql-server-5.5 mysql-server/root_password_again password yunohost -nslcd nslcd/ldap-bindpw password -nslcd nslcd/ldap-starttls boolean false -nslcd nslcd/ldap-reqcert select -nslcd nslcd/ldap-uris string ldap://localhost/ -nslcd nslcd/ldap-binddn string -nslcd nslcd/ldap-base string dc=yunohost,dc=org -libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow diff --git a/install_yunohostv1 b/install_yunohostv1 deleted file mode 100755 index 72aa5ab..0000000 --- a/install_yunohostv1 +++ /dev/null @@ -1,199 +0,0 @@ -#!/bin/bash - -SUCCESS=0 -ERR_FAIL_RESTORE=1 -ERR_FAIL_UPDATE=2 -ERR_FAIL_INSTALL=3 -ERR_CANCEL_INSTALL=4 -ERR_IMPOSSIBLE=-1 - -function bck { - FULLPATH="$(readlink -f "$1")" - DST="${2%/}/$(dirname $FULLPATH)" - mkdir -p "$DST" - cp -r --preserve=all "$FULLPATH" "$DST/$(basename $FULLPATH)" -} - -function rst { - [[ ! -d "$LEGACY" ]] && echo >&2 "Rollback failed : Unknown folder $LEGACY" && exit $ERR_FAIL_RESTORE - cp -rf "$LEGACY"/* / - [[ $? -ne 0 ]] && echo >&2 "Rollback failed" && exit $ERR_FAIL_RESTORE -} - -set -u -echo "======== Check rights ========" - -if [ "$(id -u)" != "0" ]; then - echo "This script must be run as root" 1>&2 - exit 1 -fi - -echo "======== YunoHost Installation ========" -echo "======== Check dependences ========" - -apt-get update -qq -for i in lsb-release wget whiptail -do - dpkg -l | grep -q $i - if [[ $? -eq 1 ]] - then - apt-get install $i -y - fi -done - -if [[ ! -f /etc/yunohost/yunohost.conf ]] -then -mkdir /etc/yunohost/ -cat << EOF > /etc/yunohost/yunohost.conf -#Yunohost custom config -#to enable yunohost custom config change no by yes - -amavis=no -apache2=no -dovecot=no -ejabberd=no -iptables=no -lemonldap-ng=no -postfix=no -proftpd=no -radicale=no -samba=no -slapd=no -ssh=yes -mysql=no -EOF -fi - -echo "======== Checking domain ========" -DOMAIN=$(hostname -d) -if [[ "${DOMAIN:-1}" = 1 ]] -then - echo "======== Installation failed ========" - echo "Configure your domain name please" - exit $ERR_IMPOSSIBLE -fi - -whiptail --title "Yunohost Installation" --yesno "Your domain is $DOMAIN\nDo you want to change this?" 8 78 -YESNO=$? - -case $YESNO in - 0) DOMAIN=$(whiptail --inputbox "Enter your new domain please" 8 78 --title "Yunohost Installation" 3>&1 1>&2 2>&3);; # - 1) ;; # => Noting to do here. Just keeping it for the record - *) echo >&2 "ERROR: Unknown error ($YESNO) occured. Exiting"; exit $YESNO;; # ERROR -esac - -[[ -z "$DOMAIN" ]] && DOMAIN="$(hostname -d)" - -whiptail --title "Yunohost Installation" --yesno "Caution : your config files for postfix,dovecot,mysql,apache,ejabberd,radicale will be overwritten\nDo you want to proceed install of Yunohost?" 8 78 -YESNO=$? - -if [[ $YESNO -eq 0 ]] -then - # Backup folder for legacy config files - LEGACY=/etc/yunohost/.legacy - mkdir -p "$LEGACY" - - echo "======== Updating hostname ========" - # Update hostname - bck /etc/hostname "$LEGACY" - echo "yunohost" > /etc/hostname - # Update hosts - if [[ $(grep -c "yunohost.$DOMAIN" /etc/hosts) -eq 0 ]] - then - bck /etc/hosts "$LEGACY" - cat < /etc/hosts -127.0.0.1 localhost -127.0.1.1 yunohost.$DOMAIN yunohost - -# The following lines are desirable for IPv6 capable hosts -::1 ip6-localhost ip6-loopback -fe00::0 ip6-localnet -ff00::0 ip6-mcastprefix -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters -EOF - echo -e "127.0.0.1\tyunohost.$DOMAIN\tyunohost" > /etc/hosts - /etc/init.d/hostname.sh start - fi - - echo "======== Adding repositories ========" - CUSTOMAPT=/etc/apt/sources.list - - grep -qri "yunohost" $CUSTOMAPT - if [[ $? -eq 1 ]] - then - if [ "$(lsb_release -cs)" != "squeeze" ]; - then - whiptail --title "Yunohost Installation" --msgbox "Your operating system is not compatible with yunohost v1" 8 78 - exit $ERR_FAIL_INSTALL - fi - fi - - grep -qri "lemonldap" $CUSTOMAPT - if [[ $? -eq 1 ]] - then - echo "deb http://lemonldap-ng.org/deb squeeze main" >> $CUSTOMAPT - fi - - #Get gpg key - wget -O- http://lemonldap-ng.org/_media/rpm-gpg-key-ow2 -q | apt-key add - -qq - wget -O- http://repo.yunohost.org/yunohost.asc -q | apt-key add - -qq - - - #Update repo - debconf-apt-progress \ - --logfile /var/log/yunohost-update.log \ - -- \ - apt-get update - - if [[ $? -ne 0 ]] - then - echo "Update Repo Failure : Rolling back" - rst "$LEGACY" - exit $ERR_FAIL_UPDATE - fi - - echo "======== Install ========" - #add answer in debconf db - debconf-set-selections debconfv1 - - #Install yunohost packages - debconf-apt-progress \ - --logfile /var/log/yunohost.log \ - -- \ - apt-get -o Dpkg::Options::="--force-confold" \ - -y install \ - yunohost \ - yunohost-config \ - yunohost-config-postfix \ - postfix postfix-ldap \ - postfix-policyd-spf-perl - - if [[ $? -ne 0 ]] - then - echo "======== Installation failed ========" - echo "Rolling back have to be done manually !" - echo "Check your legacy configuration files => '$LEGACY'" - echo "Check install logs => '/var/log/yunohost.log' and '/var/log/yunohost.error'" - exit $ERR_FAIL_INSTALL - else - service slapd restart - service apache2 restart - service dovecot restart - service postfix restart - service ejabberd restart - service iptables start - service nscd restart - service nslcd restart - whiptail --title "Yunohost Installation" --msgbox "Installation success" 8 78 - exit $SUCCESS - fi - -else - echo "======== Installation cancelled ========" - - exit $ERR_CANCEL_INSTALL -fi - -# Security : we shouldn't be able to exit here -exit $ERR_IMPOSSIBLE From 75399aad8cb1018310c23dbb0184ad200062f110 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Tue, 8 Sep 2015 17:20:05 +0200 Subject: [PATCH 13/25] Wording --- install_yunohostv2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index b6e765b..68d6923 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -334,7 +334,7 @@ Usage : Options : -a Enable automatic mode. No questions are asked. - This does not do the post-install step. + This does not perform the post-install step. -d Choose the distribution to install ('stable', 'testing', 'unstable'). Defaults to 'stable' -h Prints this help and exit From 0f6cc2173b4cc6f0827c86c4a9f49cc7e581fa1d Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Tue, 8 Sep 2015 17:22:31 +0200 Subject: [PATCH 14/25] Add install_yunohost symlink --- install_yunohost | 1 + 1 file changed, 1 insertion(+) create mode 120000 install_yunohost diff --git a/install_yunohost b/install_yunohost new file mode 120000 index 0000000..b15d145 --- /dev/null +++ b/install_yunohost @@ -0,0 +1 @@ +install_yunohostv2 \ No newline at end of file From 338c12bea0fd5b98bffc88a574672fd03e195bf9 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Tue, 8 Sep 2015 17:50:12 +0200 Subject: [PATCH 15/25] Update readme --- README.md | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 27f2f55..4bb218f 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,44 @@ -# Script +# YunoHost installation script -## Prérequis +## Context -Afin de pouvoir récupérer le script install_yunohost, il faut avoir git d'installé sur votre machine. +The scripts in this repository will install [YunoHost](https://yunohost.org/) on a Debian system. -Pour l'installer sur une distribution Debian: +Only Debian 7 (aka wheezy) and 8 (aka jessie) are supported. - # apt-get install git +## Basic usage -ou - - $ sudo apt-get install git - -## Récuperation du script - -Placez vous tout d'abord dans le répertoire /tmp: +Go into a temporary folder, e.g. ```/tmp```: $ cd /tmp -Récupérez le script grâce à git: +Get the install script: - $ git clone https://github.com/YunoHost/install_script.git + $ wget https://raw.githubusercontent.com/YunoHost/install_script/master/install_yunohostv2 -Déplacez vous dans le répertoire Script nouvellement cloné: +Execute the script: - $ cd install_script/ + $ bash install_yunohostv2 -Rendez le script install_yunohost exécutable: +If something goes wrong, you can check the installation logs saved in ```/var/log/yunohost.log``` - $ chmod o+x install_yunohost +## Advanced usage -Exécutez le script: +The script supports a number of positionnal arguments: - $ ./install_yunohostv1 + $ bash install_yunohostv2 -h + Usage : + install_yunohostv2 [-a] [-d ] [-h] -ou + Options : + -a Enable automatic mode. No questions are asked. + This does not perform the post-install step. + -d Choose the distribution to install ('stable', 'testing', 'unstable'). + Defaults to 'stable' + -h Prints this help and exit - $ ./install_yunohostv2 +By specifying ```-a```, the installation will be performed without asking any question. +This is usefull for fully automated headless installation. +You will need to perform the post-installation later. - -Le script va automatiquement lancer l'installation de yunohost sur votre poste ainsi que tous les paquets nécessaires. Répondez simplement aux questions qui vous seront posées. +The ```-d ``` switch is mostly for advanced users who wants to install the bleeding edge versions of YunoHost packages. From b47bd6a4c218ee4bde75fd64da5150f752819a71 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Tue, 8 Sep 2015 17:54:17 +0200 Subject: [PATCH 16/25] Fix readme wording and grammar --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4bb218f..43a3c95 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# YunoHost installation script +# YunoHost installation scripts ## Context @@ -24,7 +24,7 @@ If something goes wrong, you can check the installation logs saved in ```/var/lo ## Advanced usage -The script supports a number of positionnal arguments: +The script supports a number of positional arguments: $ bash install_yunohostv2 -h Usage : @@ -38,7 +38,7 @@ The script supports a number of positionnal arguments: -h Prints this help and exit By specifying ```-a```, the installation will be performed without asking any question. -This is usefull for fully automated headless installation. -You will need to perform the post-installation later. +This is useful for fully automated headless installations. +The [post-installation](https://yunohost.org/#/postinstall) will need to be performed later. -The ```-d ``` switch is mostly for advanced users who wants to install the bleeding edge versions of YunoHost packages. +The ```-d ``` switch is mostly for advanced users who want to install the bleeding edge versions of YunoHost packages. From a57efabd4f61479035e8457245092a85a0f5d977 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Wed, 9 Sep 2015 09:58:37 +0200 Subject: [PATCH 17/25] Nicer step by step logging --- install_yunohostv2 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 68d6923..392d53f 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -63,10 +63,9 @@ $1 } step() { - echo "------ [ $(date --rfc-3339=seconds) ] - [ start $1 ] -------------------------------------" >> $YUNOHOST_LOG + printf "[ $(date --rfc-3339=seconds) ] ----- [ entering %-30s ]\n" "$1" >> $YUNOHOST_LOG $* local return_code="$?" - echo "------ [ $(date --rfc-3339=seconds) ] - [ end $1 ] -------------------------------------" >> $YUNOHOST_LOG return $return_code } From 459dc9cbab770c6ac30464be78a2c242a0007077 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Wed, 9 Sep 2015 09:59:16 +0200 Subject: [PATCH 18/25] Realign exit codes --- install_yunohostv2 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 392d53f..e9974a5 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -404,23 +404,19 @@ if ! step register_debconf ; then fi if ! step workaround_avahi_installation ; then - die "Unable to install workaround for avahi installation" 20 + die "Unable to install workaround for avahi installation" 9 fi if ! step install_yunohost_packages ; then - die "\ -Installation of Yunohost packages failed - -You can check the install logs saved in $YUNOHOST_LOG -" 9 + die "Installation of Yunohost packages failed" 10 fi if ! step restart_services ; then - die "Error caught during services restart" 10 + die "Error caught during services restart" 11 fi if ! step post_install ; then - die "Post-installation failed" 11 + die "Post-installation failed" 12 fi # Success ! From bc19749f014ea1c05d8de70db3261e227f4dff23 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Wed, 9 Sep 2015 11:39:00 +0200 Subject: [PATCH 19/25] Upgrade system before starting install --- install_yunohostv2 | 58 +++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index e9974a5..057592a 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -YUNOHOST_LOG="/var/log/yunohost.log" +YUNOHOST_LOG="/var/log/yunohost-installation.log" print() { printf "%s\n" "$*"; @@ -30,9 +30,7 @@ Installation logs are located in $YUNOHOST_LOG success() { tput setf 2 - print " -Success ! -" + print "Success !" tput sgr 0 notify_about_install_logs } @@ -47,17 +45,16 @@ $1 " >> $YUNOHOST_LOG # Print to terminal - print "\ -==================================================" - tput setf 4 - print " -Failure ! -The following error was caught during Yunohost installation : + print "Failure !" + tput sgr 0 + + print "\ +The following error was caught during YunoHost installation : $1 " 1>&2 - tput sgr 0 + notify_about_install_logs exit "${2:-1}" } @@ -89,15 +86,20 @@ apt_get_wrapper() { fi } +upgrade_system() { + apt_get_wrapper update \ + || return 1 + + apt_get_wrapper -y dist-upgrade \ + || return 2 +} + installscript_dependencies() { # install dependencies of the install script itself - apt_get_wrapper update \ - || return 1 - apt_get_wrapper -o Dpkg::Options::="--force-confold" \ -y install \ lsb-release wget whiptail \ - || return 2 + || return 1 } create_custom_config() { @@ -375,48 +377,52 @@ if ! step ensure_root ; then die "This script must be run as root" 1 fi +if ! step upgrade_system ; then + die "Unable to update the system" 2 +fi + if ! step installscript_dependencies ; then - die "Unable to install dependencies to install script" 2 + die "Unable to install dependencies to install script" 3 fi if ! step create_custom_config ; then - die "Creating custom configuration file /etc/yunohost/yunohost.conf failed" 3 + die "Creating custom configuration file /etc/yunohost/yunohost.conf failed" 4 fi if ! step set_domain ; then - die "Setting hostname failed" 4 + die "Setting hostname failed" 5 fi if ! step confirm_installation ; then - die "Installation cancelled at your request" 5 + die "Installation cancelled at your request" 6 fi if ! step setup_package_source ; then - die "Setting up deb package sources failed" 6 + die "Setting up deb package sources failed" 7 fi if ! step apt_update ; then - die "Error caught during 'apt-get update'" 7 + die "Error caught during 'apt-get update'" 8 fi if ! step register_debconf ; then - die "Unable to insert new values into debconf database" 8 + die "Unable to insert new values into debconf database" 9 fi if ! step workaround_avahi_installation ; then - die "Unable to install workaround for avahi installation" 9 + die "Unable to install workaround for avahi installation" 10 fi if ! step install_yunohost_packages ; then - die "Installation of Yunohost packages failed" 10 + die "Installation of Yunohost packages failed" 11 fi if ! step restart_services ; then - die "Error caught during services restart" 11 + die "Error caught during services restart" 12 fi if ! step post_install ; then - die "Post-installation failed" 12 + die "Post-installation failed" 13 fi # Success ! From 47f342a44b814b49a67fb2d1f5695f605f3c84fc Mon Sep 17 00:00:00 2001 From: Zamentur aka ljf Date: Sat, 26 Sep 2015 23:12:37 +0200 Subject: [PATCH 20/25] [fix] Allow to create a DockerFile by ignore hostname change failure --- install_yunohostv2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 057592a..4e5752b 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -132,7 +132,8 @@ 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 2>/dev/null)" != "" ]] || hostname yunohost.yunohost.org > /dev/null 2>&1 + [[ "$(hostname -d 2>/dev/null)" != "" ]] || hostname yunohost.yunohost.org \ + || echo 'Hostname change is not permitted' > /dev/null 2>&1 } confirm_installation() { From ad502ef188ed193fa66e704e0166aade08d71581 Mon Sep 17 00:00:00 2001 From: Zamentur aka ljf Date: Sat, 26 Sep 2015 23:27:23 +0200 Subject: [PATCH 21/25] [fix] Remove completely the set_domain to allow DockerFile creation The hostname is change in post installation --- install_yunohostv2 | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 4e5752b..bb2a4e4 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -128,14 +128,6 @@ EOF fi } -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 2>/dev/null)" != "" ]] || hostname yunohost.yunohost.org \ - || echo 'Hostname change is not permitted' > /dev/null 2>&1 -} - confirm_installation() { [[ "$AUTOMODE" == "1" ]] && return 0 @@ -390,40 +382,36 @@ if ! step create_custom_config ; then die "Creating custom configuration file /etc/yunohost/yunohost.conf failed" 4 fi -if ! step set_domain ; then - die "Setting hostname failed" 5 -fi - if ! step confirm_installation ; then - die "Installation cancelled at your request" 6 + die "Installation cancelled at your request" 5 fi if ! step setup_package_source ; then - die "Setting up deb package sources failed" 7 + die "Setting up deb package sources failed" 6 fi if ! step apt_update ; then - die "Error caught during 'apt-get update'" 8 + die "Error caught during 'apt-get update'" 7 fi if ! step register_debconf ; then - die "Unable to insert new values into debconf database" 9 + die "Unable to insert new values into debconf database" 8 fi if ! step workaround_avahi_installation ; then - die "Unable to install workaround for avahi installation" 10 + die "Unable to install workaround for avahi installation" 9 fi if ! step install_yunohost_packages ; then - die "Installation of Yunohost packages failed" 11 + die "Installation of Yunohost packages failed" 10 fi if ! step restart_services ; then - die "Error caught during services restart" 12 + die "Error caught during services restart" 11 fi if ! step post_install ; then - die "Post-installation failed" 13 + die "Post-installation failed" 12 fi # Success ! From 688b42de1d5324fd0e9f94fa114074fb2465fdd5 Mon Sep 17 00:00:00 2001 From: Le Kload Date: Mon, 28 Sep 2015 00:13:35 +0200 Subject: [PATCH 22/25] [fix] Force dependency install --- install_yunohostv2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index bb2a4e4..34a2297 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -97,7 +97,7 @@ upgrade_system() { installscript_dependencies() { # install dependencies of the install script itself apt_get_wrapper -o Dpkg::Options::="--force-confold" \ - -y install \ + -y --force-yes install \ lsb-release wget whiptail \ || return 1 } @@ -257,7 +257,7 @@ workaround_avahi_installation() { install_yunohost_packages() { apt_get_wrapper \ -o Dpkg::Options::="--force-confold" \ - -y install \ + -y --force-yes install \ yunohost yunohost-config \ yunohost-config-postfix \ postfix postfix-ldap \ From ed1de840f8b7ee59295fa2dd40f7ffe4841ba625 Mon Sep 17 00:00:00 2001 From: zamentur Date: Mon, 28 Sep 2015 23:09:23 +0200 Subject: [PATCH 23/25] [fix] Bad debconf command --- install_yunohostv2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 34a2297..6d74f1e 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -173,7 +173,7 @@ apt_update() { register_debconf() { if [[ $(lsb_release -c | awk '{print $2}') == jessie ]]; then - cat << EOF > debconf-set-selections + debconf-set-selections << EOF slapd slapd/password1 password yunohost slapd slapd/password2 password yunohost slapd slapd/domain string yunohost.org @@ -194,7 +194,7 @@ nslcd nslcd/ldap-base string dc=yunohost,dc=org libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow EOF else - cat << EOF > debconf-set-selections + debconf-set-selections << EOF slapd slapd/password1 password yunohost slapd slapd/password2 password yunohost slapd slapd/domain string yunohost.org From 21be853424479dce38da67f90a6dc07a8fe3214c Mon Sep 17 00:00:00 2001 From: zamentur Date: Tue, 29 Sep 2015 00:05:29 +0200 Subject: [PATCH 24/25] [fix] Random avahi adduser not working correctly --- install_yunohostv2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 6d74f1e..98a802a 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -239,7 +239,7 @@ workaround_avahi_installation() { # Get a random unused uid between 500 and 999 (system-user) local avahi_id=$((500 + RANDOM % 500)) - while ! cut -d ':' -f 3 /etc/passwd | grep -q $avahi_id ; + while cut -d ':' -f 3 /etc/passwd | grep -q $avahi_id ; do avahi_id=$((500 + RANDOM % 500)) done From 35d9857286c60183c206ff634203612c45778dbc Mon Sep 17 00:00:00 2001 From: zamentur Date: Tue, 29 Sep 2015 00:06:32 +0200 Subject: [PATCH 25/25] [fix] Service nscd was not started at the end of the installation --- install_yunohostv2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index 98a802a..1f99d6d 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -267,8 +267,8 @@ install_yunohost_packages() { restart_services() { service slapd restart # service yunohost-firewall start -# service nscd restart -# service nslcd restart + service nscd restart + service nslcd restart # NOTE : We don't fail if slapd fails to restart... return 0