mirror of
https://github.com/YunoHost/install_script.git
synced 2024-09-03 20:06:25 +02:00
update script
This commit is contained in:
parent
4781d66a3f
commit
35a593e4d6
4 changed files with 177 additions and 51 deletions
|
@ -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_v6 boolean false
|
||||||
iptables-persistent iptables-persistent/autosave_v4 boolean false
|
iptables-persistent iptables-persistent/autosave_v4 boolean false
|
||||||
libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow
|
libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,6 @@ samba=no
|
||||||
slapd=no
|
slapd=no
|
||||||
ssh=yes
|
ssh=yes
|
||||||
mysql=no
|
mysql=no
|
||||||
prosody=no
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -74,11 +73,11 @@ then
|
||||||
exit $ERR_IMPOSSIBLE
|
exit $ERR_IMPOSSIBLE
|
||||||
fi
|
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=$?
|
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 Installation" 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
|
||||||
|
@ -118,51 +117,29 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "======== Adding repositories ========"
|
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
|
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
|
grep -qri "yunohost" $CUSTOMAPT
|
||||||
if [[ $? -eq 1 ]]
|
if [[ $? -eq 1 ]]
|
||||||
then
|
then
|
||||||
case "$(lsb_release -cs)" in
|
if [ "$(lsb_release -cs)" != "squeeze" ];
|
||||||
"squeeze")
|
then
|
||||||
echo "deb http://repo.yunohost.org/ squeeze main" >> $CUSTOMAPT
|
whiptail --title "Yunohost Installation" --msgbox "Your operating system is not compatible with yunohost v1" 8 78
|
||||||
echo "deb http://repo.yunohost.org/ apps main" >> $CUSTOMAPT
|
exit $ERR_FAIL_INSTALL
|
||||||
;;
|
fi
|
||||||
"wheezy"|"n/a")
|
|
||||||
echo "deb http://repo.yunohost.org/ megusta main" >> $CUSTOMAPT
|
|
||||||
echo "deb http://repo.yunohost.org/ apps main" >> $CUSTOMAPT
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
grep -qri "lemonldap" $CUSTOMAPT
|
grep -qri "lemonldap" $CUSTOMAPT
|
||||||
if [[ $? -eq 1 ]]
|
if [[ $? -eq 1 ]]
|
||||||
then
|
then
|
||||||
case "$(lsb_release -cs)" in
|
echo "deb http://lemonldap-ng.org/deb squeeze main" >> $CUSTOMAPT
|
||||||
"squeeze")
|
|
||||||
echo "deb http://lemonldap-ng.org/deb squeeze main" >> $CUSTOMAPT
|
|
||||||
;;
|
|
||||||
"wheezy"|"n/a")
|
|
||||||
echo "deb http://repo.yunohost.org/ lemonldap main" >> $CUSTOMAPT
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
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
|
#Update repo
|
||||||
debconf-apt-progress \
|
debconf-apt-progress \
|
||||||
--logfile /var/log/yunohost-update.log \
|
--logfile /var/log/yunohost-update.log \
|
||||||
|
@ -178,13 +155,7 @@ EOF
|
||||||
|
|
||||||
echo "======== Install ========"
|
echo "======== Install ========"
|
||||||
#add answer in debconf db
|
#add answer in debconf db
|
||||||
if [[ $(lsb_release -cs) = "squeeze" ]];
|
debconf-set-selections debconfv1
|
||||||
then
|
|
||||||
debconf-set-selections debconf
|
|
||||||
elif [[ $(lsb_release -cs) = "wheezy" ]] || [[ $(lsb_release -cs) = "n/a" ]];
|
|
||||||
then
|
|
||||||
debconf-set-selections debconfv2
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Install yunohost packages
|
#Install yunohost packages
|
||||||
debconf-apt-progress \
|
debconf-apt-progress \
|
||||||
|
@ -210,21 +181,17 @@ EOF
|
||||||
service apache2 restart
|
service apache2 restart
|
||||||
service dovecot restart
|
service dovecot restart
|
||||||
service postfix restart
|
service postfix restart
|
||||||
if [ "$(lsb_release -cs)" = squeeze ];
|
service ejabberd restart
|
||||||
then
|
|
||||||
service ejabberd restart
|
|
||||||
else
|
|
||||||
service prosody restart
|
|
||||||
fi
|
|
||||||
service iptables start
|
service iptables start
|
||||||
service nscd restart
|
service nscd restart
|
||||||
service nslcd restart
|
service nslcd restart
|
||||||
echo "======== Installation success ========"
|
whiptail --title "Yunohost Installation" --msgbox "Installation success" 8 78
|
||||||
exit $SUCCESS
|
exit $SUCCESS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "======== Installation cancelled ========"
|
echo "======== Installation cancelled ========"
|
||||||
|
|
||||||
exit $ERR_CANCEL_INSTALL
|
exit $ERR_CANCEL_INSTALL
|
||||||
fi
|
fi
|
||||||
|
|
160
install_yunohostv2
Normal file
160
install_yunohostv2
Normal 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
|
Loading…
Add table
Reference in a new issue