mirror of
https://github.com/YunoHost/install_script.git
synced 2024-09-03 20:06:25 +02:00
Minor changes of install_yunohostv2
This commit is contained in:
parent
e648b905c2
commit
0151e7a0b7
1 changed files with 46 additions and 32 deletions
|
@ -7,24 +7,28 @@ ERR_FAIL_INSTALL=3
|
||||||
ERR_CANCEL_INSTALL=4
|
ERR_CANCEL_INSTALL=4
|
||||||
ERR_IMPOSSIBLE=-1
|
ERR_IMPOSSIBLE=-1
|
||||||
|
|
||||||
function bck {
|
bck() {
|
||||||
FULLPATH="$(readlink -f "$1")"
|
FULLPATH="$(readlink -f "$1")"
|
||||||
DST="${2%/}/$(dirname $FULLPATH)"
|
DST="${2%/}/$(dirname $FULLPATH)"
|
||||||
mkdir -p "$DST"
|
mkdir -p "$DST"
|
||||||
cp -r --preserve=all "$FULLPATH" "$DST/$(basename $FULLPATH)"
|
cp -r --preserve=all "$FULLPATH" "$DST/$(basename $FULLPATH)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function rst {
|
rst() {
|
||||||
[[ ! -d "$LEGACY" ]] && echo >&2 "Rollback failed : Unknown folder $LEGACY" && exit $ERR_FAIL_RESTORE
|
if [[ ! -d "$LEGACY" ]]; then;
|
||||||
cp -rf "$LEGACY"/* /
|
echo >&2 "Rollback failed: Unknown folder $LEGACY" && exit $ERR_FAIL_RESTORE
|
||||||
[[ $? -ne 0 ]] && echo >&2 "Rollback failed" && exit $ERR_FAIL_RESTORE
|
fi
|
||||||
|
cp -rf -- "$LEGACY"/* /
|
||||||
|
if [[ $? -ne 0 ]]; then;
|
||||||
|
echo >&2 "Rollback failed" && exit $ERR_FAIL_RESTORE
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
echo "======== Get path of current script ======="
|
echo '======== Get path of current script ======='
|
||||||
|
|
||||||
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
|
# https://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
|
||||||
SOURCE="${BASH_SOURCE[0]}"
|
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
|
||||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
@ -35,15 +39,19 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
|
||||||
echo "Running from $DIR"
|
echo "Running from $DIR"
|
||||||
|
|
||||||
echo "======== Check rights ========"
|
echo '======== Check rights ========'
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != '0' ]; then
|
||||||
echo "This script must be run as root" 1>&2
|
echo 'This script must be run as root' 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "======== YunoHost Installation ========"
|
echo '======== YunoHost Installation ========'
|
||||||
echo "======== Check dependencies ========"
|
echo '======== Check dependencies ========'
|
||||||
|
|
||||||
|
WHIPTAIL_HEIGHT=8
|
||||||
|
WHIPTAIL_WIDTH=78
|
||||||
|
WHIPTAIL_DIM="$WHIPTAIL_HEIGHT $WHIPTAIL_WIDTH"
|
||||||
|
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
for i in lsb-release wget dialog whiptail
|
for i in lsb-release wget dialog whiptail
|
||||||
|
@ -85,7 +93,7 @@ ssowat=no
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "======== Checking domain ========"
|
echo '======== Checking domain ========'
|
||||||
DOMAIN=$(hostname -d)
|
DOMAIN=$(hostname -d)
|
||||||
if [[ "${DOMAIN:-1}" = 1 ]]
|
if [[ "${DOMAIN:-1}" = 1 ]]
|
||||||
then
|
then
|
||||||
|
@ -93,7 +101,8 @@ then
|
||||||
DOMAIN='yunohost.org'
|
DOMAIN='yunohost.org'
|
||||||
fi
|
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
|
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?" $WHIPTAIL_DIM
|
||||||
YESNO=$?
|
YESNO=$?
|
||||||
|
|
||||||
if [[ $YESNO -eq 0 ]]
|
if [[ $YESNO -eq 0 ]]
|
||||||
|
@ -102,28 +111,28 @@ then
|
||||||
LEGACY=/etc/yunohost/.legacy
|
LEGACY=/etc/yunohost/.legacy
|
||||||
mkdir -p "$LEGACY"
|
mkdir -p "$LEGACY"
|
||||||
|
|
||||||
echo "======== Adding repositories ========"
|
echo '======== Adding repositories ========'
|
||||||
|
|
||||||
CUSTOMAPT=/etc/apt/sources.list
|
CUSTOMAPT=/etc/apt/sources.list
|
||||||
|
|
||||||
grep -qri "yunohost" $CUSTOMAPT
|
grep -qri 'yunohost' $CUSTOMAPT
|
||||||
if [[ $? -eq 1 ]]
|
if [[ $? -eq 1 ]]
|
||||||
then
|
then
|
||||||
echo "deb http://repo.yunohost.org/ megusta main" >> $CUSTOMAPT
|
echo 'deb http://repo.yunohost.org/ megusta main' >> $CUSTOMAPT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
if [[ "$1" == "test" ]] || [[ "$1" == "testing" ]] ; then
|
if [[ "$1" == 'test' ]] || [[ "$1" == 'testing' ]] ; then
|
||||||
echo "deb http://daily.yunohost.org/ testing main" >> $CUSTOMAPT
|
echo 'deb http://daily.yunohost.org/ testing main' >> $CUSTOMAPT
|
||||||
fi
|
fi
|
||||||
if [[ "$1" == "daily" ]] || [[ "$1" == "unstable" ]] ; then
|
if [[ "$1" == 'daily' ]] || [[ "$1" == 'unstable' ]] ; then
|
||||||
echo "deb http://daily.yunohost.org/ testing main" >> $CUSTOMAPT
|
echo 'deb http://daily.yunohost.org/ testing main' >> $CUSTOMAPT
|
||||||
echo "deb http://daily.yunohost.org/ unstable main" >> $CUSTOMAPT
|
echo 'deb http://daily.yunohost.org/ unstable main' >> $CUSTOMAPT
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Get gpg key
|
#Get gpg key
|
||||||
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
|
||||||
|
|
||||||
#Update repo
|
#Update repo
|
||||||
debconf-apt-progress \
|
debconf-apt-progress \
|
||||||
|
@ -133,12 +142,12 @@ then
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]
|
if [[ $? -ne 0 ]]
|
||||||
then
|
then
|
||||||
echo "Update Repo Failure : Rolling back"
|
echo 'Update Repo Failure: Rolling back'
|
||||||
rst "$LEGACY"
|
rst "$LEGACY"
|
||||||
exit $ERR_FAIL_UPDATE
|
exit $ERR_FAIL_UPDATE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "======== Install ========"
|
echo '======== Install ========'
|
||||||
#add answer in debconf db
|
#add answer in debconf db
|
||||||
if [ $(lsb_release -c | awk '{print $2}') = jessie ];
|
if [ $(lsb_release -c | awk '{print $2}') = jessie ];
|
||||||
then
|
then
|
||||||
|
@ -161,10 +170,15 @@ then
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]
|
if [[ $? -ne 0 ]]
|
||||||
then
|
then
|
||||||
echo "======== Installation failed ========"
|
echo '======== Installation failed ========'
|
||||||
echo "Rolling back have to be done manually !"
|
echo 'Rolling back have to be done manually !'
|
||||||
echo "Check your legacy configuration files => '$LEGACY'"
|
echo "Check your legacy configuration files => '$LEGACY'"
|
||||||
echo "Check install logs => '/var/log/yunohost.log' and '/var/log/yunohost.error'"
|
echo -n 'Check install logs => "/var/log/yunohost.log"'
|
||||||
|
if test -e /var/log/yunohost.error
|
||||||
|
then
|
||||||
|
echo -n ' and "/var/log/yunohost.error"'
|
||||||
|
fi
|
||||||
|
echo
|
||||||
exit $ERR_FAIL_INSTALL
|
exit $ERR_FAIL_INSTALL
|
||||||
else
|
else
|
||||||
service slapd restart
|
service slapd restart
|
||||||
|
@ -176,7 +190,7 @@ then
|
||||||
service nslcd restart
|
service nslcd restart
|
||||||
|
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
whiptail --title "Post-installation" --yesno "Proceed to post-installation?" 8 78
|
whiptail --title 'Post-installation' --yesno 'Proceed to post-installation?' $WHIPTAIL_DIM
|
||||||
YESNO=$?
|
YESNO=$?
|
||||||
RESULT=1
|
RESULT=1
|
||||||
while [ $RESULT -gt 0 ]; do
|
while [ $RESULT -gt 0 ]; do
|
||||||
|
@ -186,7 +200,7 @@ then
|
||||||
let RESULT=$?
|
let RESULT=$?
|
||||||
if [ $RESULT -gt 0 ]; then
|
if [ $RESULT -gt 0 ]; then
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
whiptail --title "Post-installation" --yesno "Post-installation failed, retry ?" 8 78
|
whiptail --title 'Post-installation' --yesno 'Post-installation failed, retry?' $WHIPTAIL_DIM
|
||||||
let YESNO=$?
|
let YESNO=$?
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -196,7 +210,7 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "======== Installation cancelled ========"
|
echo '======== Installation cancelled ========'
|
||||||
exit $ERR_CANCEL_INSTALL
|
exit $ERR_CANCEL_INSTALL
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue