Skip to content

Commit

Permalink
Added some code
Browse files Browse the repository at this point in the history
After #40 I've polished the script a bit and added some code, view the # out commented lines for info.
  • Loading branch information
Ezra authored Jan 3, 2017
1 parent 57d71e1 commit e57c08f
Showing 1 changed file with 72 additions and 18 deletions.
90 changes: 72 additions & 18 deletions static/collabora.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
#!/bin/bash
DOMAIN=$(whiptail --title "Techandme.se Collabora" --inputbox "Nextcloud url, make sure it looks like this: cloud\.yourdomain\.com" 10 60 cloud\.yourdomain\.com 3>&1 1>&2 2>&3)
CLEANDOMAIN=$(whiptail --title "Techandme.se Collabora" --inputbox "Nextcloud url, now make sure it look normal" 10 60 cloud.yourdomain.com 3>&1 1>&2 2>&3)
EDITORDOMAIN=$(whiptail --title "Techandme.se Collabora" --inputbox "Collabora subdomain eg: office.yourdomain.com" 10 60 3>&1 1>&2 2>&3)
HTTPS_EXIST="/etc/apache2/sites-available/$EXISTINGDOMAIN.conf"
# Collabora auto installer

## Variable's
# Docker URL
DOMAIN=$(whiptail --title "Techandme.se Collabora" --inputbox "Nextcloud url, make sure it looks like this: cloud\\.yourdomain\\.com" "$WT_HEIGHT" "$WT_WIDTH" cloud\\.yourdomain\\.com 3>&1 1>&2 2>&3)
# Letsencrypt domains (we need to find a solution to add this Letsencrypt request to the main request for the NC domain)
CLEANDOMAIN=$(whiptail --title "Techandme.se Collabora" --inputbox "Nextcloud url, now make sure it look normal" "$WT_HEIGHT" "$WT_WIDTH" cloud.yourdomain.com 3>&1 1>&2 2>&3)
EDITORDOMAIN=$(whiptail --title "Techandme.se Collabora" --inputbox "Collabora subdomain eg: office.yourdomain.com" "$WT_HEIGHT" "$WT_WIDTH" 3>&1 1>&2 2>&3)
# Vhosts
HTTPS_EXIST="/etc/apache2/sites-available/$CLEANDOMAIN.conf"
HTTPS_CONF="/etc/apache2/sites-available/$EDITORDOMAIN.conf"
# Letsencrypt
LETSENCRYPTPATH=/etc/letsencrypt
CERTFILES=$LETSENCRYPTPATH/live
# WANIP
WANIP4=$(dig +short myip.opendns.com @resolver1.opendns.com)
# Misc
SCRIPTS=/var/scripts

# Message
whiptail --msgbox "Please before you start make sure port 443 is directly forwarded to this machine or open!" 20 60 2
# Whiptail auto size
calc_wt_size() {
WT_HEIGHT=17
WT_WIDTH=$(tput cols)

if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then
WT_WIDTH=80
fi
if [ "$WT_WIDTH" -gt 178 ]; then
WT_WIDTH=120
fi
WT_MENU_HEIGHT=$((WT_HEIGHT-7))
}

# Notification
whiptail --msgbox "Please before you start make sure port 443 is directly forwarded to this machine or open!" "$WT_HEIGHT" "$WT_WIDTH"

# Check if 443 is open using nmap, if not notify the user
if [ $(dpkg-query -W -f='${Status}' nmap 2>/dev/null | grep -c "ok installed") -eq 1 ]; then
echo "network-manager-openvpn is already installed..."
clear
else
apt install nmap -y
fi

if [ $(nmap -sS -p 443 "$WANIP4" | grep -c "open") -eq 1 ]; then
echo "Port is open"
apt remove --purge nmap -y
else
whiptail --msgbox "Port 443 is not open..." "$WT_HEIGHT" "$WT_WIDTH"
apt remove --purge nmap -y
exit
fi

# Update & upgrade
apt update
Expand All @@ -29,7 +70,6 @@ else
apt install git -y
fi


# Install Collabora docker
docker pull collabora/code
docker run -t -d -p 127.0.0.1:9980:9980 -e "domain=$DOMAIN" --restart always --cap-add MKNOD collabora/code
Expand Down Expand Up @@ -57,7 +97,6 @@ a2enmod proxy_http
a2enmod ssl

# Create Vhost for Collabora online in Apache2

if [ -f "$HTTPS_CONF" ];
then
echo "Virtual Host exists"
Expand All @@ -70,9 +109,9 @@ else
# SSL configuration, you may want to take the easy route instead and use Lets Encrypt!
SSLEngine on
SSLCertificateChainFile $CERTFILES/$DOMAIN/chain.pem
SSLCertificateFile $CERTFILES/$DOMAIN/cert.pem
SSLCertificateKeyFile $CERTFILES/$DOMAIN/privkey.pem
SSLCertificateChainFile $CERTFILES/$CLEANDOMAIN/chain.pem
SSLCertificateFile $CERTFILES/$CLEANDOMAIN/cert.pem
SSLCertificateKeyFile $CERTFILES/$CLEANDOMAIN/privkey.pem
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS
SSLHonorCipherOrder on
Expand Down Expand Up @@ -122,11 +161,26 @@ fi
fi

# Let's Encrypt
echo
echo "You now need to create a SSL certificate for the subdomain that will host Collabora..."
echo
sleep 10
wget https://raw.githubusercontent.com/nextcloud/vm/master/lets-encrypt/activate-ssl.sh -P $SCRIPTS
bash $SCRIPTS/activate-ssl.sh
rm $SCRIPTS/activate-ssl.sh

# Stop Apache to aviod port conflicts
a2dissite 000-default.conf
sudo service apache2 stop

############################### Still need to rewrite test-new-config.sh for collabora domain and add more tries for letsencrypt
# Generate certs
cd /etc
git clone https://github.com/certbot/certbot.git
cd /etc/certbot
./letsencrypt-auto certonly --agree-tos --standalone -d $CLEANDOMAIN
# Check if $certfiles exists
if [ -d "$HTTPS_CONF" ]
then
echo -e "\e[96m"
echo -e "Certs are generated!"
else
echo -e "\e[96m"
echo -e "It seems like no certs were generated, please upload your logs to https://github.com/nextcloud/vm"
echo -e "\e[32m"
read -p "Press any key to continue... " -n1 -s
echo -e "\e[0m"
fi

0 comments on commit e57c08f

Please sign in to comment.