summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbertalanp99 <bertalanp99+git@bertalanp99.eu>2020-04-05 19:56:11 +0200
committerbertalanp99 <bertalanp99+git@bertalanp99.eu>2020-04-05 19:56:11 +0200
commit3e98c7a31e889cd9bf5bd53b98470f460b717659 (patch)
treead6df9fc8ec55a41339372213884527b5f05f4c8
parent016794a45bd128dd8b1a433343a4deb5233ae5e9 (diff)
downloadscripts-3e98c7a31e889cd9bf5bd53b98470f460b717659.tar.gz
scripts-3e98c7a31e889cd9bf5bd53b98470f460b717659.zip
bad commit
-rw-r--r--backup/backup65
-rwxr-xr-xledgertidy/ledgertidy18
-rwxr-xr-xpassmenu/passmenu55
-rwxr-xr-xrcsedit/rcsedit77
-rwxr-xr-xrundwm/rundwm7
5 files changed, 203 insertions, 19 deletions
diff --git a/backup/backup b/backup/backup
new file mode 100644
index 0000000..28df95e
--- /dev/null
+++ b/backup/backup
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+###
+# backup - my backup script using duplicity
+#
+# req:
+# - duplicity
+#
+# The list of backup locations is specified in a file with the following format:
+# /path/to/first/dir
+# /path/to/2nd/dir
+# ...
+# This file is supplied by the BACKUP_PATHS environment variable.
+# If unset, this script shall try ~/.backup_paths
+#
+# Another environment variable used is PASSPHRASE that must be set to the
+# desired GnuPG passphrase. Obviously, take care not to expose this value.
+#
+# Since the script is made for BackBlaze B2, 3 more thigns must be supplied:
+# - an app key ID (APPKEYID)
+# - an app key (APPKEY)
+# - a bucket name (BUCKET)
+# Again, make sure to keep at least APPKEY confidential.
+#
+# The script has a verbose mode that can be enabled by passing the switch `-v`.
+#
+# bertalanp99@ 2019-07-09
+###
+
+errcho()
+{
+ >&2 echo "error: $@"
+ exit 1
+}
+
+################################################################################
+
+BACKUP_PATHS="${BACKUP_PATHS:-"${HOME}/.backup_paths"}"
+[ -f "$BACKUP_PATHS" ] || errcho "cannot open BACKUP_PATHS at '$BACKUP_PATHS'"
+
+[ -n "$PASSPHRASE" ] || errcho PASSPHRASE must be set
+
+for b2var in APPKEYID APPKEY BUCKET
+do
+ [ -n "$b2var" ] || errcho $b2var must be set
+done
+
+################################################################################
+
+verbose=
+while [ "$#" -ne 0 ]
+do
+ case "$1" in
+ -v) verbose=1 ;;
+ *) errcho "unknown option '$1'" ;;
+ esac
+ shift
+done
+
+while read loc
+do
+ [ -z "$loc" ] && continue
+ [ -n $verbose ] && echo "now backing up '$loc'"
+ duplicity "$loc" "b2://${APPKEYID}:${APPKEY}@${BUCKET}/${loc}"
+done <"$BACKUP_PATHS"
diff --git a/ledgertidy/ledgertidy b/ledgertidy/ledgertidy
new file mode 100755
index 0000000..723dde1
--- /dev/null
+++ b/ledgertidy/ledgertidy
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+while [ $# -ne 1 ]
+do
+ case "$1" in
+ -i) inplace=1 ;;
+ *) (>&2 echo "unknown option -- $1"; exit 1) ;;
+ esac
+ shift
+done
+
+# Fix YYYY/MM/DD dates ---> YYYY-MM-DD
+if [ "$inplace" -eq 1 ]
+then
+ sed -i '/[0-9]\{4\}\/[0-9]\{2\}\/[0-9]\{2\}/ s|/|-|g' "$1"
+else
+ sed '/[0-9]\{4\}\/[0-9]\{2\}\/[0-9]\{2\}/ s|/|-|g' "$1"
+fi
diff --git a/passmenu/passmenu b/passmenu/passmenu
index 987fbb9..eee435d 100755
--- a/passmenu/passmenu
+++ b/passmenu/passmenu
@@ -1,5 +1,7 @@
#!/bin/sh
+# !!!! UPDATE WITH ROFI GOODNESS
+
###
# passmenu - dmenu interface for password-store
#
@@ -74,17 +76,21 @@ do
shift
;;
- -h|--help)
+ -c)
+ cli=1
+ ;;
+
+ -h)
usage
exit 0
;;
- -u|--username)
+ -u)
needuser=1
;;
*)
- echo unknown option \'"$1"\'
+ echo "unknown option -- $1"
usage
exit 1
;;
@@ -94,19 +100,42 @@ done
### MAIN ###
+
+if [ -n "$cli" ]
+then
+ password="$(\
+ find "$prefix" -name '*.gpg' \
+ | sed "s|${prefix}\(.*\).gpg|\1|" \
+ | fzf)"
+ if [ $needuser -eq 0 ]
+ then
+ pass show "$password" 2>/dev/null \
+ | sed 1q \
+ | tr -d '\n' \
+ | xsel --input
+ else
+ pass show "$password" 2>/dev/null \
+ | awk '/login:/{print $2}' \
+ | tr -d '\n' \
+ | xsel --input
+ fi
+ return
+fi
+
password="$(\
- find "$prefix" -name '*.gpg' |\
- sed "s|${prefix}\(.*\).gpg|\1|" |\
- dmenu $dmenuoptions)"
+ find "$prefix" -name '*.gpg' \
+ | sed "s|${prefix}\(.*\).gpg|\1|" \
+ | rofi -dmenu $dmenuoptions)"
if [ $needuser -eq 0 ]
then
- pass show --clip "$password" >/dev/null 2>&1
+ pass show "$password" 2>/dev/null \
+ | sed 1q \
+ | tr -d '\n' \
+ | xsel --input
else
- pass show "$password" 2>/dev/null |\
- head -2 |\
- tail -1 |\
- sed 's/login: //' |\
- tr -d '\n' |\
- xsel --input --clipboard
+ pass show "$password" 2>/dev/null \
+ | awk '/login:/{print $2}' \
+ | tr -d '\n' \
+ | xsel --input
fi
diff --git a/rcsedit/rcsedit b/rcsedit/rcsedit
new file mode 100755
index 0000000..b8f18ee
--- /dev/null
+++ b/rcsedit/rcsedit
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+###
+# rcsedit - Edit system config files using RCS
+#
+# req:
+# - rcs
+#
+# usage:
+# rcsedit FILE
+###
+
+usage()
+{
+ echo 'usage: rcsedit FILE'
+}
+
+errcho()
+{
+ 2>&1 echo error: $@
+ exit 1
+}
+
+yesno()
+{
+ msg="$1"
+ printf '%s ' "$msg [y/n]"
+ read choice
+ case "$choice" in
+ [yY]*) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
+################################################################################
+
+command -v rcs >/dev/null 2>/dev/null || errcho RCS is required
+[ $# -ne 0 ] || (usage; exit 1)
+
+
+file="$1"
+
+if ! [ -f "$file" ]
+then
+ yesno "$file -- file does not exist; create?" && touch "$file" || exit 0
+fi
+
+rcsdir="$(dirname "$file")/RCS"
+[ -d "$rcsdir" ] || mkdir "$rcsdir"
+
+if ! co -q -l "$file" >/dev/null 2>/dev/null
+then
+ if yesno "$file -- file is not in RCS; check in?"
+ then
+ ci -q -u "$file" && co -q -l "$file"
+ else
+ exit 0
+ fi
+fi
+
+while true
+do
+ $EDITOR "$file"
+
+ if rcsdiff -q -u "$file"
+ then
+ echo
+ echo You have made no modifications
+ else
+ echo
+ echo You have made the above modifications
+ fi
+
+ yesno 'Edit again?' && continue || break
+done
+
+ci -q -u "$file"
diff --git a/rundwm/rundwm b/rundwm/rundwm
index ce14fe7..a535c1d 100755
--- a/rundwm/rundwm
+++ b/rundwm/rundwm
@@ -3,18 +3,13 @@
###
# rundmw - run dwm and restart when killed
#
-# box: watermelon
-# os: openbsd
-#
# This script allows running dwm in a loop, so when it exits, the X session is
# preserved and dwm is started again.
#
# In order to properly terminate the X session, this script must be killed.
-#
-# bertalanp99@ 2019-05-18
###
while true
do
- dwm 2>$HOME/.log/dwm-errors.log
+ dwm 2>$HOME/dwm.errout
done