mirror of
https://github.com/YunoHost/install_script.git
synced 2024-09-03 20:06:25 +02:00
add check DOMAIN and ROOT
This commit is contained in:
parent
ad76357778
commit
56442e33e4
1 changed files with 35 additions and 30 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash -x
|
||||||
|
|
||||||
SUCCESS=0
|
SUCCESS=0
|
||||||
ERR_FAIL_RESTORE=1
|
ERR_FAIL_RESTORE=1
|
||||||
|
@ -20,15 +20,18 @@ function rst {
|
||||||
[[ $? -ne 0 ]] && echo >&2 "Rollback failed" && exit $ERR_FAIL_RESTORE
|
[[ $? -ne 0 ]] && echo >&2 "Rollback failed" && exit $ERR_FAIL_RESTORE
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO : test if the script is executed as root
|
|
||||||
|
|
||||||
set -u
|
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 "======== YunoHost Installation ========"
|
||||||
echo "======== Check dependences ========"
|
echo "======== Check dependences ========"
|
||||||
|
|
||||||
dpkg -l | grep -q lsb-release
|
dpkg -l | grep -q lsb-release
|
||||||
# @abeudin : Using double brackets is more "secure" (kind of) => http://tldp.org/LDP/abs/html/testconstructs.html#DBLBRACKETS
|
|
||||||
if [[ $? -eq 1 ]]
|
if [[ $? -eq 1 ]]
|
||||||
then
|
then
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
|
@ -58,13 +61,20 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "======== Checking domain ========"
|
echo "======== Checking domain ========"
|
||||||
|
if [[ "${DOMAIN:-1}" = 1 ]]
|
||||||
|
then
|
||||||
|
echo "======== Installation failed ========"
|
||||||
|
echo "Configure your domain name please"
|
||||||
|
exit $ERR_IMPOSSIBLE
|
||||||
|
fi
|
||||||
|
|
||||||
whiptail --title "Yunohost Domain" --yesno "Your domain is $DOMAIN\nDo you want to change this?" 8 78
|
whiptail --title "Yunohost Domain" --yesno "Your domain is $DOMAIN\nDo you want to change this?" 8 78
|
||||||
YESNO=$?
|
YESNO=$?
|
||||||
|
|
||||||
case $YESNO in
|
case $YESNO in
|
||||||
0) DOMAIN=$(whiptail --inputbox "Enter your new domain please" 8 78 --title "Yunohost Domain" 3>&1 1>&2 2>&3);; # <YES>
|
0) DOMAIN=$(whiptail --inputbox "Enter your new domain please" 8 78 --title "Yunohost Domain" 3>&1 1>&2 2>&3);; # <YES>
|
||||||
1) ;; # <NO> => Noting to do here. Just keeping it for the record
|
1) ;; # <NO> => Noting to do here. Just keeping it for the record
|
||||||
*) echo >&2 "ERROR: Unknown error ($YESNO) occured. Exiting"; exit $YESNO;; # ERROR
|
*) echo >&2 "ERROR: Unknown error ($YESNO) occured. Exiting"; exit $YESNO;; # ERROR
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[[ -z "$DOMAIN" ]] && DOMAIN="$(hostname -d)"
|
[[ -z "$DOMAIN" ]] && DOMAIN="$(hostname -d)"
|
||||||
|
@ -74,18 +84,18 @@ YESNO=$?
|
||||||
|
|
||||||
if [[ $YESNO -eq 0 ]]
|
if [[ $YESNO -eq 0 ]]
|
||||||
then
|
then
|
||||||
# Backup folder for legacy config files
|
# Backup folder for legacy config files
|
||||||
LEGACY=/etc/yunohost/.legacy
|
LEGACY=/etc/yunohost/.legacy
|
||||||
mkdir -p "$LEGACY"
|
mkdir -p "$LEGACY"
|
||||||
|
|
||||||
echo "======== Updating hostname ========"
|
echo "======== Updating hostname ========"
|
||||||
# Update hostname
|
# Update hostname
|
||||||
bck /etc/hostname "$LEGACY"
|
bck /etc/hostname "$LEGACY"
|
||||||
echo "yunohost" > /etc/hostname
|
echo "yunohost" > /etc/hostname
|
||||||
# Update hosts
|
# Update hosts
|
||||||
if [[ $(grep -c "yunohost.$DOMAIN" /etc/hosts) -eq 0 ]]
|
if [[ $(grep -c "yunohost.$DOMAIN" /etc/hosts) -eq 0 ]]
|
||||||
then
|
then
|
||||||
bck /etc/hosts "$LEGACY"
|
bck /etc/hosts "$LEGACY"
|
||||||
echo -e "127.0.0.1\tyunohost.$DOMAIN\tyunohost" > /etc/hosts
|
echo -e "127.0.0.1\tyunohost.$DOMAIN\tyunohost" > /etc/hosts
|
||||||
/etc/init.d/hostname.sh start
|
/etc/init.d/hostname.sh start
|
||||||
fi
|
fi
|
||||||
|
@ -95,14 +105,14 @@ then
|
||||||
wget -O- http://lemonldap-ng.org/_media/rpm-gpg-key-ow2 -q | apt-key add - -qq
|
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
|
wget -O- http://repo.yunohost.org/yunohost.asc -q | apt-key add - -qq
|
||||||
|
|
||||||
CUSTOMAPT=/etc/apt/sources.list.d/yunohost.list
|
CUSTOMAPT=/etc/apt/sources.list
|
||||||
grep -qri "lemonldap-ng.org" /etc/apt/sources.list*
|
grep -qri "lemonldap-ng.org" $CUSTOMAPT
|
||||||
if [[ $? -eq 1 ]]
|
if [[ $? -eq 1 ]]
|
||||||
then
|
then
|
||||||
echo "deb http://lemonldap-ng.org/deb squeeze main" >> $CUSTOMAPT
|
echo "deb http://lemonldap-ng.org/deb squeeze main" >> $CUSTOMAPT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
grep -qri "yunohost" /etc/apt/sources.list*
|
grep -qri "yunohost" $CUSTOMAPT
|
||||||
if [[ $? -eq 1 ]]
|
if [[ $? -eq 1 ]]
|
||||||
then
|
then
|
||||||
case "$(lsb_release -is)" in
|
case "$(lsb_release -is)" in
|
||||||
|
@ -121,9 +131,9 @@ then
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
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 ========"
|
||||||
|
@ -131,10 +141,6 @@ then
|
||||||
debconf-set-selections debconf
|
debconf-set-selections debconf
|
||||||
|
|
||||||
#Install yunohost packages
|
#Install yunohost packages
|
||||||
<<<<<<< HEAD
|
|
||||||
debconf-apt-progress --logstderr /var/log/yunohost.log -- apt-get -y install yunohost yunohost-config yunohost-config-postfix postfix postfix-ldap postfix-policyd-spf-perl
|
|
||||||
if [ $? != 0 ] ;
|
|
||||||
=======
|
|
||||||
debconf-apt-progress \
|
debconf-apt-progress \
|
||||||
--logfile /var/log/yunohost.log \
|
--logfile /var/log/yunohost.log \
|
||||||
--logstderr /var/log/yunohost.error \
|
--logstderr /var/log/yunohost.error \
|
||||||
|
@ -147,13 +153,12 @@ then
|
||||||
postfix-policyd-spf-perl
|
postfix-policyd-spf-perl
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]
|
if [[ $? -ne 0 ]]
|
||||||
>>>>>>> 307fa4b0a8fd8391ae5be4caffd1252d9397b012
|
|
||||||
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 "Check install logs => '/var/log/yunohost.log' and '/var/log/yunohost.error'"
|
||||||
exit $ERR_FAIL_INSTALL
|
exit $ERR_FAIL_INSTALL
|
||||||
else
|
else
|
||||||
service slapd restart
|
service slapd restart
|
||||||
service apache2 restart
|
service apache2 restart
|
||||||
|
@ -164,7 +169,7 @@ then
|
||||||
service nscd restart
|
service nscd restart
|
||||||
service nslcd restart
|
service nslcd restart
|
||||||
echo "======== Installation success ========"
|
echo "======== Installation success ========"
|
||||||
exit $SUCCESS
|
exit $SUCCESS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue