app's scripts: try to use long options

This commit is contained in:
Jeremy Gardais 2021-07-07 12:42:13 +02:00
parent af622337ff
commit 7da80f22f9
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
5 changed files with 13 additions and 13 deletions

View File

@ -48,11 +48,11 @@ else
discord_current_version=$(dpkg --list -- discord | awk '/^ii *discord/ {print $3}' | sed 's/.:\(.*\)-.*/\1/') discord_current_version=$(dpkg --list -- discord | awk '/^ii *discord/ {print $3}' | sed 's/.:\(.*\)-.*/\1/')
fi fi
discord_new_version=$(curl -s 'https://discord.com/api/download?platform=linux&format=deb' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep " href=\"https" | sed -e 's;.*.deb">.*/apps/linux/\(.*\)/discord.*.deb</a>.*;\1;') discord_new_version=$(curl --silent 'https://discord.com/api/download?platform=linux&format=deb' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep " href=\"https" | sed -e 's;.*.deb">.*/apps/linux/\(.*\)/discord.*.deb</a>.*;\1;')
discord_new_version_file="/tmp/.discord.upgrade" discord_new_version_file="/tmp/.discord.upgrade"
discord_new_pkg_url=$(curl -s 'https://discord.com/api/download?platform=linux&format=deb' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep " href=\"https" | sed -e 's;.*href="\(.*.deb\)">.*;\1;') discord_new_pkg_url=$(curl --silent 'https://discord.com/api/download?platform=linux&format=deb' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep " href=\"https" | sed -e 's;.*href="\(.*.deb\)">.*;\1;')
discord_new_pkg_path="/tmp/discord-${discord_new_version}.deb" discord_new_pkg_path="/tmp/discord-${discord_new_version}.deb"
# }}} # }}}

View File

@ -42,7 +42,7 @@ pihole_new_version_file="/tmp/.pihole.upgrade"
# }}} # }}}
# Check the current status with pihole subcommand {{{ # Check the current status with pihole subcommand {{{
if printf -- '%s' "${pihole_current_status}" | grep -q -- "Everything is up to date"; then if printf -- '%s' "${pihole_current_status}" | grep --quiet -- "Everything is up to date"; then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Pi-hole seems up to date." [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Pi-hole seems up to date."
## Ensure to remove any temp file ## Ensure to remove any temp file
rm --force -- "${pihole_new_version_file}" rm --force -- "${pihole_new_version_file}"

View File

@ -28,12 +28,12 @@ fi
cd "$(dirname ${JENKINS_AUTH_FILE})" || exit cd "$(dirname ${JENKINS_AUTH_FILE})" || exit
# Verify if updates are availables for plugins # Verify if updates are availables for plugins
if java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep -i -q -- "(.*)$" if java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep --ignore-case --quiet -- "(.*)$"
then then
touch "${JENKINS_PLUGIN_UPDATE_LOG}" touch "${JENKINS_PLUGIN_UPDATE_LOG}"
#printf '%b\n' "Please upgrade plugins" #printf '%b\n' "Please upgrade plugins"
else else
rm -f -- "${JENKINS_PLUGIN_UPDATE_LOG}" rm --force -- "${JENKINS_PLUGIN_UPDATE_LOG}"
#printf '%b\n' "Nothing to do" #printf '%b\n' "Nothing to do"
fi fi
cd - > /dev/null || exit cd - > /dev/null || exit

View File

@ -27,22 +27,22 @@ if [ ! -f "${JENKINS_AUTH_FILE}" ]; then
fi fi
if [ -f "${JENKINS_PLUGIN_LIST_FILE}" ]; then if [ -f "${JENKINS_PLUGIN_LIST_FILE}" ]; then
rm -f -- "${JENKINS_PLUGIN_LIST_FILE}" rm --force -- "${JENKINS_PLUGIN_LIST_FILE}"
fi fi
# Move to the directory where authentication file is stored # Move to the directory where authentication file is stored
cd "$(dirname ${JENKINS_AUTH_FILE})" || exit cd "$(dirname ${JENKINS_AUTH_FILE})" || exit
# Verify if updates are available for plugins # Verify if updates are available for plugins
if java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep -i -q -- "(.*)$" if java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep --ignore-case --quiet -- "(.*)$"
then then
# Store the list of plugins to upgrade in a file, one by line # Store the list of plugins to upgrade in a file, one by line
java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep -i -- "(.*)$" | cut -d" " -f1 > "${JENKINS_PLUGIN_LIST_FILE}" java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep --ignore-case -- "(.*)$" | cut --delimiter=" " --fields=1 > "${JENKINS_PLUGIN_LIST_FILE}"
# Upgrade plugins one by one # Upgrade plugins one by one
while IFS= read -r plugin; do while IFS= read -r plugin; do
#printf '%b\n' "Upgrading: ${plugin}" #printf '%b\n' "Upgrading: ${plugin}"
java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth install-plugin "${plugin}" > /dev/null & java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth install-plugin "${plugin}" > /dev/null &
# Wait for the end of the upgrade # Wait for the end of the upgrade
while ps axg | grep -vw grep | grep -w "install-plugin ${plugin}" > /dev/null; do sleep 1; done while ps axg | grep --invert-match --word-regexp grep | grep --word-regexp "install-plugin ${plugin}" > /dev/null; do sleep 1; done
# With pgrep, it still runs 4~5 java commands at the same time # With pgrep, it still runs 4~5 java commands at the same time
#while pgrep -f "install-plugin ${plugin}" > /dev/null; do sleep 1; done #while pgrep -f "install-plugin ${plugin}" > /dev/null; do sleep 1; done
done < "${JENKINS_PLUGIN_LIST_FILE}" done < "${JENKINS_PLUGIN_LIST_FILE}"
@ -55,6 +55,6 @@ cd - > /dev/null || exit
# Purge "log" files older than 30 days # Purge "log" files older than 30 days
find "${JENKINS_HOME}/updates" -iname ".plugin_list*" -mtime +30 -delete find "${JENKINS_HOME}/updates" -iname ".plugin_list*" -mtime +30 -delete
rm -f -- "${JENKINS_PLUGIN_UPDATE_LOG}" rm --force -- "${JENKINS_PLUGIN_UPDATE_LOG}"
exit 0 exit 0

View File

@ -174,7 +174,7 @@ main() { # {{{
## }}} ## }}}
## Get the list of .deb files to manage {{{ ## Get the list of .deb files to manage {{{
rm -f -- "${packages_list_file}" rm --force -- "${packages_list_file}"
debug_message "main \ debug_message "main \
Get the list of .deb files to manage from ${reprepro_dir} directory and store it to ${packages_list_file} file." Get the list of .deb files to manage from ${reprepro_dir} directory and store it to ${packages_list_file} file."
find "${reprepro_dir}" -maxdepth 1 -type f -iname "*.deb" > "${packages_list_file}" find "${reprepro_dir}" -maxdepth 1 -type f -iname "*.deb" > "${packages_list_file}"
@ -237,7 +237,7 @@ Regenerate index files for ${release} codename."
if [ ! "${NBARGS}" -eq "0" ]; then if [ ! "${NBARGS}" -eq "0" ]; then
## If the first argument is not an option ## If the first argument is not an option
if ! printf -- '%s' "${1}" | grep -q -E -- "^-+"; if ! printf -- '%s' "${1}" | grep --quiet --extended-regexp -- "^-+";
then then
usage usage
error_message "Unknown argument (${1}), check the help." 2 error_message "Unknown argument (${1}), check the help." 2
@ -246,7 +246,7 @@ if [ ! "${NBARGS}" -eq "0" ]; then
manage_arg="0" manage_arg="0"
# Parse all options (start with a "-") one by one # Parse all options (start with a "-") one by one
while printf -- '%s' "${1}" | grep -q -E -- "^-+"; do while printf -- '%s' "${1}" | grep --quiet --extended-regexp -- "^-+"; do
case "${1}" in case "${1}" in
-d|--dir|--directory ) ## Set directory -d|--dir|--directory ) ## Set directory