Browse Source

improve 2222.sh

master
VirtuBox 1 year ago
parent
commit
c3dc66676b
2 changed files with 57 additions and 45 deletions
  1. +3
    -2
      backup/mysqldump/mysqldump.sh
  2. +54
    -43
      easyengine/secure-22222/22222.sh

+ 3
- 2
backup/mysqldump/mysqldump.sh View File

@@ -1,5 +1,4 @@
#!/bin/bash

# -------------------------------------------------------------------------
# Modified First By: Mitesh Shah
# Then Modified By : VirtuBox
@@ -39,7 +38,7 @@ DAYSOLD=3
ALLDB=0
SINGLE_DB=1

### Add help menu
_help() {
echo "Backup MySQL databases using mysqldump"
echo "Usage: ./mysqldump.sh [mode][options] ..."
@@ -60,6 +59,8 @@ _help() {
### ----[ No Editing below ]------###
#####################################

# script arguments parsing

while [[ $# -gt 0 ]]; do
arg="$1"
case $arg in


+ 54
- 43
easyengine/secure-22222/22222.sh View File

@@ -1,50 +1,61 @@
#!/bin/bash



ee-acme-22222() {

MY_HOSTNAME=$(hostname -f)
MY_IP=$(curl -s v4.vtbox.net)
MY_HOSTNAME_IP=$(dig +short @8.8.8.8 $MY_HOSTNAME)

if [[ "$MY_IP" = "$MY_HOSTNAME_IP" ]]
then

if [ ! -f /etc/systemd/system/multi-user.target.wants/nginx.service ]
then
sudo systemctl enable nginx.service
fi

sudo apt install socat -y

if [ ! -f $HOME/.acme.sh/${MY_HOSTNAME}_ecc/fullchain.cer ]
then
$HOME/.acme.sh/acme.sh --issue -d $MY_HOSTNAME --keylength ec-384 --standalone --pre-hook "service nginx stop " --post-hook "service nginx start"
fi

if [ -d /etc/letsencrypt/live/$MY_HOSTNAME ]
then
rm -rf /etc/letsencrypt/live/$MY_HOSTNAME/*
else
mkdir -p /etc/letsencrypt/live/$MY_HOSTNAME
fi

# install acme.sh if needed
echo ""
echo "checking if acme.sh is already installed"
echo ""
if [ ! -f ~/.acme.sh/acme.sh ]; then
echo ""
echo "installing acme.sh"
echo ""
wget -O - https://get.acme.sh | sh
fi

echo ""
echo "checking if dig is available"
echo ""
if [ ! -x /usr/bin/dig ]; then
apt-get install bind9-host -y >>/dev/null
fi

NET_INTERFACES_WAN=$(ip -4 route get 8.8.8.8 | grep -oP "dev [^[:space:]]+ " | cut -d ' ' -f 2)
MY_IP=$(ip -4 address show ${NET_INTERFACES_WAN} | grep 'inet' | sed 's/.*inet \([0-9\.]\+\).*/\1/')
MY_HOSTNAME=$(/bin/hostname -f)
MY_HOSTNAME_IP=$(/usr/bin/dig +short @8.8.8.8 "$MY_HOSTNAME")

if [[ "$MY_IP" = "$MY_HOSTNAME_IP" ]]; then

[ ! -f /etc/systemd/system/multi-user.target.wants/nginx.service ] && {

sudo systemctl enable nginx.service
}

sudo apt install socat -y

[ ! -f $HOME/.acme.sh/${MY_HOSTNAME}_ecc/fullchain.cer ] && {

$HOME/.acme.sh/acme.sh --issue -d $MY_HOSTNAME --keylength ec-384 --standalone --pre-hook "service nginx stop " --post-hook "service nginx start"
}

if [ -d /etc/letsencrypt/live/$MY_HOSTNAME ]; then
rm -rf /etc/letsencrypt/live/$MY_HOSTNAME/*
else
mkdir -p /etc/letsencrypt/live/$MY_HOSTNAME
fi
[ -f $HOME/.acme.sh/${MY_HOSTNAME}_ecc/fullchain.cer ] && {
# install the cert and reload nginx
$HOME/.acme.sh/acme.sh --install-cert -d ${MY_HOSTNAME} --ecc \
--cert-file /etc/letsencrypt/live/${MY_HOSTNAME}/cert.pem \
--key-file /etc/letsencrypt/live/${MY_HOSTNAME}/key.pem \
--fullchain-file /etc/letsencrypt/live/${MY_HOSTNAME}/fullchain.pem \
--reloadcmd "systemctl reload nginx.service"

if [ -f /etc/letsencrypt/live/${MY_HOSTNAME}/fullchain.pem ] && [ -f /etc/letsencrypt/live/${MY_HOSTNAME}/key.pem ]
then
sed -i "s/ssl_certificate \/var\/www\/22222\/cert\/22222.crt;/ssl_certificate \/etc\/letsencrypt\/live\/${MY_HOSTNAME}\/fullchain.pem;/" /etc/nginx/sites-available/22222
sed -i "s/ssl_certificate_key \/var\/www\/22222\/cert\/22222.key;/ssl_certificate_key \/etc\/letsencrypt\/live\/${MY_HOSTNAME}\/key.pem;/" /etc/nginx/sites-available/22222
fi
service nginx reload
--cert-file /etc/letsencrypt/live/${MY_HOSTNAME}/cert.pem \
--key-file /etc/letsencrypt/live/${MY_HOSTNAME}/key.pem \
--fullchain-file /etc/letsencrypt/live/${MY_HOSTNAME}/fullchain.pem \
--reloadcmd "systemctl enable nginx.service && service nginx restart"
}

if [ -f /etc/letsencrypt/live/${MY_HOSTNAME}/fullchain.pem ] && [ -f /etc/letsencrypt/live/${MY_HOSTNAME}/key.pem ]; then

sed -i "s/ssl_certificate \/var\/www\/22222\/cert\/22222.crt;/ssl_certificate \/etc\/letsencrypt\/live\/${MY_HOSTNAME}\/fullchain.pem;/" /etc/nginx/sites-available/22222
sed -i "s/ssl_certificate_key \/var\/www\/22222\/cert\/22222.key;/ssl_certificate_key \/etc\/letsencrypt\/live\/${MY_HOSTNAME}\/key.pem;/" /etc/nginx/sites-available/22222
fi
}
service nginx reload

ee-acme-22222
fi

Loading…
Cancel
Save