update script

This commit is contained in:
Adrien Beudin 2013-05-13 11:14:15 +02:00
parent 4781d66a3f
commit 35a593e4d6
4 changed files with 177 additions and 51 deletions

View file

View file

@ -18,4 +18,3 @@ proftpd-basic shared/proftpd/inetd_or_standalone select standalone
iptables-persistent iptables-persistent/autosave_v6 boolean false
iptables-persistent iptables-persistent/autosave_v4 boolean false
libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow

View file

@ -61,7 +61,6 @@ samba=no
slapd=no
ssh=yes
mysql=no
prosody=no
EOF
fi
@ -74,11 +73,11 @@ then
exit $ERR_IMPOSSIBLE
fi
whiptail --title "Yunohost Domain" --yesno "Your domain is $DOMAIN\nDo you want to change this?" 8 78
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 Domain" 3>&1 1>&2 2>&3);; # <YES>
0) DOMAIN=$(whiptail --inputbox "Enter your new domain please" 8 78 --title "Yunohost Installation" 3>&1 1>&2 2>&3);; # <YES>
1) ;; # <NO> => Noting to do here. Just keeping it for the record
*) echo >&2 "ERROR: Unknown error ($YESNO) occured. Exiting"; exit $YESNO;; # ERROR
esac
@ -118,51 +117,29 @@ EOF
fi
echo "======== Adding repositories ========"
#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
CUSTOMAPT=/etc/apt/sources.list
#if [[ "$(lsb_release -cs)" = "wheezy" ]] || [[ "$(lsb_release -cs)" = "n/a" ]]
#then
# whiptail --title "Yunohost Installation" --yesno "Caution : Yunohost v2 is in development.\nDo you want to proceed install of Yunohost?" 8 78
# YESNO=$?
# if [[ $YESNO -eq 1 ]]
# then
# echo "======== Installation cancelled ========"
# exit $ERR_CANCEL_INSTALL
# fi
#fi
grep -qri "yunohost" $CUSTOMAPT
if [[ $? -eq 1 ]]
then
case "$(lsb_release -cs)" in
"squeeze")
echo "deb http://repo.yunohost.org/ squeeze main" >> $CUSTOMAPT
echo "deb http://repo.yunohost.org/ apps main" >> $CUSTOMAPT
;;
"wheezy"|"n/a")
echo "deb http://repo.yunohost.org/ megusta main" >> $CUSTOMAPT
echo "deb http://repo.yunohost.org/ apps main" >> $CUSTOMAPT
;;
esac
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
case "$(lsb_release -cs)" in
"squeeze")
echo "deb http://lemonldap-ng.org/deb squeeze main" >> $CUSTOMAPT
;;
"wheezy"|"n/a")
echo "deb http://repo.yunohost.org/ lemonldap main" >> $CUSTOMAPT
;;
esac
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 \
@ -178,13 +155,7 @@ EOF
echo "======== Install ========"
#add answer in debconf db
if [[ $(lsb_release -cs) = "squeeze" ]];
then
debconf-set-selections debconf
elif [[ $(lsb_release -cs) = "wheezy" ]] || [[ $(lsb_release -cs) = "n/a" ]];
then
debconf-set-selections debconfv2
fi
debconf-set-selections debconfv1
#Install yunohost packages
debconf-apt-progress \
@ -210,21 +181,17 @@ EOF
service apache2 restart
service dovecot restart
service postfix restart
if [ "$(lsb_release -cs)" = squeeze ];
then
service ejabberd restart
else
service prosody restart
fi
service ejabberd restart
service iptables start
service nscd restart
service nslcd restart
echo "======== Installation success ========"
whiptail --title "Yunohost Installation" --msgbox "Installation success" 8 78
exit $SUCCESS
fi
else
echo "======== Installation cancelled ========"
exit $ERR_CANCEL_INSTALL
fi

160
install_yunohostv2 Normal file
View file

@ -0,0 +1,160 @@
#!/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
iptables=no
lemonldap-ng=no
postfix=no
proftpd=no
radicale=no
samba=no
slapd=no
ssh=yes
mysql=no
prosody=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 "Caution : your config files for postfix,dovecot,mysql,apache,prosody,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 "======== 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
grep -qri "lemonldap" $CUSTOMAP
if [[ $? -eq 1 ]]
then
echo "deb http://repo.yunohost.org/ lemonldap 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 debconfv2
#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 prosody restart
service iptables start
service nscd restart
service nslcd restart
IP=$(/sbin/ifconfig | sed '/Bcast/!d' | awk '{print $2}' | sed 's/.*\://')
whiptail --title "Yunohost Installation" --msgbox "Installation success\n Connect to http://$IP:6767 for finish installation" 8 78
fi
else
echo "======== Installation cancelled ========"
exit $ERR_CANCEL_INSTALL
fi
# Security : we shouldn't be able to exit here
exit $ERR_IMPOSSIBLE