From 9157278eb08512074b079568164de115c12fe1a1 Mon Sep 17 00:00:00 2001 From: David Kebler Date: Thu, 14 Dec 2023 13:59:24 -0800 Subject: [PATCH] ignore .inst and .uninst files add systemd loginctl commands btrfs find subvolumes --- .bash-shell-ignore | 2 ++ load/alias/00-basic | 2 ++ load/alias/systemd/user | 1 + modules/btrfs.mod | 25 ++++++++++++++++++++++++- modules/scripting/helpers.lib | 3 +++ modules/scripting/{path.sh => path.lib} | 0 modules/systemd.lib | 12 ++++++++++++ modules/utility/file.lib | 3 +-- 8 files changed, 45 insertions(+), 3 deletions(-) rename modules/scripting/{path.sh => path.lib} (100%) diff --git a/.bash-shell-ignore b/.bash-shell-ignore index 1d2d804..9650379 100644 --- a/.bash-shell-ignore +++ b/.bash-shell-ignore @@ -5,6 +5,8 @@ *.example *.tmpl *.template +*.inst +*.uinst *.md *TODO* *.log diff --git a/load/alias/00-basic b/load/alias/00-basic index c9da28c..b0e39f5 100644 --- a/load/alias/00-basic +++ b/load/alias/00-basic @@ -62,3 +62,5 @@ alias follow="readlink -f" # use this when there are transport errors after unmounting or killing a mount alias umountf="sudo umount -l" + +alias loginust="loginctl show-user $USER" diff --git a/load/alias/systemd/user b/load/alias/systemd/user index b4f8f72..f79fd7c 100644 --- a/load/alias/systemd/user +++ b/load/alias/systemd/user @@ -10,3 +10,4 @@ alias sdlau="systemctl --user list-units | grep" alias sdlu="systemctl --user list-unit-files | grep" alias sdleu="systemctl --user list-unit-files | grep enabled" alias sdpidu="systemctl show --user --property MainPID --value" + \ No newline at end of file diff --git a/modules/btrfs.mod b/modules/btrfs.mod index d5348e6..e569f86 100644 --- a/modules/btrfs.mod +++ b/modules/btrfs.mod @@ -68,4 +68,27 @@ echo $subvolumeFolderSize KB echo "~ $((subvolumeFolderSize/1024)) MB" echo "~ $((subvolumeFolderSize/1024/1024)) GB" -} \ No newline at end of file +} + +find_subvolumes () { +sudo /bin/find $1 -maxdepth $2 -type d -exec sh -c ' + for d do + sudo btrfs subvolume show "$d" >/dev/null 2>&1 && printf "%s\n" "$d" + done' find-sh {} + +} + +# sudo find / -type d -exec sh -c ' +# for d do +# btrfs subvolume show "$d" >/dev/null 2>&1 && printf "%s\n" "$d" +# done' find-sh {} + +# You may want to exclude paths that are beyond suspicion. The following code excludes /proc, /sys and /dev: + +# sudo find / -type d \( \ +# \( -path /proc -prune \) -o \ +# \( -path /sys -prune \) -o \ +# \( -path /dev -prune \) -o \ +# \( -exec sh -c ' +# for d do +# btrfs subvolume show "$d" >/dev/null 2>&1 && printf "%s\n" "$d" +# done +# ' find-sh {} + \) \) \ No newline at end of file diff --git a/modules/scripting/helpers.lib b/modules/scripting/helpers.lib index eb71b15..a45a213 100644 --- a/modules/scripting/helpers.lib +++ b/modules/scripting/helpers.lib @@ -93,3 +93,6 @@ sed_ignore_comments () { fi } +#rows between matched rows +# sed '1,/firstmatch/d;/secondmatch/,$d' + diff --git a/modules/scripting/path.sh b/modules/scripting/path.lib similarity index 100% rename from modules/scripting/path.sh rename to modules/scripting/path.lib diff --git a/modules/systemd.lib b/modules/systemd.lib index 6e0703a..7357a06 100644 --- a/modules/systemd.lib +++ b/modules/systemd.lib @@ -38,3 +38,15 @@ systemctl --user show --no-page $1 | grep ExecMainPID systemctl --user show --no-page $1 | grep ExecMainStartTimestamp= systemctl --user show --no-page $1 | grep ExecMainExitTimestamp= } + +function sdeub { +loginctl enable-linger +} + +function sddub { +loginctl disable-linger +} + +function sdstub { +[[ $(loginctl show-user "$USER" --property=Linger | cut -d= -f2) == 'yes' ]] && echo enabled || echo disabled +} \ No newline at end of file diff --git a/modules/utility/file.lib b/modules/utility/file.lib index 830b423..3b64eba 100644 --- a/modules/utility/file.lib +++ b/modules/utility/file.lib @@ -61,11 +61,10 @@ function _find () { # all lines ending in / will be treated as directory names to ignore, otherwise files # p option explictly excludes paths(directories) # d option sets the directory depth which is current directy by default, 0 is all -# x excitly excludes file globs as a string # n inclucdes only file globs otherwise it's all except .files # if no directory is given it will attempt to source the present working directory # example: -# source_dir -p "archive" -x '"*.off" "*.md"' -d 0 # $DIR/$SUBDIR +# source_dir -p "archive" -e '"*.off" "*.md"' -d 0 # $DIR/$SUBDIR local EXCLUDE_FILE local PATHS local NAMES