Skip to content

Instantly share code, notes, and snippets.

@brahianpdev
Forked from roxsross/deploy_web.sh
Created September 13, 2022 18:23
Show Gist options
  • Save brahianpdev/f970ea7098a54c5301826fb00992a20d to your computer and use it in GitHub Desktop.
Save brahianpdev/f970ea7098a54c5301826fb00992a20d to your computer and use it in GitHub Desktop.
deploy_web
#!/bin/bash
#variables
DISTRO=$(lsb_release -ds)
USERID=$(id -u)
DOMAIN="web.192.168.56.108.nip.io"
WEB="pages"
#Check user
if [ $USERID -ne 0 ]; then
echo "El usuario debe ser ROOT "
exit 1
fi
web () {
echo -e "\e[32;1;3mDespliegue WEB\e[m"
wget -q --show-progress https://github.com/roxsross/educacionIT/raw/master/pages.tar.gz
cp pages.tar.gz /var/www/html
rm -rf pages.tar.gz
cd /var/www/html
tar -xzf pages.tar.gz
rm -rf pages.tar.gz
chown -R $USER:$USER $WEB
chmod -R 755 $WEB
echo "Finish"
echo "Web Enable $DOMAIN"
}
#configuracion de virtual host apache
host () {
echo -e "\e[32;1;3mVirtual Host Apache\e[m"
mkdir -p /var/www/html/${WEB}
touch /etc/apache2/sites-available/${WEB}.conf
cat > /etc/apache2/sites-available/${WEB}.conf <<EOF
<VirtualHost *:80>
ServerAdmin webmaster@educacionit.com
ServerName ${DOMAIN}
DocumentRoot /var/www/html/${WEB}
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/${WEB}/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EOF
a2ensite ${WEB}.conf
a2dissite 000-default.conf
apache2ctl configtest
systemctl restart apache2
}
if [ -f /etc/lsb-release ]; then
echo -e "\e[32;1;3mUbuntu Detectado......\e[m"
host
web
fi
#!/bin/bash
#variables
DISTRO=$(lsb_release -ds)
USERID=$(id -u)
#Check user
if [ $USERID -ne 0 ]; then
echo "El usuario debe ser ROOT "
exit 1
fi
apache () {
echo -e "\e[32;1;3mupdate System\e[m"
apt-get update
apt-get update
echo "Fix Apache"
apt-get -y purge apache2
echo "install apache"
apt install -y apache2
cd /var/www/html
echo "<h1>Apache Running</h1>" > index.html
}
service () {
echo "Restarting Apache"
systemctl restart apache2
}
if [ -f /etc/lsb-release ]; then
echo "Ubuntu Detectado......"
apache
service
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment