diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1c544d8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,20 @@ +# +# Configure line ending normalisation for this repository. +# See http://schacon.github.io/git/gitattributes.html for more information. +# +# Also each developer should configure the old style normalisation on her workstation +# (see http://timclem.wordpress.com/2012/03/01/mind-the-end-of-your-line/): +# +# Windows user should use: git config --global core.autocrlf = true +# Unix/Linux users should use: git config --global core.autocrlf = input +# + +# Auto detect text files and perform LF normalization +* text=auto + +*.txt text +*.xml text diff=xml +# Shell scripts require LF +*.sh text eol=lf +# Batch scripts require CRLF +*.bat text eol=crlf diff --git a/bin/acme.sh b/bin/acme.sh index f0650c0..dc9a549 100755 --- a/bin/acme.sh +++ b/bin/acme.sh @@ -8,6 +8,11 @@ TYPE=0 CONT_NAME='litespeed' ACME_SRC='https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh' EPACE=' ' +RENEW='' +RENEW_ALL='' +FORCE='' +REVOKE='' +REMOVE='' echow(){ FLAG=${1} @@ -31,6 +36,16 @@ help_message(){ echo -e "\033[1m Only for the First time\033[0m" echow '--install --email [EMAIL_ADDR]' echo "${EPACE}${EPACE}Will install ACME with the Email provided" + echow '-r, --renew' + echo "${EPACE}${EPACE}Renew a specific domain with -D or --domain parameter if posibile. To force renew, use -f parameter." + echow '-R, --renew-all' + echo "${EPACE}${EPACE}Renew all domains if possible. To force renew, use -f parameter." + echow '-f, -F, --force' + echo "${EPACE}${EPACE}Force renew for a specific domain or all domains." + echow '-v, --revoke' + echo "${EPACE}${EPACE}Revoke a domain." + echow '-V, --remove' + echo "${EPACE}${EPACE}Remove a domain." exit 0 ;; "3") @@ -172,7 +187,57 @@ install_cert(){ echo '[End] Apply Lets Encrypt Certificate' } +renew_acme(){ + echo '[Start] Renew ACME' + if [ "${FORCE}" = 'true' ]; then + docker-compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew --domain ${1} --force" + else + docker-compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew --domain ${1}" + fi + echo '[End] Renew ACME' + lsws_restart +} + +renew_all_acme(){ + echo '[Start] Renew all ACME' + if [ "${FORCE}" = 'true' ]; then + docker-compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew-all --force" + else + docker-compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --renew-all" + fi + echo '[End] Renew all ACME' + lsws_restart +} + +revoke(){ + echo '[Start] Revoke a domain' + docker-compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --revoke --domain ${1}" + echo '[End] Revoke a domain' + lsws_restart +} + +remove(){ + echo '[Start] Remove a domain' + docker-compose exec ${CONT_NAME} su -c "~/.acme.sh/acme.sh --remove --domain ${1}" + echo '[End] Remove a domain' + lsws_restart +} + main(){ + if [ "${RENEW_ALL}" = 'true' ]; then + renew_all_acme + exit 0 + elif [ "${RENEW}" = 'true' ]; then + renew_acme ${DOMAIN} + exit 0 + elif [ "${REVOKE}" = 'true' ]; then + revoke ${DOMAIN} + exit 0 + elif [ "${REMOVE}" = 'true' ]; then + remove ${DOMAIN} + exit 0 + fi + check_acme domain_filter ${DOMAIN} www_domain ${DOMAIN} @@ -198,7 +263,22 @@ while [ ! -z "${1}" ]; do -[uU] | --uninstall ) UNINSTALL=true uninstall_acme - ;; + ;; + -[fF] | --force ) + FORCE=true + ;; + -[r] | --renew ) + RENEW=true + ;; + -[R] | --renew-all ) + RENEW_ALL=true + ;; + -[v] | --revoke ) + REVOKE=true + ;; + -[V] | --remove ) + REMOVE=true + ;; -[eE] | --email ) shift check_input "${1}" EMAIL="${1}" diff --git a/docker-compose.yml b/docker-compose.yml index 9818264..88ac96d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,28 +2,32 @@ version: '3' services: mysql: image: mariadb:10.5.9 + logging: + driver: none command: --max_allowed_packet=256M volumes: - "./data/db:/var/lib/mysql:delegated" - ports: - - "3306:3306" environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} restart: always + networks: + - default litespeed: image: litespeedtech/openlitespeed:${OLS_VERSION}-${PHP_VERSION} + logging: + driver: none env_file: - .env volumes: - - ./lsws/conf:/usr/local/lsws/conf - - ./lsws/admin-conf:/usr/local/lsws/admin/conf - - ./bin/container:/usr/local/bin - - ./sites:/var/www/vhosts/ - - ./acme:/root/.acme.sh/ - - ./logs:/usr/local/lsws/logs/ + - ./lsws/conf:/usr/local/lsws/conf + - ./lsws/admin-conf:/usr/local/lsws/admin/conf + - ./bin/container:/usr/local/bin + - ./sites:/var/www/vhosts/ + - ./acme:/root/.acme.sh/ + - ./logs:/usr/local/lsws/logs/ ports: - 80:80 - 443:443 @@ -32,11 +36,20 @@ services: restart: always environment: TZ: ${TimeZone} + networks: + - default phpmyadmin: image: bitnami/phpmyadmin:5.0.2-debian-10-r72 + logging: + driver: none ports: - 8080:80 - 8443:443 environment: - DATABASE_HOST: mysql - restart: always + DATABASE_HOST: mysql + restart: always + networks: + - default +networks: + default: + driver: bridge \ No newline at end of file