Commit cfb52c6591d4a26677ce68b4b0ea8b45c81df4cf

Thomas de Grivel 2023-01-24T14:55:38

bin

diff --git a/bin/backup b/bin/backup
new file mode 100644
index 0000000..04ade16
--- /dev/null
+++ b/bin/backup
@@ -0,0 +1,65 @@
+#!/bin/sh
+set -e
+
+umount_by_path() {
+	for P; do
+		mount \
+		| grep " on $P" \
+		| sort -r \
+		| cut -d ' ' -f 1 \
+		| xargs -n 1 umount
+	done
+}
+
+if [ "x$1" = "xumount" ]; then
+	umount_by_path /mnt/ '/mnt '
+	exit
+fi
+
+mount | ! grep ' on /mnt '
+
+if [ "x$1" = "xdisklabel" ]; then
+	shift
+	for DEV; do
+		printf 'a a\n\n2g\n\na b\n\n2g\n\na d\n\n10g\n\na e\n\n10g\n\na f\n\n10g\n\na g\n\n2g\n\na h\n\n20g\n\na j\n\n10g\n\na k\n\n10g\n\na l\n\n10g\n\na m\n\n20g\n\na n\n\n10g\n\na o\n\n10g\n\na p\n\n\n\nw\nq\n' | disklabel -dE $DEV
+	done
+	exit
+elif [ "x$1" = "xnewfs" ]; then
+	shift
+	for DEV; do
+		for P in a d e f g h j k l m n o p; do
+			newfs $DEV$P
+		done
+	done
+	exit
+fi
+
+for DEV; do
+	mount /dev/${DEV}a /mnt/
+	rsync -aHx --delete-before /. /mnt/
+	mount /dev/${DEV}d /mnt/tmp
+	rsync -aHx --delete-before /tmp/. /mnt/tmp/
+	mount /dev/${DEV}e /mnt/var
+	rsync -aHx --delete-before --exclude postgresql /var/. /mnt/var/
+	mount /dev/${DEV}f /mnt/usr
+	rsync -aHx --delete-before /usr/. /mnt/usr/
+	mount /dev/${DEV}g /mnt/usr/X11R6
+	rsync -aHx --delete-before /usr/X11R6/. /mnt/usr/X11R6/
+	mount /dev/${DEV}h /mnt/usr/local
+	rsync -aHx --delete-before /usr/local/. /mnt/usr/local/
+	mount /dev/${DEV}j /mnt/usr/src
+	rsync -aHx --delete-before /usr/src/. /mnt/usr/src/
+	mount /dev/${DEV}k /mnt/usr/obj
+	rsync -aHx --delete-before /usr/obj/. /mnt/usr/obj/
+	mount /dev/${DEV}l /mnt/usr/ports
+	rsync -aHx --delete-before /usr/ports/. /mnt/usr/ports/
+	mount /dev/${DEV}m /mnt/usr/ports/pobj
+	rsync -aHx --delete-before /usr/ports/pobj/. /mnt/usr/ports/pobj/
+	mount /dev/${DEV}n /mnt/usr/xenocara
+	rsync -aHx --delete-before /usr/xenocara/. /mnt/usr/xenocara/
+	mount /dev/${DEV}o /mnt/usr/xobj
+	rsync -aHx --delete-before /usr/xobj/. /mnt/usr/xobj/
+	mount /dev/${DEV}p /mnt/home
+	rsync -aHx --delete-before /home/. /mnt/home/
+	umount_by_path /mnt/
+done
diff --git a/bin/status-r7 b/bin/status-r7
new file mode 100755
index 0000000..0202088
--- /dev/null
+++ b/bin/status-r7
@@ -0,0 +1,2 @@
+#!/bin/sh
+xsetroot -name " dwm $(hostname) $(~/bin/egress_interface) $(~/bin/host-ip) $(~/bin/nwid) $(~/bin/load) $(~/bin/temperature-r7) $(date)"
diff --git a/bin/temperature-r7 b/bin/temperature-r7
new file mode 100755
index 0000000..a805a9a
--- /dev/null
+++ b/bin/temperature-r7
@@ -0,0 +1,4 @@
+#!/bin/sh
+CPUTEMP=$(sysctl -n hw.sensors.cpu0.temp0 | cut -d\  -f 1)
+MBTEMP=$(sysctl -n hw.sensors.acpitz0.temp0 | cut -d\  -f 1)
+echo "${CPUTEMP}°C ${MBTEMP}°C"
diff --git a/bin/usb_key_bsd b/bin/usb_key_bsd
new file mode 100755
index 0000000..54ab8b2
--- /dev/null
+++ b/bin/usb_key_bsd
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+DEV="$1"
+fdisk -iy "$DEV"
+printf "a a\n\n\n\nq\ny\n" | disklabel -E "$DEV"
+echo
+newfs /dev/r"$DEV"a