Make Samba and CMS optional in BashScripts/install-apache.sh
This commit is contained in:
parent
2cf9a8aba4
commit
50584cbf1b
@ -7,15 +7,18 @@ fi
|
|||||||
REALUSER=$(logname)
|
REALUSER=$(logname)
|
||||||
mkdir /home/$REALUSER/www 2>>install.log &
|
mkdir /home/$REALUSER/www 2>>install.log &
|
||||||
|
|
||||||
#apt install docker.io
|
|
||||||
|
|
||||||
apt update -qq 2>>install.log
|
apt update -qq 2>>install.log
|
||||||
apt install apache2 -y 2>>install.log &&
|
apt install apache2 -y 2>>install.log
|
||||||
apt install samba -y 2>>install.log &&
|
|
||||||
|
|
||||||
# Setting up Samba shares
|
read -p "Would you like to install Samba? (Y/n)" -n 1 -r
|
||||||
if ! grep -q "/home/$REALUSER/www" "/etc/samba/smb.conf"; then
|
echo
|
||||||
cat <<EOT >> "/etc/samba/smb.conf"
|
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 <<EOT >> "/etc/samba/smb.conf"
|
||||||
[$REALUSER-www]
|
[$REALUSER-www]
|
||||||
comment = Samba File Server Share
|
comment = Samba File Server Share
|
||||||
path = /home/$REALUSER/www
|
path = /home/$REALUSER/www
|
||||||
@ -28,9 +31,9 @@ if ! grep -q "/home/$REALUSER/www" "/etc/samba/smb.conf"; then
|
|||||||
force directory mode = 777
|
force directory mode = 777
|
||||||
[/$REALUSER-www]
|
[/$REALUSER-www]
|
||||||
EOT
|
EOT
|
||||||
fi
|
fi
|
||||||
if ! grep -q "/var/www" "/etc/samba/smb.conf"; then
|
if ! grep -q "/var/www" "/etc/samba/smb.conf"; then
|
||||||
cat <<EOT >> "/etc/samba/smb.conf"
|
cat <<EOT >> "/etc/samba/smb.conf"
|
||||||
[www]
|
[www]
|
||||||
comment = Samba File Server Share
|
comment = Samba File Server Share
|
||||||
path = /var/www
|
path = /var/www
|
||||||
@ -48,9 +51,9 @@ if ! grep -q "/var/www" "/etc/samba/smb.conf"; then
|
|||||||
admin users = root
|
admin users = root
|
||||||
[/www]
|
[/www]
|
||||||
EOT
|
EOT
|
||||||
fi
|
fi
|
||||||
if ! grep -q "/etc/apache2" "/etc/samba/smb.conf"; then
|
if ! grep -q "/etc/apache2" "/etc/samba/smb.conf"; then
|
||||||
cat <<EOT >> "/etc/samba/smb.conf"
|
cat <<EOT >> "/etc/samba/smb.conf"
|
||||||
[apache2]
|
[apache2]
|
||||||
comment = Samba File Server Share
|
comment = Samba File Server Share
|
||||||
path = /etc/apache2
|
path = /etc/apache2
|
||||||
@ -68,17 +71,46 @@ if ! grep -q "/etc/apache2" "/etc/samba/smb.conf"; then
|
|||||||
admin users = root
|
admin users = root
|
||||||
[/apache2]
|
[/apache2]
|
||||||
EOT
|
EOT
|
||||||
fi
|
fi
|
||||||
sed -i -e 's/obey pam restrictions = yes/obey pam restrictions = no/g' /etc/samba/smb.conf
|
sed -i -e 's/obey pam restrictions = yes/obey pam restrictions = no/g' /etc/samba/smb.conf
|
||||||
service smbd restart 2>>install.log &&
|
service smbd restart 2>>install.log &&
|
||||||
ufw allow samba 2>>install.log
|
ufw allow samba 2>>install.log
|
||||||
|
|
||||||
if ! pdbedit "$REALUSER" &>/dev/null; then
|
if ! pdbedit "$REALUSER" &>/dev/null; then
|
||||||
sudo smbpasswd -a $REALUSER 2>>install.log
|
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 <<EOT > "/etc/apache2/sites-enabled/cms.conf"
|
||||||
|
# Listen 8090
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin webmaster@localhost
|
||||||
|
DocumentRoot /var/www/cms/www
|
||||||
|
ErrorLog /var/www/cms/log/error.log
|
||||||
|
CustomLog /var/www/cms/log/access.log combined
|
||||||
|
|
||||||
|
<Directory /var/www/cms/www>
|
||||||
|
Options Indexes FollowSymLinks MultiViews
|
||||||
|
DirectoryIndex index.html index.pl
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
<Files ~ "\.(pl|cgi)$">
|
||||||
|
AddHandler cgi-script .pl
|
||||||
|
Options +ExecCGI
|
||||||
|
</Files>
|
||||||
|
</VirtualHost>
|
||||||
|
EOT
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p /var/www/cms/www 2>>install.log &&
|
|
||||||
mkdir -p /var/www/cms/log 2>>install.log &&
|
|
||||||
chmod -R uga+rwx /home/$REALUSER/www/ 2>>install.log &&
|
chmod -R uga+rwx /home/$REALUSER/www/ 2>>install.log &&
|
||||||
chmod -R uga+rwx /var/www/ 2>>install.log &&
|
chmod -R uga+rwx /var/www/ 2>>install.log &&
|
||||||
# chmod -R 775 /var/www/
|
# chmod -R 775 /var/www/
|
||||||
@ -131,30 +163,6 @@ a2enmod ssl 2>>install.log &&
|
|||||||
a2enmod proxy 2>>install.log &&
|
a2enmod proxy 2>>install.log &&
|
||||||
a2enmod proxy_http 2>>install.log &&
|
a2enmod proxy_http 2>>install.log &&
|
||||||
|
|
||||||
|
|
||||||
if [ ! -f "/etc/apache2/sites-enabled/cms.conf" ]; then
|
|
||||||
cat <<EOT > "/etc/apache2/sites-enabled/cms.conf"
|
|
||||||
# Listen 8090
|
|
||||||
<VirtualHost *:80>
|
|
||||||
ServerAdmin webmaster@localhost
|
|
||||||
DocumentRoot /var/www/cms/www
|
|
||||||
ErrorLog /var/www/cms/log/error.log
|
|
||||||
CustomLog /var/www/cms/log/access.log combined
|
|
||||||
|
|
||||||
<Directory /var/www/cms/www>
|
|
||||||
Options Indexes FollowSymLinks MultiViews
|
|
||||||
DirectoryIndex index.html index.pl
|
|
||||||
AllowOverride All
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
<Files ~ "\.(pl|cgi)$">
|
|
||||||
AddHandler cgi-script .pl
|
|
||||||
Options +ExecCGI
|
|
||||||
</Files>
|
|
||||||
</VirtualHost>
|
|
||||||
EOT
|
|
||||||
fi
|
|
||||||
|
|
||||||
systemctl restart apache2 2>>install.log &&
|
systemctl restart apache2 2>>install.log &&
|
||||||
|
|
||||||
echo 'Installation complete'
|
echo 'Installation complete'
|
Loading…
x
Reference in New Issue
Block a user