OpenColleague_v1

by dkirkpatrick1z
13 deployments · 1 still active · last rev. 3 months ago

-> Description - About OpenColleague:
OpenColleague supports the philosophy of Self Management by providing powerful web-based tools that
together promote transparency, accountability, and clarity in workplaces embracing the principles of
Self Management.

-> About OpenColleague :
This web-based software is powered by a PHP MVC framework, a mySQL database, an Apache2 webserver,
and other open-source software including Ubuntu Linux. The software can be installed on any webserver
that has the following system requirements:

-> Minimum Recommended System Resources
- Root Access to Linux Webserver with ~5-10GB available webserver storage space and Internet Access
- PHP (v5.6)
- MySQL (v. 4.x and above)
- Apache2 WebServer
- Ability to configure apache2 mod_rewrite
- php5.6 PEAR, GD Library, php5.6-mysql

-> Recommendations:
It is highly recommended to install OpenColleague on its own Linux webserver to prevent potential
conflicts with other tools/software and to maximize performance.

While there are several hosting companies that allow the developer to select their preferred
Linux Operating System and subsequently control all aspects of the webserver, Linode.com is
highly recommended as a web host, with their “Linode 2GB” hosting package appropriate for
most standard OpenColleague software installations (https://www.linode.com/pricing)

In order to automate the installation of version 1.0 of OpenColleague, this Linode.com
“StackScript” (similar to a Shell Script) has been created to facilitate the entire process of
installing & configuring an OpenColleague installation on a new Linode.com webserver (See
Installation Option 1: Linode StackScripts below). If you prefer to run a Shell Script with
another web hosting provider other than Linode.com, please contact
vincent.t.metzger@gmail.com to request this resource.

Installation files and accompanying instructions exist for setting up a webserver
running OpenColleague.com using http (through port 80) and https (utilizing port 443). SSL
Encryption instructions are included for the CA-Certificate provider SSLMate.com.

Compatible with: Ubuntu 16.04 LTS
						#!/bin/bash
#######################################################################################################################################
#  6/22/2017 - OpenColleague Version1.0
#
#  .oooooo.                                      .oooooo.             oooo  oooo
# d8P'  `Y8b                                    d8P'  `Y8b            `888  `888
#888      888 oo.ooooo.   .ooooo.  ooo. .oo.   888           .ooooo.   888   888   .ooooo.   .oooo.    .oooooooo oooo  oooo   .ooooo.
#888      888  888' `88b d88' `88b `888P^Y88b  888          d88' `88b  888   888  d88' `88b `P  )88b  888' `88b  `888  `888  d88' `88b
#888      888  888   888 888ooo888  888   888  888          888   888  888   888  888ooo888  .oP^888  888   888   888   888  888ooo888
#`88b    d88'  888   888 888    .o  888   888  `88b    ooo  888   888  888   888  888    .o d8(  888  `88bod8P'   888   888  888    .o
# `Y8bood8P'   888bod8P' `Y8bod8P' o888o o888o  `Y8bood8P'  `Y8bod8P' o888o o888o `Y8bod8P' `Y888^^8o `8oooooo.   `V88V^V8P' `Y8bod8P'
#              888                                                                                    d^     YD
#             o888o                                                                                   ^Y88888P'
#
#
# >> Install OpenColleague Version 1.0 <<
#
# -> Description - About OpenColleague:
#       OpenColleague supports the philosophy of Self Management by providing powerful web-based tools that
#       together promote transparency, accountability, and clarity in workplaces embracing the principles of
#       Self Management.
#
# -> About OpenColleague :
#       This web-based software is powered by a PHP MVC framework, a mySQL database, an Apache2 webserver,
#       and other open-source software including Ubuntu Linux.  The software can be installed on any webserver
#       that has the following system requirements:
#
# -> Minimum Recommended System Resources
#       - Root Access to Linux Webserver with ~5-10GB available webserver storage space and Internet Access
#       - PHP (v5.6)
#       - MySQL (v. 4.x and above)
#       - Apache2 WebServer
#       - Ability to configure apache2 mod_rewrite
#       - php5.6 PEAR, GD Library, php5.6-mysql
#
# -> Recommendations:
#       It is highly recommended to install OpenColleague on its own Linux webserver to prevent potential
#       conflicts with other tools/software and to maximize performance.
#
#       While there are several hosting companies that allow the developer to select their preferred
#       Linux Operating System and subsequently control all aspects of the webserver, Linode.com is
#       highly recommended as a web host, with their Linode 2GB hosting package appropriate for
#       most standard OpenColleague software installations (https://www.linode.com/pricing)
#
#       In order to automate the installation of version 1.0 of OpenColleague, this Linode.com
#       StackScript (similar to a Shell Script) has been created to facilitate the entire process of
#       installing & configuring an OpenColleague installation on a new Linode.com webserver (See
#       Installation Option 1: Linode StackScripts below).  If you prefer to run a Shell Script with
#       another web hosting provider other than Linode.com, please contact
#       vincent.t.metzger@gmail.com to request this resource.
#
#       Installation files and accompanying instructions exist for setting up a webserver
#       running OpenColleague.com using http (through port 80) and https (utilizing port 443). SSL
#       Encryption instructions are included for the CA-Certificate provider SSLMate.com.
#
#
####################################################################################################################################

#<UDF name="oc_license_key" label="Your OpenColleague License Key (Provided)" example="OCV1-XXXX" />

#<UDF name="fileserver_user" Label="SFTP/SSH Username Provided (to Download Installation Files)" />
#<UDF name="fileserver_password" Label="SFTP/SSH Password Provided" />

#<UDF name="var_http_or_https" Label="Pick one of" oneOf="http,https" example="Select https if you are configuring SSL" />

#<UDF name="var_fqdn_or_ip" Label="Pick one of" oneOf="Registered domain name,No domain name - use IP" example="Do you have a registered domain name?" />
#<UDF name="website" Label="Fully Qualified Domain Name (FQDN)" default="" example="example.com" />
#<UDF name="hostname" Label="Hostname" example="example" />

#<UDF name="your_admin_email_address" Label="Your Email Address" example="you@yourdomain.com" />
#<UDF name="your_oc_password" Label="Your OpenColleague Password" example="password1234" />


#load external StackScript (composed by Linode.com Staff, contains basic functions)
source <ssinclude StackScriptID="1">

DB_NAME = "oc_database_v1"
SSUSER = "oc_sudo_user"
IPADDR=$(/sbin/ifconfig eth0 | awk '/inet / { print $2 }' | sed 's/addr://')


# add sudo user
adduser $SSUSER --disabled-password --gecos "" && \
echo "$SSUSER:$YOUR_OC_PASSWORD" | chpasswd
adduser $SSUSER sudo

# This section sets the hostname.
echo $HOSTNAME > /etc/hostname
hostname -F /etc/hostname


# updates
apt-get -o Acquire::ForceIPv4=true update -y
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold"  install grub-pc
apt-get -o Acquire::ForceIPv4=true update -y


#SET HOSTNAME   
hostnamectl set-hostname $HOSTNAME
echo "127.0.0.1   $HOSTNAME" >> /etc/hosts
# This section sets the Fully Qualified Domain Name (FQDN) in the hosts file.
echo $IPADDR $FQDN $HOSTNAME >> /etc/hosts


#INSTALL APACHE
apt-get install apache2 -y


# edit apache config
sed -ie "s/KeepAlive Off/KeepAlive On/g" /etc/apache2/apache2.conf


#Create a copy of the default Apache configuration file for your site:
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/$WEBSITE.conf


# configuration of vhost file
cat <<END >/etc/apache2/sites-available/$WEBSITE.conf
<Directory /var/www/html/$WEBSITE/public_html>
    Require all granted
</Directory>
<VirtualHost *:80>
        ServerName $WEBSITE
        ServerAlias www.$WEBSITE
        ServerAdmin $YOUR_ADMIN_EMAIL_ADDRESS
        DocumentRoot /var/www/html/$WEBSITE/public_html

        ErrorLog /var/www/html/$WEBSITE/logs/error.log
        CustomLog /var/www/html/$WEBSITE/logs/access.log combined

</VirtualHost>
END


mkdir -p /var/www/html/$WEBSITE/{public_html,logs}

cd /var/www/html/$WEBSITE/public_html/

echo "<h1>Stackscript: Ubuntu 16.04 LAMP successfully installed :D<h1/></html>" > index.html

cd


rm /var/www/html/index.html


#Link your virtual host file from the sites-available directory to the sites-enabled directory:
sudo a2ensite $WEBSITE.conf


#Disable the default virtual host to minimize security risks:
a2dissite 000-default.conf


# restart apache
systemctl reload apache2
systemctl restart apache2


# Install MySQL Server in a Non-Interactive mode. Default root password will be "root"
echo "mysql-server mysql-server/root_password password $YOUR_OC_PASSWORD" | sudo debconf-set-selections
echo "mysql-server mysql-server/root_password_again password $YOUR_OC_PASSWORD" | sudo debconf-set-selections
apt-get -y install mysql-server

mysql -uroot -p$YOUR_OC_PASSWORD -e "create database $DB_NAME"

service mysql restart
 
#installing php

sudo apt-get install software-properties-common python-software-properties -y --force-yes
printf '/n'
echo '/n'
sudo add-apt-repository ppa:ondrej/php -y 
printf '/n'
echo '/n'
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install php5.6 php-pear php5.6-mysql libapache2-mod-php5.6 php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-xml php5.6-xmlrpc
printf '/n'
echo '/n'

sudo apt-get update
sudo apt-get -y upgrade

sudo a2dismod php7.1
sudo a2enmod php5.6

# get sendmail for sending mail
sudo apt-get -y install sendmail
sudo apt-get -y install mailutils

# making directory for php? giving apache permissions to that log? restarting php
mkdir /var/log/php
chown www-data /var/log/php
systemctl restart apache2

#setup SCP/SSH/SFTP from this machine to opencolleague.com
sudo apt-get -y install sshpass
ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -P ""
sshpass -p$FILESERVER_PASSWORD ssh-copy-id -i ~/.ssh/id_rsa.pub $FILESERVER_USER@opencolleague.com

#cat ~/.ssh/id_rsa.pub | ssh $FILESERVER_USER@opencolleague.com "mkdir -p /home/$FILESERVER_USER/.ssh ; cat >> /home/$FILESERVER_USER/.ssh/authorized_keys"
#scp -rp $FILESERVER_USER@opencolleague.com:/home/opencolleague/OpenColleague_InstallationFiles/Linux-standard/https_ssl-version-1_0/installation_files /var/www/html/
#scp -rp $FILESERVER_USER@opencolleague.com:/var/www/html/henrysend.opencolleague.com/public_html /var/www/html/



#copy over the files
scp -rp $FILESERVER_USER@opencolleague.com:/var/www/html/henrysend.opencolleague.com/public_html /var/www/html/$WEBSITE

sudo chown -R www-data /var/www/html/$WEBSITE/public_html
sudo chown -R www-data /var/www/html/$WEBSITE/public_html/app/webroot/tmp
sudo chown -R www-data /var/www/html/$WEBSITE/public_html/app/webroot/uploads

sudo chmod -R 755 /var/www/html/$WEBSITE/public_html/app/webroot/tmp
sudo chmod -R 755 /var/www/html/$WEBSITE/public_html/app/webroot/uploads

cd /var/www/html/$WEBSITE/public_html
find ./ -type f -exec sed -i -e 's/henrysend.opencolleague.com/$IPADDRESS/g' {} \;

echo "Yes it worked, w00t"