From 803adb405fc1888f2ba51d1f2b105e018b754cd4 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Thu, 6 Jun 2024 20:59:19 +0300 Subject: [PATCH] pre-commit run --all-files --- bash/acmesh-ssl.bash | 2 +- bash/comms.bash | 12 ++++---- bash/deb-update.bash | 20 ++++++------- bash/deprecated/certbot-ssl.sh | 2 +- bash/deprecated/ydns-simple | 8 ++--- bash/deprecated/ydns6 | 4 +-- bash/iwd-wifi.bash | 2 +- bash/metropolia/calculator.bash | 50 +++++++++++++++---------------- bash/metropolia/employees.bash | 4 +-- bash/steamos-venv-pre-commit.bash | 4 +-- 10 files changed, 54 insertions(+), 54 deletions(-) diff --git a/bash/acmesh-ssl.bash b/bash/acmesh-ssl.bash index 6ebb02f..09345f2 100755 --- a/bash/acmesh-ssl.bash +++ b/bash/acmesh-ssl.bash @@ -64,7 +64,7 @@ chown -R oragono:oragono $ORAGONODIR # WeeChat relay, remember to /relay sslcertkey $ACMESH -d $DOMAINNAME --fullchain-file $WEECHATDIR/fullchain.pem --key-file $WEECHATDIR/privkey.pem -cat $WEECHATDIR/{fullchain,privkey}.pem >$WEECHATDIR/relay.pem +cat $WEECHATDIR/{fullchain,privkey}.pem > $WEECHATDIR/relay.pem chmod -R 700 $WEECHATDIR chown -R mikaela:mikaela $WEECHATDIR diff --git a/bash/comms.bash b/bash/comms.bash index 9479b7d..d160def 100755 --- a/bash/comms.bash +++ b/bash/comms.bash @@ -7,17 +7,17 @@ set -x # XMPP -if hash dino 2>/dev/null; then +if hash dino 2> /dev/null; then (dino &) fi -if hash gajim 2>/dev/null; then +if hash gajim 2> /dev/null; then (gajim &) else (flatpak run org.gajim.Gajim --quiet &) fi # Jami, mostly P2P app -if hash jami-gnome 2>/dev/null; then +if hash jami-gnome 2> /dev/null; then (jami-gnome -r &) fi @@ -25,18 +25,18 @@ fi if [ -f ~/.local/Telegram/Updater ]; then (~/.local/Telegram/Updater -many -startintray &) else - if hash telegram-desktop 2>/dev/null; then + if hash telegram-desktop 2> /dev/null; then (telegram-desktop -many -startintray &) fi fi # Keybase -if hash run_keybase 2>/dev/null; then +if hash run_keybase 2> /dev/null; then (run_keybase &) fi # Steam -if hash steam 2>/dev/null; then +if hash steam 2> /dev/null; then (STEAM_FRAME_FORCE_CLOSE=1 steam -silent &) fi diff --git a/bash/deb-update.bash b/bash/deb-update.bash index 8af8048..e276ab0 100755 --- a/bash/deb-update.bash +++ b/bash/deb-update.bash @@ -10,7 +10,7 @@ set -x export LC_ALL=C.utf8 # if hash checks that the command exists -if hash apt-get 2>/dev/null; then +if hash apt-get 2> /dev/null; then # I am not sure if -y here even does anything, at least it won't work for # accepting suite changes for Debian when testing becomes stable. # Checking for updates or new packages. @@ -26,20 +26,20 @@ if hash apt-get 2>/dev/null; then apt-get "$@" autoremove fi -if hash dpkg 2>/dev/null; then +if hash dpkg 2> /dev/null; then # In case dpkg was interrupted previously, configure packages. dpkg --configure -a fi # Enables Fedora third party repositories if not enabled, otherwise quiet. # My systems most likely have them already -if hash fedora-third-party 2>/dev/null; then +if hash fedora-third-party 2> /dev/null; then fedora-third-party enable # Are they enabled? fedora-third-party query fi -if hash dnf 2>/dev/null; then +if hash dnf 2> /dev/null; then # I don't know if -y does anything here either and I think this may be # useless, but I am used to it coming from apt and I think it will just # say nothing to do or do nothing if mirrors haven't updated. @@ -59,12 +59,12 @@ if hash dnf 2>/dev/null; then dnf -v "$@" autoremove fi -if hash rpmconf 2>/dev/null; then +if hash rpmconf 2> /dev/null; then # Tests if there are rpmsave/rpmnew files, hopefully is non-interactive rpmconf -a -t fi -if hash flatpak 2>/dev/null; then +if hash flatpak 2> /dev/null; then # Flatpak apps are sandboxed and should be safe to update automatically # KEEP --noninteractive IN PLACE! While it removes progress bar, it also # doesn't blink making it worth it in case of migraine attack. @@ -81,7 +81,7 @@ if hash flatpak 2>/dev/null; then flatpak uninstall --user --unused --assumeyes --noninteractive fi -if hash snap 2>/dev/null; then +if hash snap 2> /dev/null; then # I don't want my systems full of old snaps # > retain must be a number between 2 and 20, not "1" snap set system refresh.retain=2 @@ -95,19 +95,19 @@ fi # I don't have flatpak or snap going to background, because I often do # ./deb-update.bash && poweroff -if hash pkcon 2>/dev/null; then +if hash pkcon 2> /dev/null; then # So PackageKit using KDE Plasma and possibly GNOME stop alerting about # already installed updates. It has backends for all other package managers, # so it needs to be after them. pkcon refresh force fi -if hash apt-file 2>/dev/null; then +if hash apt-file 2> /dev/null; then # So the local apt-file database is up-to-date. apt-file update fi -if hash needrestart 2>/dev/null; then +if hash needrestart 2> /dev/null; then # needrestart batch mode, should be visible on bottom of scrollback # see https://github.com/liske/needrestart/blob/master/README.batch.md needrestart -b diff --git a/bash/deprecated/certbot-ssl.sh b/bash/deprecated/certbot-ssl.sh index 3c43d4e..bb12cab 100755 --- a/bash/deprecated/certbot-ssl.sh +++ b/bash/deprecated/certbot-ssl.sh @@ -16,4 +16,4 @@ chown -R mumble-server:mumble-server /var/lib/mumble-server/ssl/ pkill $(cat /var/run/mumble-server/mumble-server.pid) -USR1 # ZNC via https://wiki.znc.in/Signed_SSL_certificate#Certbot -cat /etc/letsencrypt/live/relpda.mikaela.info/{privkey,fullchain}.pem >/home/znc/.znc/znc.pem +cat /etc/letsencrypt/live/relpda.mikaela.info/{privkey,fullchain}.pem > /home/znc/.znc/znc.pem diff --git a/bash/deprecated/ydns-simple b/bash/deprecated/ydns-simple index 1363fd8..55ee72c 100755 --- a/bash/deprecated/ydns-simple +++ b/bash/deprecated/ydns-simple @@ -17,7 +17,7 @@ PASSWORD="" HOSTNAME="" # Get IPv4 address -if hash dig 2>/dev/null; then +if hash dig 2> /dev/null; then WAN_IP4=$(dig +short myip.opendns.com. A @208.67.220.220) else WAN_IP4=$(curl -sL4 https://icanhazip.com/) @@ -30,7 +30,7 @@ else fi # Get IPv6 address -if hash dig 2>/dev/null; then +if hash dig 2> /dev/null; then WAN_IP6=$(dig +short myip.opendns.com. AAAA @2620:0:ccd::2) else WAN_IP6=$(curl -sL6 https://icanhazip.com/) @@ -46,7 +46,7 @@ fi if [ "$WAN_IP4" = "$OLD_WAN_IP4" ]; then echo "IP4 Unchanged" else - echo $WAN_IP4 >$HOME/.wan_ip4-ydns.txt + echo $WAN_IP4 > $HOME/.wan_ip4-ydns.txt echo "Updating DNS to $WAN_IP4" curl -4 --basic -u "$USEREMAIL:$PASSWORD" --silent \ https://ydns.eu/api/v1/update/?host=$HOSTNAME @@ -56,7 +56,7 @@ fi if [ "$WAN_IP6" = "$OLD_WAN_IP6" ]; then echo "IP6 Unchanged" else - echo $WAN_IP6 >$HOME/.wan_ip6-ydns.txt + echo $WAN_IP6 > $HOME/.wan_ip6-ydns.txt echo "Updating DNS to $WAN_IP6" curl -6 --basic -u "$USEREMAIL:$PASSWORD" --silent \ https://ydns.eu/api/v1/update/?host=$HOSTNAME diff --git a/bash/deprecated/ydns6 b/bash/deprecated/ydns6 index 32876b8..7754e0d 100755 --- a/bash/deprecated/ydns6 +++ b/bash/deprecated/ydns6 @@ -22,7 +22,7 @@ PASSWORD="" HOSTNAME="" # Get IPv6 address -if hash dig 2>/dev/null; then +if hash dig 2> /dev/null; then WAN_IP6=$(dig +short myip.opendns.com. AAAA @2620:0:ccd::2) else WAN_IP6=$(curl -sL6 https://icanhazip.com/) @@ -38,7 +38,7 @@ fi if [ "$WAN_IP6" = "$OLD_WAN_IP6" ]; then echo "IP6 Unchanged" else - echo $WAN_IP6 >$HOME/.ydns6.txt + echo $WAN_IP6 > $HOME/.ydns6.txt echo "Updating DNS to $WAN_IP6" curl -6 --basic -u "$USEREMAIL:$PASSWORD" --silent \ https://ydns.io/api/v1/update/?host=$HOSTNAME\&ip=$WAN_IP6 diff --git a/bash/iwd-wifi.bash b/bash/iwd-wifi.bash index bc5e48d..67c65c0 100755 --- a/bash/iwd-wifi.bash +++ b/bash/iwd-wifi.bash @@ -24,7 +24,7 @@ echo "To connect: # Device Provisioning Protocol https://iwd.wiki.kernel.org/device_provisioning # requires qrencode, so let's check it exists -if hash qrencode needrestart 2>/dev/null; then +if hash qrencode needrestart 2> /dev/null; then # Remind of command to share echo "To share credentials: % iwctl dpp $WIFIDEVICE start-configurator diff --git a/bash/metropolia/calculator.bash b/bash/metropolia/calculator.bash index c7d7787..20a5f57 100755 --- a/bash/metropolia/calculator.bash +++ b/bash/metropolia/calculator.bash @@ -15,32 +15,32 @@ operand2=$3 # The main case/switch which was required in the exercise case $operator in -'+') - result=$((operand1 + operand2)) - operatorWord="plus" - ;; -'-') - result=$((operand1 - operand2)) - operatorWord="minus" - ;; -'*') - result=$((operand1 * operand2)) - operatorWord="multiplied by" - ;; -'/') - if [ "$operand2" -eq 0 ]; then - echo "The laws of mathematics don't allow division by zero." + '+') + result=$((operand1 + operand2)) + operatorWord="plus" + ;; + '-') + result=$((operand1 - operand2)) + operatorWord="minus" + ;; + '*') + result=$((operand1 * operand2)) + operatorWord="multiplied by" + ;; + '/') + if [ "$operand2" -eq 0 ]; then + echo "The laws of mathematics don't allow division by zero." + exit 1 + else + result=$((operand1 / operand2)) + operatorWord="divided by" + fi + ;; + # Let's not forget default case either + *) + echo "Please use operator +, -. * or /" exit 1 - else - result=$((operand1 / operand2)) - operatorWord="divided by" - fi - ;; -# Let's not forget default case either -*) - echo "Please use operator +, -. * or /" - exit 1 - ;; + ;; esac # and finally the output in format wanted by the task diff --git a/bash/metropolia/employees.bash b/bash/metropolia/employees.bash index 216f86e..a70d36d 100755 --- a/bash/metropolia/employees.bash +++ b/bash/metropolia/employees.bash @@ -2,7 +2,7 @@ # Ensure that the file is empty. -n is specified to avoid \n which would # become obvious in the cat in the end. -echo -n '' >employees.csv +echo -n '' > employees.csv # Begin at 0 so the incrementing later makes the first employee id 1. employees=0 @@ -24,7 +24,7 @@ while true; do # store employee_id and name to employees.csv # I think tsv would be easier and better, but this is what the task requested. - echo "$employee_id;$name" >>employees.csv + echo "$employee_id;$name" >> employees.csv # increment employees so the next id will be 2 employees=$((employees + 1)) diff --git a/bash/steamos-venv-pre-commit.bash b/bash/steamos-venv-pre-commit.bash index 5821b6b..efaa002 100755 --- a/bash/steamos-venv-pre-commit.bash +++ b/bash/steamos-venv-pre-commit.bash @@ -14,10 +14,10 @@ mkdir -p ~/.local/bin/ # come with and it was the original motivation for this script, so it's # difficult to start changing anything here. If you don't want it, just # install pypy or symlink it in path yourself! -if ! hash pypy 2>/dev/null; then +if ! hash pypy 2> /dev/null; then ln -sf /usr/bin/python ~/.local/bin/pypy fi -if ! hash pypy3 2>/dev/null; then +if ! hash pypy3 2> /dev/null; then ln -sf /usr/bin/python3 ~/.local/bin/pypy3 fi