Skip to content
Snippets Groups Projects
Commit 0b6f992f authored by sebastien curt's avatar sebastien curt
Browse files

InstallNextcloud.sh

    - BugFix : LC_ALL="en_US.utf-8"
    - BugFix : error outputs
    - BugFix : apg installed if not installed
installMySQL.sh
    - Before installation the root password can be set
parent 9f276192
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ set -o nounset # Treat unset variables as an error ...@@ -20,6 +20,7 @@ set -o nounset # Treat unset variables as an error
apt-get clean apt-get clean
# Add stable backports to source.list and set preferences
if ! $(grep -Rq "jessie-backports" /etc/apt/sources.list /etc/apt/sources.list.d) if ! $(grep -Rq "jessie-backports" /etc/apt/sources.list /etc/apt/sources.list.d)
then then
( (
...@@ -37,6 +38,7 @@ then ...@@ -37,6 +38,7 @@ then
) > /etc/apt/preferences.d/backports ) > /etc/apt/preferences.d/backports
fi fi
apt-get update apt-get update
DEBIAN_FRONTEND='noninteractive' apt-get -qq install \ DEBIAN_FRONTEND='noninteractive' apt-get -qq install \
......
...@@ -30,7 +30,7 @@ set -o nounset # Treat unset variables as an error ...@@ -30,7 +30,7 @@ set -o nounset # Treat unset variables as an error
DEBIAN_FRONTEND='noninteractive' apt-get -qq install mysql-server \ DEBIAN_FRONTEND='noninteractive' apt-get -qq install mysql-server \
apg expect apg expect
mysqlPassword="$(apg -q -a 0 -n 1 -m 21 -E "\"\'\`" -M NCL)" MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-$(apg -q -a 0 -n 1 -m 21 -M NCL)}
# Save in Root home directory connection configuration # Save in Root home directory connection configuration
if [ ! -e "${HOME}/.my.cnf" ] if [ ! -e "${HOME}/.my.cnf" ]
...@@ -38,11 +38,15 @@ then ...@@ -38,11 +38,15 @@ then
{ {
echo "[client]" echo "[client]"
echo "user=root" echo "user=root"
echo "password=${mysqlPassword}" echo "password=${MYSQL_ROOT_PASSWORD}"
echo ""
echo "[mysqldump]"
echo "user=root"
echo "password=${MYSQL_ROOT_PASSWORD}"
} | tee '/root/.my.cnf' > "${HOME}/.my.cnf"; } | tee '/root/.my.cnf' > "${HOME}/.my.cnf";
chmod 400 '/root/.my.cnf' "${HOME}/.my.cnf"; chmod 400 '/root/.my.cnf' "${HOME}/.my.cnf";
else else
echo "MySQL already configured" >2 echo "MySQL already configured" >&2
exit exit
fi fi
...@@ -61,10 +65,10 @@ echo "expect -re \"Set root password\?.*\"" ...@@ -61,10 +65,10 @@ echo "expect -re \"Set root password\?.*\""
echo "send \"y\r\"" echo "send \"y\r\""
echo "expect -re \"New password:.*\"" echo "expect -re \"New password:.*\""
echo "send \"${mysqlPassword}\r\"" echo "send \"${MYSQL_ROOT_PASSWORD}\r\""
echo "expect \"Re-enter new password:\"" echo "expect \"Re-enter new password:\""
echo "send \"${mysqlPassword}\r\"" echo "send \"${MYSQL_ROOT_PASSWORD}\r\""
echo "expect -re \"Remove anonymous users\?.*\"" echo "expect -re \"Remove anonymous users\?.*\""
echo "send \"y\r\"" echo "send \"y\r\""
...@@ -87,16 +91,16 @@ expect ${configureMySQLFile} ...@@ -87,16 +91,16 @@ expect ${configureMySQLFile}
# allow PHP to access to mysql # allow PHP to access to mysql
mysql -e " mysql -e "
GRANT ALL PRIVILEGES on *.* to 'root'@'localhost' IDENTIFIED BY GRANT ALL PRIVILEGES on *.* to 'root'@'localhost' IDENTIFIED BY
'${mysqlPassword}'; '${MYSQL_ROOT_PASSWORD}';
GRANT ALL PRIVILEGES on *.* to 'root'@'127.0.0.1' IDENTIFIED BY GRANT ALL PRIVILEGES on *.* to 'root'@'127.0.0.1' IDENTIFIED BY
'${mysqlPassword}'; '${MYSQL_ROOT_PASSWORD}';
FLUSH PRIVILEGES;" FLUSH PRIVILEGES;"
# Cleanup # Cleanup
rm -v ${configureMySQLFile} # Remove the generated Expect script rm -v ${configureMySQLFile} # Remove the generated Expect script
unset configureMySQLFile unset configureMySQLFile
unset mysqlPassword unset MYSQL_ROOT_PASSWORD
echo "MySQL setup completed. Insecure defaults are gone. Please remove" echo "MySQL setup completed. Insecure defaults are gone. Please remove"
echo " this script manually when you are done with it (or at least " echo " this script manually when you are done with it (or at least "
......
...@@ -27,6 +27,8 @@ set -o nounset # Treat unset variables as an error ...@@ -27,6 +27,8 @@ set -o nounset # Treat unset variables as an error
SCRIPT_DIRECTORY=`pwd` SCRIPT_DIRECTORY=`pwd`
. `pwd`/installNextcloud.env . `pwd`/installNextcloud.env
RUNNING_DATE_TIME="`$(date +%Y%m%d%H%M%S)`"
if [ ! -d $NEXTCLOUD_DIRECTORY_SOURCES ] if [ ! -d $NEXTCLOUD_DIRECTORY_SOURCES ]
then then
...@@ -36,12 +38,12 @@ fi ...@@ -36,12 +38,12 @@ fi
cd $NEXTCLOUD_DIRECTORY_SOURCES cd $NEXTCLOUD_DIRECTORY_SOURCES
# 1. Download Nexcloud Package # 1. Download Nexcloud Package
DEBIAN_FRONTEND='noninteractive' apt-get -qq install wget gnupg2 \ DEBIAN_FRONTEND='noninteractive' apt-get -qq install wget gnupg2 \
bzip2 tar apache2 isomd5sum ufw sudo bzip2 tar apache2 isomd5sum ufw sudo apg
if [ -d ${NEXTCLOUD_INSTALL_DIR} ] if [ -d ${NEXTCLOUD_INSTALL_DIR} ]
then then
echo "Nextcloud install directory already exists : " \ echo "Nextcloud install directory already exists : " \
${NEXTCLOUD_INSTALL_DIR} >2 ${NEXTCLOUD_INSTALL_DIR} >&2
return return
fi fi
...@@ -75,14 +77,14 @@ gpg2 --import nextcloud.asc ...@@ -75,14 +77,14 @@ gpg2 --import nextcloud.asc
# 2. Check package integrity and source authenticity # 2. Check package integrity and source authenticity
md5sum --quiet -c ${NEXTCLOUD_PACKAGE}.md5 < ${NEXTCLOUD_PACKAGE} \ md5sum --quiet -c ${NEXTCLOUD_PACKAGE}.md5 < ${NEXTCLOUD_PACKAGE} \
&& gpg2 --verbose --batch --output - --no-auto-check-trustdb \ && LC_ALL="en_US.utf-8" gpg2 --verbose --batch --output - \
--verify ${NEXTCLOUD_PACKAGE}.asc ${NEXTCLOUD_PACKAGE} \ --no-auto-check-trustdb --verify ${NEXTCLOUD_PACKAGE}.asc \
2>&1 | grep -q "Good signature" ${NEXTCLOUD_PACKAGE} 2>&1 | grep -q "Good signature"
# stop if the package isn't reliable # stop if the package isn't reliable
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "Nextcloud packages unsafe" >2 echo "Nextcloud packages unsafe" >&2
return return
fi fi
...@@ -91,7 +93,7 @@ tar xf ${NEXTCLOUD_VERSION}.tar ...@@ -91,7 +93,7 @@ tar xf ${NEXTCLOUD_VERSION}.tar
cp -r nextcloud $(dirname ${NEXTCLOUD_INSTALL_DIR%/}) cp -r nextcloud $(dirname ${NEXTCLOUD_INSTALL_DIR%/})
chown -R www-data:www-data ${NEXTCLOUD_INSTALL_DIR} chown -R www-data:www-data ${NEXTCLOUD_INSTALL_DIR}
sudo -u www-data php ${NEXTCLOUD_INSTALL_DIR}occ -V | grep -q "Nextcloud is not installed" LC_ALL="en_US.utf-8" sudo -u www-data php ${NEXTCLOUD_INSTALL_DIR}occ -V | grep -q "Nextcloud is not installed"
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
...@@ -204,19 +206,30 @@ cd ${SCRIPT_DIRECTORY} ...@@ -204,19 +206,30 @@ cd ${SCRIPT_DIRECTORY}
. `pwd`/nextcloudStrongDirectoryPermissions.sh . `pwd`/nextcloudStrongDirectoryPermissions.sh
if [ -f /etc/apache2/nextcloud-ssl.conf ]
then
cp /etc/apache2/nextcloud-ssl.conf \
/etc/apache2/${RUNNING_DATE_TIME}_nextcloud-ssl.conf
fi
if [ -f /etc/apache2/ssl.conf ]
then
cp /etc/apache2/ssl.conf /etc/apache2/${RUNNING_DATE_TIME}_ssl.conf
fi
# Configure Apache for nextcloud # Configure Apache for nextcloud
#echo "Configure Apache nextcloud-ssl.conf" echo "Configure Apache nextcloud-ssl.conf"
#sed \ sed \
# "s@<+NEXTCLOUD_CONFIG_ServerAdmin+>@${NEXTCLOUD_CONFIG_ServerAdmin}@ "s@<+NEXTCLOUD_CONFIG_ServerAdmin+>@${NEXTCLOUD_CONFIG_ServerAdmin}@
# s@<+NEXTCLOUD_CONFIG_ServerName+>@${NEXTCLOUD_CONFIG_ServerName}@" \ s@<+NEXTCLOUD_CONFIG_ServerName+>@${NEXTCLOUD_CONFIG_ServerName}@" \
#`pwd`/template_nextcloud-ssl.conf > \ `pwd`/template_nextcloud-ssl.conf > \
# /etc/apache2/sites-available/nextcloud-ssl.conf /etc/apache2/sites-available/nextcloud-ssl.conf
#sed \ sed \
# "s@<+SSLCertificateFile+>@${NEXTCLOUD_CONFIG_certificateFile:-<+SSLCertificateFile+>}@ "s@<+SSLCertificateFile+>@${NEXTCLOUD_CONFIG_certificateFile:-<+SSLCertificateFile+>}@
# s@<+SSLCertificateKeyFile+>@${NEXTCLOUD_CONFIG_certificateKeyFile:-<+SSLCertificateKeyFile+>}@" \ s@<+SSLCertificateKeyFile+>@${NEXTCLOUD_CONFIG_certificateKeyFile:-<+SSLCertificateKeyFile+>}@" \
# `pwd`/template_ssl.conf > \ `pwd`/template_ssl.conf > \
# /etc/apache2/ssl.conf /etc/apache2/ssl.conf
#ln -s /etc/apache2/sites-available/nextcloud-ssl.conf \ #ln -s /etc/apache2/sites-available/nextcloud-ssl.conf \
...@@ -224,27 +237,30 @@ cd ${SCRIPT_DIRECTORY} ...@@ -224,27 +237,30 @@ cd ${SCRIPT_DIRECTORY}
#echo "WARNING : SSLEngine is disabled : to enable modify file /etc/apache2/ssl.conf" #echo "WARNING : SSLEngine is disabled : to enable modify file /etc/apache2/ssl.conf"
#echo "Configure Apache nextcloud-ssl.conf : terminated" #echo "Configure Apache nextcloud-ssl.conf : terminated"
#echo "a2enmod rewrite" echo "a2enmod rewrite"
#a2enmod rewrite a2enmod rewrite
#echo "a2enmod rewrite : terminated" echo "a2enmod rewrite : terminated"
#echo "a2enmod headers" echo "a2enmod headers"
#a2enmod headers a2enmod headers
#echo "a2enmod env" echo "a2enmod env"
#a2enmod env a2enmod env
#echo "a2enmod env : terminated" echo "a2enmod env : terminated"
#echo "a2enmod dir" echo "a2enmod dir"
#a2enmod dir a2enmod dir
#echo "a2enmod dir : terminated" echo "a2enmod dir : terminated"
#echo "a2enmod mime" echo "a2enmod mime"
#a2enmod mime a2enmod mime
#echo "a2enmod mime : terminated" echo "a2enmod mime : terminated"
#echo "a2enmod ssl" echo "a2enmod ssl"
#a2enmod ssl a2enmod ssl
#echo "a2enmod ssl : terminated" echo "a2enmod ssl : terminated"
#
#echo "service apache2 restart" echo "service apache2 restart"
#service apache2 restart service apache2 restart
#echo "service apache2 restart : terminated" echo "service apache2 restart : terminated"
echo "WARNING : apache ssl isn't activated => to activate it : run following" \
"command : " \
"a2enmod ssl; a2ensite default-ssl; service apache2 reload"
# activation ssl # activation ssl
#a2enmod ssl #a2enmod ssl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment