Переделал на echo

Доработал acme скрипт
master
Rinsvent 2 years ago
parent c43c16eb8d
commit ad55c296d6
  1. 13
      src/acme.sh
  2. 12
      src/condition.sh
  3. 18
      src/condition.test.sh
  4. 12
      src/logger.sh
  5. 22
      src/var.sh
  6. 15
      src/var.test.sh

@ -1 +1,14 @@
#!/bin/bash
. ./var.sh
# You should declare ACME_EMAIL/ACME_WEBROOT/ACME_DIRECTORY variables before source
# generateCertificate $host
# generateCertificate rinsvent.ru
generateCertificate () {
local email=$(getVar ACME_EMAIL)
local webroot=$(getVar ACME_WEBROOT)
local directory=$(getVar ACME_DIRECTORY)
certbot certonly --noninteractive --agree-tos --cert-name "$1" -d "$1" -m "$email" --webroot -w "$webroot"
cp /etc/letsencrypt/live/"$1"/fullchain.pem "$directory"/"$1".pem
cp /etc/letsencrypt/live/"$1"/privkey.pem "$directory"/"$1"-key.pem
}

@ -1,11 +1,15 @@
#!/bin/bash
equal() {
local RETURN
RETURN=0
if [[ "$1" = "$2" ]];
then
RETURN=1
echo "1"
fi
}
more() {
if [[ "$1" = "$2" ]];
then
echo "1"
fi
echo $RETURN
}

@ -3,22 +3,32 @@
. ./condition.sh
# equal
if [ $(equal 1 1) -eq 1 ]
if [ "$(equal 1 1)" ]
then
echo "equal numeric"
fi
if [[ $(equal 1 2) -eq 0 ]]
if [[ ! $(equal 1 2) ]]
then
echo "not equal numeric"
fi
if [[ $(equal "asdf" "asdf") -eq 1 ]]
if [[ $(equal "asdf" "asdf") ]]
then
echo "equal string"
fi
if [[ $(equal "asdf" "asdf1") -eq 0 ]]
if [[ ! $(equal "asdf" "asdf1") ]]
then
echo "not equal string"
fi
[ "$(equal "afsdf" "afsdf")" ] && [ "$(equal 1 1)" ] && echo "AND condition 1 && 1"
[ "$(equal "afsdf" "afs")" ] && [ "$(equal 1 1)" ] && echo "AND condition 0 && 1"
[ "$(equal "afsdf" "afsdf")" ] && [ "$(equal 1 3)" ] && echo "AND condition 1 && 0"
[ "$(equal "afsdf" "afsdfsdfg")" ] && [ "$(equal 1 3)" ] && echo "AND condition 0 && 0"
[ "$(equal "afsdf" "afsdf")" ] || [ "$(equal 1 1)" ] && echo "OR condition 1 || 1"
[ "$(equal "afsdf" "afs")" ] || [ "$(equal 1 1)" ] && echo "OR condition 0 || 1"
[ "$(equal "afsdf" "afsdf")" ] || [ "$(equal 1 3)" ] && echo "OR condition 1 || 0"
[ "$(equal "afsdf" "afsdfsdfg")" ] || [ "$(equal 1 3)" ] && echo "OR condition 0 || 0"

@ -9,18 +9,12 @@
# info = 3
# debug = 9
getVar LOGGER_LEVEL 1
LOGGER_LEVEL=$RETURN
getVar LOG_PATH ''
LOG_PATH=$RETURN
LOGGER_LEVEL=$(getVar LOGGER_LEVEL 1)
LOG_PATH=$(getVar LOG_PATH)
ENDCOLOR="\e[0m"
function getLogPath() {
getVar LOG_PATH ''
local LOCAL_LOG_PATH=$RETURN
local LOCAL_LOG_PATH=$(getVar LOG_PATH '')
local YEAR
YEAR=$(date +%Y)
LOCAL_LOG_PATH=$(echo "$LOCAL_LOG_PATH" | sed -r "s/%Y/$YEAR/g")

@ -1,16 +1,24 @@
#!/bin/bash
getVar() {
VAR_NAME=$1
VAR_VALUE=${!VAR_NAME}
if [ -z $VAR_VALUE ]
local VAR_NAME=$1
local VAR_VALUE=${!VAR_NAME}
if [ -z "$VAR_VALUE" ]
then
if [ $# -eq 2 ]
then
VAR_VALUE=$2
else
VAR_VALUE=NULL
echo "$2"
fi
else
echo "$VAR_VALUE"
fi
}
existsVar() {
VAR_NAME=$1
VAR_VALUE=${!VAR_NAME}
if [ -n "$VAR_VALUE" ]
then
echo "1"
fi
RETURN=$VAR_VALUE
}

@ -3,9 +3,12 @@
TEMP=5234
. ./var.sh
getVar TEMP false
echo "RESULT $RETURN"
getVar TEMP2 false
echo "RESULT $RETURN"
getVar TEMP2
echo "RESULT $RETURN"
TEMP=$(getVar TEMP false)
echo "RESULT $TEMP"
echo "RESULT $(getVar TEMP false)"
echo "RESULT $(getVar TEMP2 false)"
echo "RESULT $(getVar TEMP2)"
echo "EXISTS $(existsVar TEMP)"
echo "NOT EXISTS $(existsVar TEMP2)"

Loading…
Cancel
Save