dotfiles/.config/bash/iridion.bash

51 lines
1.4 KiB
Bash
Raw Normal View History

2023-08-07 15:05:54 +00:00
set -o pipefail
2023-10-04 15:17:06 +00:00
alias localip="ip addr show | grep -E '(ens|eth)' | grep -oP '"'(?<=inet\s)\d+(\.\d+){3}'"' | head -1"
letsencrypt() {
(
ip=$(localip)
IFS=$'\n'
for user in $(list users)
do for domain in $(hestia v-list-web-domains $user | grep $ip | awk '{print $1}')
do #echo "Checking $user $domain" >&2
hestia v-list-web-domain-ssl $user $domain | grep -q . && continue
hestia v-list-web-domain $user $domain | grep -q REDIRECT && continue
#echo "Generating Certificate" >&2
hestia v-add-letsencrypt-domain $user $domain $(hestia v-list-web-domain $user $domain | grep ALIAS | tr -s ' ' | cut -d' ' -f2- | tr ' ' ',')
done
done
)
}
2023-08-07 15:05:54 +00:00
list() {
type="$1"
shift
if test $# -eq 0 && echo $type | grep -q -- '-domains$'
2023-10-04 15:17:06 +00:00
then for user in $(list users)
do if test -t 1
then echo "$user" && list "$type" "$user"
else list "$type" "$user" | sed "s|^|$user |"
fi
done
2023-08-07 15:05:54 +00:00
else if test -t 1
2023-10-04 15:17:06 +00:00
then sudo "$HESTIA/bin/v-list-$type" "$@" | column -t
else sudo "$HESTIA/bin/v-list-$type" "$@" | tail +3 | awk '{print $1}'
fi
2023-08-07 15:05:54 +00:00
fi
}
hestia() {
2023-10-04 15:17:06 +00:00
test $# -eq 0 && cd "$HESTIA" && return 0
2023-08-07 15:05:54 +00:00
command=$1
shift
2023-10-04 15:17:06 +00:00
echo '>' sudo $(which $command) "$@" >&2
2023-08-07 15:05:54 +00:00
sudo $(which $command) "$@"
}
accessible() {
dir=/home/*/web/$1/public_html
sudo chmod -v 755 $dir
sudo chown -v :sudo $dir
}