25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Fix Shellcheck warnings in shell scripts

This commit is contained in:
Badlop 2023-02-14 21:47:28 +01:00
parent c9143dd3d8
commit 2137a4f663
4 changed files with 46 additions and 43 deletions

View File

@ -1,25 +1,24 @@
echo -n "===> Preparing dev configuration files: "
printf "===> Preparing dev configuration files: "
PWD_DIR=`pwd`
PWD_DIR=$(pwd)
REL_DIR=$PWD_DIR/_build/dev/rel/ejabberd/
CON_DIR=$REL_DIR/conf/
[ -z "$REL_DIR_TEMP" ] && REL_DIR_TEMP=$REL_DIR
CON_DIR_TEMP=$REL_DIR_TEMP/conf/
BIN_DIR_TEMP=$REL_DIR_TEMP/bin/
cd $CON_DIR_TEMP
cd $CON_DIR_TEMP || exit
sed -i "s|# certfiles:|certfiles:\n - $CON_DIR/cert.pem|g" ejabberd.yml.example
sed -i "s|certfiles:|ca_file: $CON_DIR/ca.pem\ncertfiles:|g" ejabberd.yml.example
sed -i 's|^acl:$|acl:\n admin: [user: admin]|g' ejabberd.yml.example
[ ! -f "$CON_DIR/ejabberd.yml" ] \
&& echo -n "ejabberd.yml " \
&& printf "ejabberd.yml " \
&& mv ejabberd.yml.example ejabberd.yml
sed -i "s|#' POLL|EJABBERD_BYPASS_WARNINGS=true\n\n#' POLL|g" ejabberdctl.cfg.example
[ ! -f "$CON_DIR/ejabberdctl.cfg" ] \
&& echo -n "ejabberdctl.cfg " \
&& printf "ejabberdctl.cfg " \
&& mv ejabberdctl.cfg.example ejabberdctl.cfg
echo ""

View File

@ -1,4 +1,4 @@
PWD_DIR=`pwd`
PWD_DIR=$(pwd)
REL_DIR=$PWD_DIR/_build/relive/
CON_DIR=$REL_DIR/conf/
@ -15,17 +15,17 @@ cp ejabberd.yml.example $CON_DIR/ejabberd.yml.example
cp test/ejabberd_SUITE_data/ca.pem $CON_DIR
cp test/ejabberd_SUITE_data/cert.pem $CON_DIR
cd $CON_DIR_TEMP
cd $CON_DIR_TEMP || exit
sed -i "s|# certfiles:|certfiles:\n - $CON_DIR/cert.pem|g" ejabberd.yml.example
sed -i "s|certfiles:|ca_file: $CON_DIR/ca.pem\ncertfiles:|g" ejabberd.yml.example
sed -i 's|^acl:$|acl:\n admin: [user: admin]|g' ejabberd.yml.example
[ ! -f "$CON_DIR/ejabberd.yml" ] \
&& echo -n "ejabberd.yml " \
&& printf "ejabberd.yml " \
&& mv ejabberd.yml.example ejabberd.yml
sed -i "s|#' POLL|EJABBERD_BYPASS_WARNINGS=true\n\n#' POLL|g" ejabberdctl.cfg.example
[ ! -f "$CON_DIR/ejabberdctl.cfg" ] \
&& echo -n "ejabberdctl.cfg " \
&& printf "ejabberdctl.cfg " \
&& mv ejabberdctl.cfg.example ejabberdctl.cfg \
|| echo -n
|| printf

View File

@ -76,7 +76,7 @@ write_rfcs()
int=$(echo $1 | sed 's/^0*//')
imp=$(grep "\-protocol({rfc, $int," $BASE/src/* | sed "s/.*src\/\(.*\).erl.*'\([0-9.-]*\)'.*/\1 \2/")
[ "$imp" == "" ] && imp="NA 0.0"
[ "$imp" = "" ] && imp="NA 0.0"
echo " <implements rdf:resource=\"https://www.rfc-editor.org/info/$rfc\"/>" >>$out
}
@ -88,7 +88,7 @@ write_xeps()
comments2=""
int=$(echo $1 | sed 's/^0*//')
imp=$(grep "\-protocol({xep, $int," $BASE/src/* | sed "s/.*src\/\(.*\).erl.*'\([0-9.-]*\)'.*/\1 \2/")
[ "$imp" == "" ] && imp="NA 0.0"
[ "$imp" = "" ] && imp="NA 0.0"
sourcefiles=$(grep "\-protocol({xep, $int," $BASE/src/* | sed "s/.*src\/\(.*\).erl.*'\([0-9.-]*\)'.*/\1/" | tr '\012' ',' | sed 's|,$||' | sed 's|,|, |g' | sed 's|^ejabberd$||')
@ -103,15 +103,17 @@ write_xeps()
[ -n "$comments" ] && comments2=", $comments"
note="$sourcefiles$comments2"
echo " <implements>" >>$out
echo " <xmpp:SupportedXep>" >>$out
echo " <xmpp:xep rdf:resource=\"https://xmpp.org/extensions/$xep.html\"/>" >>$out
echo " <xmpp:version>$versions</xmpp:version>" >>$out
echo " <xmpp:since>$since</xmpp:since>" >>$out
echo " <xmpp:status>$status</xmpp:status>" >>$out
echo " <xmpp:note>$note</xmpp:note>" >>$out
echo " </xmpp:SupportedXep>" >>$out
echo " </implements>" >>$out
{
echo " <implements>"
echo " <xmpp:SupportedXep>"
echo " <xmpp:xep rdf:resource=\"https://xmpp.org/extensions/$xep.html\"/>"
echo " <xmpp:version>$versions</xmpp:version>"
echo " <xmpp:since>$since</xmpp:since>"
echo " <xmpp:status>$status</xmpp:status>"
echo " <xmpp:note>$note</xmpp:note>"
echo " </xmpp:SupportedXep>"
echo " </implements>"
} >>$out
}
[ $# -eq 1 ] && BASE="$1" || BASE="$PWD"
@ -121,13 +123,13 @@ final=ejabberd.doap
write_doap_head $final
for x_num in $(grep "\-protocol({rfc" $BASE/src/* | sed "s/,//" | awk '{printf("%04d\n", $2)}' | sort -u)
grep "\-protocol({rfc" $BASE/src/* | sed "s/,//" | awk '{printf("%04d\n", $2)}' | sort -u | while IFS= read -r x_num
do
write_rfcs $x_num $temp
done
echo "" >>$temp
for x_num in $(grep "\-protocol({xep" $BASE/src/* | sed "s/,//" | awk '{printf("%04d\n", $2)}' | sort -u)
grep "\-protocol({xep" $BASE/src/* | sed "s/,//" | awk '{printf("%04d\n", $2)}' | sort -u | while IFS= read -r x_num
do
write_xeps $x_num $temp
done

View File

@ -32,7 +32,7 @@ extract_lang_po2msg ()
MSGSTR_PATH=$PO_PATH.msgstr
MSGS_PATH=$LANG_CODE.msg
cd $PO_DIR
cd $PO_DIR || exit
# Check PO has correct ~
# Let's convert to C format so we can use msgfmt
@ -48,11 +48,13 @@ extract_lang_po2msg ()
msgattrib $PO_PATH --translated --no-fuzzy --no-obsolete --no-location --no-wrap | grep "^msg" | tail --lines=+3 >$MS_PATH
grep "^msgid" $PO_PATH.ms | sed 's/^msgid //g' >$MSGID_PATH
grep "^msgstr" $PO_PATH.ms | sed 's/^msgstr //g' >$MSGSTR_PATH
echo "%% Generated automatically" >$MSGS_PATH
echo "%% DO NOT EDIT: run \`make translations\` instead" >>$MSGS_PATH
echo "%% To improve translations please read:" >>$MSGS_PATH
echo "%% https://docs.ejabberd.im/developer/extending-ejabberd/localization/" >>$MSGS_PATH
echo "" >>$MSGS_PATH
{
echo "%% Generated automatically"
echo "%% DO NOT EDIT: run \`make translations\` instead"
echo "%% To improve translations please read:"
echo "%% https://docs.ejabberd.im/developer/extending-ejabberd/localization/"
echo ""
} >>$MSGS_PATH
paste $MSGID_PATH $MSGSTR_PATH --delimiter=, | awk '{print "{" $0 "}."}' | sort -g >>$MSGS_PATH
rm $MS_PATH
@ -68,29 +70,29 @@ extract_lang_updateall ()
echo "Generating POT..."
extract_lang_src2pot
cd $MSGS_DIR
cd $MSGS_DIR || exit
echo ""
echo -e "File Missing (fuzzy) Language Last translator"
echo -e "---- ------- ------- -------- ---------------"
for i in $( ls *.msg ) ; do
echo "File Missing (fuzzy) Language Last translator"
echo "---- ------- ------- -------- ---------------"
for i in *.msg ; do
LANG_CODE=${i%.msg}
echo -n $LANG_CODE | awk '{printf "%-6s", $1 }'
printf "%s" "$LANG_CODE" | awk '{printf "%-6s", $1 }'
PO=$PO_DIR/$LANG_CODE.po
extract_lang_popot2po $LANG_CODE
extract_lang_po2msg $LANG_CODE
MISSING=`msgfmt --statistics $PO 2>&1 | awk '{printf "%5s", $4+$7 }'`
echo -n " $MISSING"
MISSING=$(msgfmt --statistics $PO 2>&1 | awk '{printf "%5s", $4+$7 }')
printf " %s" "$MISSING"
FUZZY=`msgfmt --statistics $PO 2>&1 | awk '{printf "%7s", $4 }'`
echo -n " $FUZZY"
FUZZY=$(msgfmt --statistics $PO 2>&1 | awk '{printf "%7s", $4 }')
printf " %s" "$FUZZY"
LANGUAGE=`grep "X-Language:" $PO | sed 's/\"X-Language: //g' | sed 's/\\\\n\"//g' | awk '{printf "%-12s", $1}'`
echo -n " $LANGUAGE"
LANGUAGE=$(grep "X-Language:" $PO | sed 's/\"X-Language: //g' | sed 's/\\n\"//g' | awk '{printf "%-12s", $1}')
printf " %s" "$LANGUAGE"
LASTAUTH=`grep "Last-Translator" $PO | sed 's/\"Last-Translator: //g' | sed 's/\\\\n\"//g'`
LASTAUTH=$(grep "Last-Translator" $PO | sed 's/\"Last-Translator: //g' | sed 's/\\n\"//g')
echo " $LASTAUTH"
done
echo ""
@ -101,7 +103,7 @@ extract_lang_updateall ()
cd ..
}
EJA_DIR=`pwd`
EJA_DIR=$(pwd)
PROJECT=ejabberd
DEPS_DIR=$1
MSGS_DIR=$EJA_DIR/priv/msgs