Skip to content

Commit

Permalink
hooks/conf_regen: Fix some shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamandar committed Dec 21, 2024
1 parent 3e90d35 commit df6dc90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 6 additions & 5 deletions hooks/conf_regen/30-opendkim
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

set -e
# Exit hook on subcommand error or unset variable
set -Eeuo pipefail

do_pre_regen() {
pending_dir=$1

cd /usr/share/yunohost/conf/opendkim

install -D -m 644 opendkim.conf "${pending_dir}/etc/opendkim.conf"
install -D -m 644 opendkim.conf "$pending_dir/etc/opendkim.conf"
}

do_post_regen() {
Expand All @@ -39,14 +40,14 @@ do_post_regen() {
domain_list="$(yunohost domain list --features mail_in mail_out --output-as json | jq -r ".domains[]" | tr '\n' ' ')"
for domain in $domain_list; do
domain_key="/etc/dkim/${domain}.mail.key"
[ ! -f "$domain_key" ] && {
if [ ! -f "$domain_key" ]; then
# We use a 1024 bit size because nsupdate doesn't seem to be able to
# handle 2048...
opendkim-genkey --domain="$domain" \
--selector=mail --directory=/etc/dkim -b 1024
mv /etc/dkim/mail.private "$domain_key"
mv /etc/dkim/mail.txt "/etc/dkim/${domain}.mail.txt"
}
fi

echo "mail._domainkey.${domain} ${domain}:mail:${domain_key}" >> /etc/dkim/keytable
echo "*@$domain mail._domainkey.${domain}" >> /etc/dkim/signingtable
Expand All @@ -58,4 +59,4 @@ do_post_regen() {
systemctl restart opendkim
}

do_$1_regen ${@:2}
"do_$1_regen" "${@:2}"
12 changes: 7 additions & 5 deletions hooks/conf_regen/46-nsswitch
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

set -e
# Exit hook on subcommand error or unset variable
set -Eeuo pipefail

do_init_regen() {
do_pre_regen ""
Expand All @@ -30,14 +31,15 @@ do_pre_regen() {

cd /usr/share/yunohost/conf/nsswitch

install -D -m 644 nsswitch.conf "${pending_dir}/etc/nsswitch.conf"
install -D -m 644 nsswitch.conf "$pending_dir/etc/nsswitch.conf"
}

do_post_regen() {
regen_conf_files=$1

[[ -z "$regen_conf_files" ]] \
|| systemctl restart unscd
if [[ -n "$regen_conf_files" ]]; then
systemctl restart unscd
fi
}

do_$1_regen ${@:2}
"do_$1_regen" "${@:2}"

0 comments on commit df6dc90

Please sign in to comment.