mirror of
https://github.com/YunoHost/install_script.git
synced 2024-09-03 20:06:25 +02:00
Remove unnecessary files
This commit is contained in:
parent
46f3ae18a1
commit
2e72746829
5 changed files with 0 additions and 420 deletions
|
@ -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
|
|
@ -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
|
14
debconfv1
14
debconfv1
|
@ -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
|
15
debconfv2
15
debconfv2
|
@ -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
|
|
@ -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);; # <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
|
||||
|
||||
[[ -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 <<EOF > /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
|
Loading…
Add table
Reference in a new issue