# Install using: sudo su -c "bash <(wget -qO- /url/to/install-apache.sh)" # Make sure script is ran as root if [[ $EUID -ne 0 ]]; then exec sudo /bin/bash "$0" "$@" fi REALUSER=$(logname) mkdir /home/$REALUSER/www 2>>install.log & apt update -qq 2>>install.log apt install apache2 -y 2>>install.log read -p "Would you like to install Samba? (Y/n)" -n 1 -r echo if [[ ! $REPLY =~ ^[Nn]$ ]] then echo Installing Samba... apt install samba -y 2>>install.log && # Setting up Samba shares if ! grep -q "/home/$REALUSER/www" "/etc/samba/smb.conf"; then cat <> "/etc/samba/smb.conf" [$REALUSER-www] comment = Samba File Server Share path = /home/$REALUSER/www browsable = yes guest ok = yes read only = no create mask = 777 force create mode = 777 directory mask = 777 force directory mode = 777 oplocks = yes [/$REALUSER-www] EOT fi if ! grep -q "/var/www" "/etc/samba/smb.conf"; then cat <> "/etc/samba/smb.conf" [www] comment = Samba File Server Share path = /var/www browsable = yes guest ok = yes read only = no create mask = 777 force create mode = 777 directory mask = 777 force directory mode = 777 valid users = $REALUSER, root force user = root force group = root writeable = yes admin users = root oplocks = yes [/www] EOT fi if ! grep -q "/etc/apache2" "/etc/samba/smb.conf"; then cat <> "/etc/samba/smb.conf" [apache2] comment = Samba File Server Share path = /etc/apache2 browsable = yes guest ok = yes read only = no create mask = 777 force create mode = 777 directory mask = 777 force directory mode = 777 valid users = $REALUSER, root force user = root force group = root writeable = yes admin users = root oplocks = yes [/apache2] EOT fi sed -i -e 's/obey pam restrictions = yes/obey pam restrictions = no/g' /etc/samba/smb.conf # https://www.oreilly.com/openbook/samba/book/ch05_05.html # https://unix.stackexchange.com/questions/425934/windows-clients-will-not-refresh-linux-samba-file-locally-if-reading-file-at-int # Add kernel oplocks = yes under [global] sed -i '/kernel oplocks/d' /etc/samba/smb.conf sed -i '/\[global\]/a kernel oplocks = yes' /etc/samba/smb.conf service smbd restart 2>>install.log && ufw allow samba 2>>install.log if ! pdbedit "$REALUSER" &>/dev/null; then sudo smbpasswd -a $REALUSER 2>>install.log fi fi read -p "Would you like to install uCMS site? (Y/n)" -n 1 -r echo if [[ ! $REPLY =~ ^[Nn]$ ]] then mkdir -p /var/www/cms/www 2>>install.log && mkdir -p /var/www/cms/log 2>>install.log && if [ ! -f "/etc/apache2/sites-enabled/cms.conf" ]; then cat < "/etc/apache2/sites-enabled/cms.conf" # Listen 8090 ServerAdmin webmaster@localhost DocumentRoot /var/www/cms/www ErrorLog /var/www/cms/log/error.log CustomLog /var/www/cms/log/access.log combined Options Indexes FollowSymLinks MultiViews DirectoryIndex index.html index.pl AllowOverride All Require all granted AddHandler cgi-script .pl Options +ExecCGI EOT fi fi chmod -R uga+rwx /home/$REALUSER/www/ 2>>install.log && chmod -R uga+rwx /var/www/ 2>>install.log && # chmod -R 775 /var/www/ # chown -R $REALUSER:$REALUSER /var/www/ # chown -R $REALUSER:$REALUSER /etc/apache2/ service apache2 restart 2>>install.log # Install the Microsoft ODBC driver for SQL Server (Linux) # https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15 if ! [[ "18.04 20.04 22.04" == *"$(lsb_release -rs)"* ]]; then echo "Ubuntu $(lsb_release -rs) is not currently supported."; else curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list apt update -qq ACCEPT_EULA=Y apt install -y msodbcsql18 # Optional: for bcp and sqlcmd uncomment the following lines. # ACCEPT_EULA=Y apt install -y mssql-tools18 # echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc # source ~/.bashrc # Optional: for unixODBC development headers uncomment the following lines. # apt install -y unixodbc-dev fi apt install libcgi-session-perl -y 2>>install.log && apt install libapache2-mod-perl2 -y 2>>install.log && apt install libarchive-zip-perl -y 2>>install.log && apt install libdbi-perl -y 2>>install.log && apt install libdbd-odbc-perl -y 2>>install.log && apt install libdbd-sqlite2-perl -y 2>>install.log && apt install libdbd-sqlite3-perl -y 2>>install.log && apt install libdbd-mysql-perl -y 2>>install.log && apt install libio-string-perl -y 2>>install.log && apt install libjson-perl -y 2>>install.log && apt install libmime-lite-perl -y 2>>install.log && apt install libexcel-writer-xlsx-perl -y 2>>install.log && apt install libgd-perl -y 2>>install.log && apt install perlmagick -y 2>>install.log && apt install librest-client-perl -y 2>>install.log && apt install libxml-simple-perl -y 2>>install.log && apt install libspreadsheet-xlsx-perl -y 2>>install.log && a2enmod rewrite 2>>install.log && a2enmod headers 2>>install.log && a2enmod expires 2>>install.log && a2enmod cgi.load 2>>install.log && a2enmod ssl 2>>install.log && a2enmod proxy 2>>install.log && a2enmod proxy_http 2>>install.log && systemctl restart apache2 2>>install.log && logrotate --version 2>&1 || ( echo "Installing Logrotate..." apt install logrotate -y 2>>install.log && logrotate --version ) if ! grep -q "/var/www/\*/logs/\*\.log" "/etc/logrotate.d/apache2"; then echo "Adding logrotate config" cat <> "/etc/logrotate.d/apache2" /var/www/*/logs/*.log { su root root maxsize 50M daily missingok rotate 7 compress delaycompress notifempty create 640 root adm sharedscripts postrotate if invoke-rc.d apache2 status > /dev/null 2>&1; then invoke-rc.d apache2 reload > /dev/null 2>&1; fi; endscript prerotate if [ -d /etc/logrotate.d/httpd-prerotate ]; then run-parts /etc/logrotate.d/httpd-prerotate; fi; endscript } EOT fi echo 'Installation complete'