install_nextcloud.sh: support colaboraonline on nginx hosts.
This commit is contained in:
parent
d8e0a7bac0
commit
3b50776610
@ -1162,9 +1162,9 @@ echo "IPV4=$IPV4" >> $log_file
|
||||
echo "IPV6=$IPV6" >> $log_file
|
||||
echo "SRC_BASE_DIR=$SRC_BASE_DIR" >> $log_file
|
||||
if $apache2_installed ; then
|
||||
echo "apache_vhost_dir=$apache_vhost_dir"
|
||||
echo "apache_vhost_dir=$apache_vhost_dir" >> $log_file
|
||||
elif $nginx_installed ; then
|
||||
echo "nginx_vhost_dir=$nginx_vhost_dir"
|
||||
echo "nginx_vhost_dir=$nginx_vhost_dir" >> $log_file
|
||||
fi
|
||||
echo "HTTP_USER=$HTTP_USER" >> $log_file
|
||||
echo "HTTP_GROUP=$HTTP_GROUP" >> $log_file
|
||||
@ -1203,8 +1203,16 @@ echo "# -----" >> $log_file
|
||||
|
||||
if ! $INSTALL_REDIS_SERVICE ; then
|
||||
if $REDIS_SERVICE_INSTALLED ; then
|
||||
|
||||
echo "# -" >> $log_file
|
||||
echo "# - Redis Service is already installed." >> $log_file
|
||||
|
||||
info "Redis Service is already installed."
|
||||
|
||||
else
|
||||
echo "# -" >> $log_file
|
||||
echo "# -Redis Service is NOT installed, but also NOT requested for installation!" >> $log_file
|
||||
|
||||
warn "Redis Service is NOT installed, but also NOT requested for installation!"
|
||||
fi
|
||||
else
|
||||
@ -1414,12 +1422,53 @@ echo "# -----" >> $log_file
|
||||
|
||||
if ! $INSTALL_COLABORA_SERVICE ; then
|
||||
if $COLABORA_SERVICE_INSTALLED ; then
|
||||
info "ColaboraOnline Service (loolwsd) is already installed."
|
||||
|
||||
echo "# -" >> $log_file
|
||||
echo "# - ColaboraOnline Service is already installed." >> $log_file
|
||||
|
||||
info "Redis Service is already installed."
|
||||
|
||||
else
|
||||
warn "ColaboraOnline Service is not requested for installation!"
|
||||
|
||||
echo "# -" >> $log_file
|
||||
echo "# -ColaboraOnline Service is NOT installed, but also NOT requested for installation!" >> $log_file
|
||||
|
||||
warn "ColaboraOnline Service is NOT installed, but also NOT requested for installation!"
|
||||
|
||||
fi
|
||||
else
|
||||
|
||||
echononl "Backup configuration directory for loolwsd.."
|
||||
if [[ -d "/etc/loolwsd" ]] ; then
|
||||
|
||||
echo "" >> $log_file
|
||||
echo "# - Backup existing directory '/etc/loolwsd'.." >> $log_file
|
||||
echo "mv \"/etc/loolwsd\" \"/etc/loolwsd.${backup_date}\"" >> $log_file
|
||||
|
||||
mv "/etc/loolwsd" "/etc/loolwsd.${backup_date}" >> $log_file 2>&1
|
||||
if [[ $? -eq 0 ]] ; then
|
||||
echo_ok
|
||||
else
|
||||
echo_failed
|
||||
error "For more informations see log output at '$log_file'."
|
||||
|
||||
echononl "continue anyway [yes/no]: "
|
||||
read OK
|
||||
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
|
||||
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
|
||||
echononl "Wrong entry! - repeat [yes/no]: "
|
||||
read OK
|
||||
done
|
||||
[[ $OK = "yes" ]] || fatal "Interrupted ny user."
|
||||
|
||||
fi
|
||||
|
||||
else
|
||||
echo_skipped
|
||||
fi
|
||||
|
||||
blank_line
|
||||
|
||||
# - Add key for ColaboraOnline Repository
|
||||
# -
|
||||
_failed=false
|
||||
@ -1580,7 +1629,6 @@ EOF
|
||||
echo_skipped
|
||||
fi
|
||||
|
||||
blank_line
|
||||
|
||||
# - Symlimk Snakeoil Cert '/etc/loolwsd/cert.pem' --> '/etc/ssl/certs/ssl-cert-snakeoil.pem'
|
||||
# -
|
||||
@ -1589,7 +1637,9 @@ EOF
|
||||
echo "" >> $log_file
|
||||
echo "# - Symlink '${_symlink_dst}' --> ${_symlink_src}" >> $log_file
|
||||
echo "# -" >> $log_file
|
||||
echo "ln -s \"$_symlink_src\" \"$_symlink_dst\"" >> $log_file
|
||||
echononl "Symlink '${_symlink_dst}' --> ${_symlink_src}"
|
||||
|
||||
ln -s "$_symlink_src" "$_symlink_dst" >> $log_file 2>&1
|
||||
if [ "$?" = 0 ]; then
|
||||
echo_ok
|
||||
@ -1614,7 +1664,9 @@ EOF
|
||||
echo "" >> $log_file
|
||||
echo "# - Symlink '${_symlink_dst}' --> ${_symlink_src}" >> $log_file
|
||||
echo "# -" >> $log_file
|
||||
echo "ln -s \"$_symlink_src\" \"$_symlink_dst\"" >> $log_file
|
||||
echononl "Symlink '${_symlink_dst}' --> ${_symlink_src}"
|
||||
|
||||
ln -s "$_symlink_src" "$_symlink_dst" >> $log_file 2>&1
|
||||
if [ "$?" = 0 ]; then
|
||||
echo_ok
|
||||
@ -1639,7 +1691,9 @@ EOF
|
||||
echo "" >> $log_file
|
||||
echo "# - Symlink '${_symlink_dst}' --> ${_symlink_src}" >> $log_file
|
||||
echo "# -" >> $log_file
|
||||
echo "ln -s \"$_symlink_src\" \"$_symlink_dst\"" >> $log_file
|
||||
echononl "Symlink '${_symlink_dst}' --> ${_symlink_src}"
|
||||
|
||||
ln -s "$_symlink_src" "$_symlink_dst" >> $log_file 2>&1
|
||||
if [ "$?" = 0 ]; then
|
||||
echo_ok
|
||||
@ -1662,13 +1716,14 @@ EOF
|
||||
# - Restart 'loolwsd' service
|
||||
# -
|
||||
echo "" >> $log_file
|
||||
echo "# - Restart 'loolwsd' service" >> $log_file
|
||||
echo "# - Start 'loolwsd' service" >> $log_file
|
||||
echo "# -" >> $log_file
|
||||
echononl "Restart 'loolwsd' service.."
|
||||
echononl "Start 'loolwsd' service.."
|
||||
if $systemd_supported ; then
|
||||
|
||||
echo "systemctl start loolwsd" >> $log_file
|
||||
systemctl restart loolwsd >> $log_file 2>&1
|
||||
sleep 2
|
||||
systemctl start loolwsd >> $log_file 2>&1
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
@ -1740,6 +1795,7 @@ EOF
|
||||
echononl "Backup existing file '${apache_vhost_dir}/${HOSTNAME_CO}.conf.static'" >> $log_file
|
||||
|
||||
echo "mv \"${apache_vhost_dir}/${HOSTNAME_CO}.conf.static\" \"${apache_vhost_dir}/${HOSTNAME_CO}.conf.static.$backup_date\"" >> $log_file
|
||||
|
||||
mv "${apache_vhost_dir}/${HOSTNAME_CO}.conf.static" "${apache_vhost_dir}/${HOSTNAME_CO}.conf.static.$backup_date" >> $log_file 2>&1
|
||||
|
||||
if [ "$?" = 0 ]; then
|
||||
@ -1965,6 +2021,8 @@ EOF
|
||||
|
||||
server_name ${HOSTNAME_CO};
|
||||
|
||||
root /var/www/${HOSTNAME_CO};
|
||||
|
||||
ssl_certificate ${server_cert};
|
||||
ssl_certificate_key ${server_key};
|
||||
|
||||
@ -2038,6 +2096,7 @@ EOF
|
||||
echo "# -" >> $log_file
|
||||
echononl "Symlink '${_symlink_dst}' --> ${_symlink_src}"
|
||||
|
||||
echo "ln -s \"$_symlink_src\" \"$_symlink_dst\"" >> $log_file
|
||||
ln -s "$_symlink_src" "$_symlink_dst" >> $log_file 2>&1
|
||||
if [ "$?" = 0 ]; then
|
||||
echo_ok
|
||||
@ -2056,6 +2115,182 @@ EOF
|
||||
|
||||
fi
|
||||
|
||||
echononl "Backup existing document root directory '/var/www/${HOSTNAME_CO}'.."
|
||||
|
||||
if [[ -d "/var/www/${HOSTNAME_CO}" ]] ; then
|
||||
echo "" >> $log_file
|
||||
echo "# - Backup existing document root directory '/var/www/${HOSTNAME_CO}'" >> $log_file
|
||||
echo "# -" >> $log_file
|
||||
echo "mv \"/var/www/${HOSTNAME_CO}\" \"/var/www/${HOSTNAME_CO}.${backup_date}\"" >> $log_file
|
||||
|
||||
mv "/var/www/${HOSTNAME_CO}" "/var/www/${HOSTNAME_CO}.${backup_date}" >> $log_file 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
echo_failed
|
||||
error "For more informations see log output at '$log_file'."
|
||||
fi
|
||||
else
|
||||
echo_skipped
|
||||
fi
|
||||
|
||||
|
||||
echo "" >> $log_file
|
||||
echo "# - Ceate documentroot directory '/var/www/${HOSTNAME_CO}'." >> $log_file
|
||||
echo "# -" >> $log_file
|
||||
echononl "Ceate documentroot directory '/var/www/${HOSTNAME_CO}'."
|
||||
|
||||
echo "mkdir \"/var/www/${HOSTNAME_CO}\"" >> $log_file
|
||||
mkdir "/var/www/${HOSTNAME_CO}" >> $log_file 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
echo_failed
|
||||
error "For more informations see log output at '$log_file'."
|
||||
fi
|
||||
|
||||
|
||||
echo "" >> $log_file
|
||||
echo "# - Create index file '/var/www/${HOSTNAME_CO}/index.html'" >> $log_file
|
||||
echo "# -" >> $log_file
|
||||
echo "cat <<EOF > /var/www/${HOSTNAME_CO}/index.html
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTTP Error 404 / Http Fehler 404</title>
|
||||
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
|
||||
<style type=\"text/css\">
|
||||
|
||||
body {
|
||||
background: #eee;
|
||||
font: normal normal 16px/140% Arial, Helvetica, Trebuchet MS, Geneva, sans-serif;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
line-height: 100%;
|
||||
}
|
||||
h2 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
line-height: 100%;
|
||||
}
|
||||
|
||||
.Container {
|
||||
background: #fff;
|
||||
width: 825px;
|
||||
}
|
||||
.Content {
|
||||
background: #fff;
|
||||
font-size: 12px;
|
||||
height: 400px;
|
||||
line-height: 16px;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<link rel=\"shortcut icon\" href=\"/favicon.ico\" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class=\"Container\">
|
||||
|
||||
<div class=\"Logo\"></div>
|
||||
|
||||
<div class=\"Content\">
|
||||
|
||||
<h1>HTTP Error 404</h1>
|
||||
<h2>The site you have requestet was not found on this Server</h2>
|
||||
<p>Please check your spelling and try again.</p>
|
||||
<p>Thank You very much!</p>
|
||||
|
||||
<h1>HTTP Fehler 404</h1>
|
||||
<h2>Die von Ihnen aufgerufene Seite gibt es leider nicht - Sorry</h2>
|
||||
<p>Bitte prüfen Sie die Adresse und versuchen es nochmals.</p>
|
||||
<p>Vielen Dank für Ihr Verständnis!</p>
|
||||
|
||||
</div><!-- .Content -->
|
||||
</div><!-- .Container -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOF" >> $log_file
|
||||
|
||||
echononl "Create index file '/var/www/${HOSTNAME_CO}/index.html'"
|
||||
|
||||
cat <<EOF > /var/www/${HOSTNAME_CO}/index.html 2>> $log_file
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTTP Error 404 / Http Fehler 404</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background: #eee;
|
||||
font: normal normal 16px/140% Arial, Helvetica, Trebuchet MS, Geneva, sans-serif;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
line-height: 100%;
|
||||
}
|
||||
h2 {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
line-height: 100%;
|
||||
}
|
||||
|
||||
.Container {
|
||||
background: #fff;
|
||||
width: 825px;
|
||||
}
|
||||
.Content {
|
||||
background: #fff;
|
||||
font-size: 12px;
|
||||
height: 400px;
|
||||
line-height: 16px;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="Container">
|
||||
|
||||
<div class="Logo"></div>
|
||||
|
||||
<div class="Content">
|
||||
|
||||
<h1>HTTP Error 404</h1>
|
||||
<h2>The site you have requestet was not found on this Server</h2>
|
||||
<p>Please check your spelling and try again.</p>
|
||||
<p>Thank You very much!</p>
|
||||
|
||||
<h1>HTTP Fehler 404</h1>
|
||||
<h2>Die von Ihnen aufgerufene Seite gibt es leider nicht - Sorry</h2>
|
||||
<p>Bitte prüfen Sie die Adresse und versuchen es nochmals.</p>
|
||||
<p>Vielen Dank für Ihr Verständnis!</p>
|
||||
|
||||
</div><!-- .Content -->
|
||||
</div><!-- .Container -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
echo_failed
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
error "Cant find nginx's vhost directory!"
|
||||
@ -2076,7 +2311,91 @@ EOF
|
||||
|
||||
fi # if $apache2_installed
|
||||
|
||||
|
||||
echo "" >> $log_file
|
||||
echo "# - Setup script 'check_cert_loolwsd.sh'" >> $log_file
|
||||
echo "# -" >> $log_file
|
||||
echononl "Setup script 'check_cert_loolwsd.sh'"
|
||||
|
||||
_failed=false
|
||||
if [[ -f "/root/bin/nextcloud/conf/check_cert_loolwsd.conf.sample" ]]; then
|
||||
if [[ ! -f "/root/bin/nextcloud/conf/check_cert_loolwsd.conf" ]]; then
|
||||
cp -a "/root/bin/nextcloud/conf/check_cert_loolwsd.conf.sample" \
|
||||
"/root/bin/nextcloud/conf/check_cert_loolwsd.conf"
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
_failed=true
|
||||
fi
|
||||
fi
|
||||
|
||||
cat << EOF >> $log_file
|
||||
perl -i -n -p -e "s/^\\s*HOSTNAME_CO\\s*=.*/HOSTNAME_CO=\"${HOSTNAME_CO}\"" \\
|
||||
/root/bin/nextcloud/conf/check_cert_loolwsd.conf
|
||||
EOF
|
||||
perl -i -n -p -e "s/^\s*HOSTNAME_CO\s*=.*/HOSTNAME_CO="${HOSTNAME_CO}"/" \
|
||||
/root/bin/nextcloud/conf/check_cert_loolwsd.conf >> "$log_file" 2>&1
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
if $_failed ; then
|
||||
echo_failed
|
||||
error "Failed to setup script 'check_cert_loolwsd.sh'."
|
||||
else
|
||||
echo_ok
|
||||
|
||||
echononl "Initial run of script 'check_cert_loolwsd.sh'.."
|
||||
if [[ -x "/root/bin/nextcloud/check_cert_loolwsd.sh" ]]; then
|
||||
/root/bin/nextcloud/check_cert_loolwsd.sh
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_ok
|
||||
else
|
||||
echo_failed
|
||||
fi
|
||||
else
|
||||
echo_skipped
|
||||
warn "Cannot find script '/root/bin/nextcloud/check_cert_loolwsd.sh'"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo_skipped
|
||||
warn "Cannot find sample configuration file '/root/bin/nextcloud/conf/check_cert_loolwsd.conf.sample'"
|
||||
|
||||
echo "# -" >> $log_file
|
||||
echo "# - Cannot find sample configuration file '/root/bin/nextcloud/conf/check_cert_loolwsd.conf.sample'" >> $log_file
|
||||
echo "# - Skip configuration of script '/root/bin/nextcloud/check_cert_loolwsd.sh'" >> $log_file
|
||||
echo "# -" >> $log_file
|
||||
fi
|
||||
|
||||
echononl "Create cronjob for checcking/renewing lollwsd certs.."
|
||||
if [[ -x "/root/bin/nextcloud/check_cert_loolwsd.sh" ]] ; then
|
||||
_crontab_tmp_file=/tmp/crontab_root.$$
|
||||
crontab -l > $_crontab_tmp_file 2> /dev/null
|
||||
|
||||
if ! grep -q -E "/root/bin/nextcloud/check_cert_loolwsd.sh" $_crontab_tmp_file 2> /dev/null ; then
|
||||
echo "" >> $_crontab_tmp_file
|
||||
echo "# - Check if certificates for loolwsd service are up to date" >> $_crontab_tmp_file
|
||||
echo "# -" >> $_crontab_tmp_file
|
||||
echo "17 05 * * * /root/bin/nextcloud/check_cert_loolwsd.sh" >> $_crontab_tmp_file
|
||||
crontab $_crontab_tmp_file
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo_done
|
||||
else
|
||||
echo_failed
|
||||
error "Creating cronjob for checcking/renewing lollwsd certs failed!"
|
||||
fi
|
||||
else
|
||||
echo_skipped
|
||||
fi
|
||||
else
|
||||
echo_skipped
|
||||
warn "Script '/root/bin/nextcloud/check_cert_loolwsd.sh' not found'."
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
clean_up 0
|
||||
|
||||
|
||||
# -----
|
||||
|
Loading…
Reference in New Issue
Block a user