mirror of
				https://gitea.blesmrt.net/mikaela/scripts.git
				synced 2025-11-03 19:07:21 +01:00 
			
		
		
		
	pre-commit run --all-files
This commit is contained in:
		
							parent
							
								
									cbbe880f05
								
							
						
					
					
						commit
						803adb405f
					
				@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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))
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user