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 df6dc90 commit e1a1452
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
9 changes: 6 additions & 3 deletions hooks/conf_regen/25-dovecot
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
# 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

. /usr/share/yunohost/helpers
# Source YNH helpers
# shellcheck source=../../helpers/helpers
source /usr/share/yunohost/helpers

do_pre_regen() {
pending_dir=$1
Expand Down Expand Up @@ -87,4 +90,4 @@ do_post_regen() {
systemctl restart dovecot
}

do_$1_regen ${@:2}
"do_$1_regen" "${@:2}"
19 changes: 10 additions & 9 deletions hooks/conf_regen/37-mdns
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
# 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

_generate_config() {
echo "domains:"
# Add yunohost.local (only if yunohost.local ain't already in ynh_domains)
if ! echo "$YNH_DOMAINS" | tr ' ' '\n' | grep -q --line-regexp 'yunohost.local'; then
if ! echo "${YNH_DOMAINS:-}" | tr ' ' '\n' | grep -q --line-regexp 'yunohost.local'; then
echo " - yunohost.local"
fi
for domain in $YNH_DOMAINS; do
for domain in ${YNH_DOMAINS:-}; do
# Only keep .local domains (don't keep
[[ "$domain" =~ [^.]+\.[^.]+\.local$ ]] && echo "Subdomain $domain cannot be handled by Bonjour/Zeroconf/mDNS" >&2
[[ "$domain" =~ ^[^.]+\.local$ ]] || continue
Expand All @@ -40,7 +41,7 @@ _generate_config() {
}

do_init_regen() {
do_pre_regen
do_pre_regen ""
do_post_regen /etc/systemd/system/yunomdns.service
systemctl enable yunomdns --quiet
}
Expand All @@ -49,13 +50,13 @@ do_pre_regen() {
pending_dir="$1"

cd /usr/share/yunohost/conf/mdns
mkdir -p ${pending_dir}/etc/systemd/system/
cp yunomdns.service ${pending_dir}/etc/systemd/system/
mkdir -p "${pending_dir}/etc/systemd/system/"
cp yunomdns.service "${pending_dir}/etc/systemd/system/"

getent passwd mdns &> /dev/null || useradd --no-create-home --shell /usr/sbin/nologin --system --user-group mdns

mkdir -p ${pending_dir}/etc/yunohost
_generate_config > ${pending_dir}/etc/yunohost/mdns.yml
mkdir -p "$pending_dir/etc/yunohost"
_generate_config > "$pending_dir/etc/yunohost/mdns.yml"
}

do_post_regen() {
Expand All @@ -78,4 +79,4 @@ do_post_regen() {
|| systemctl restart yunomdns
}

do_$1_regen ${@:2}
"do_$1_regen" "${@:2}"
9 changes: 6 additions & 3 deletions hooks/conf_regen/52-fail2ban
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
# 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

. /usr/share/yunohost/helpers
# Source YNH helpers
# shellcheck source=../../helpers/helpers
source /usr/share/yunohost/helpers

do_pre_regen() {
pending_dir=$1
Expand Down Expand Up @@ -52,4 +55,4 @@ do_post_regen() {
|| systemctl reload fail2ban
}

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

0 comments on commit e1a1452

Please sign in to comment.