Closed HeCodes2Much closed 2 years ago
you also dont need the greps at all for the one that had awk already as you can just apend awk a few times :)
snaphome should also be a bit more better not using so many greps and only using awk where awk is already used ill leave root for you to do if home works for you
I am working on a pacman hook to do snapshots before updates and also a systemd timer for auto snapshots
i have also made a dmenu script as shown below right now the list just shows in the terminal but i may make it also show the snapshots in the dmenu itself later :)
oh btw these commands should have sudo in them as thats not safe to do in a script itself you are better off having error handeling for the command that needs sudo and have it error out and ask for sudo then you would so sudo snaplist
if it needed sudo to run the commands
as an example
cmd=$(basename $0)
runas=$(whoami)
if [ $runas != 'root' ]; then
printf ${GREEN}"%s ${RED}command must be ran as root\n" "$cmd"
exit
fi
if you wanna check it out repomenu-snapshots this is my script for dmenu and the scripts as well as the systemd and pacman hook
screenshot of what the pacman hook does
adding some more cool features to my build if you want to keep an eye out on it
just a heads up im working on making this not use awk or grub at all and just use bash builtin's so far so good :) got the number counting working with
#number of root snapshots
rsl=0
while IFS= read -r Line; do
[ "${Line/snapshot/}" = "$Line" ] && continue
[ "${Line/@root/}" = "$Line" ] && continue
[ "${Line/pacman/}" = "$Line" ] || continue
(( rsl++ ))
done <<< $(btrfs subvolume list /)
#number of home snapshots
hsl=0
while IFS= read -r Line; do
[ "${Line/snapshot/}" = "$Line" ] && continue
[ "${Line/@home/}" = "$Line" ] && continue
[ "${Line/pacman/}" = "$Line" ] || continue
(( hsl++ ))
done <<< $(btrfs subvolume list /)
#number of pacman snapshots
psl=0
while IFS= read -r Line; do
[ "${Line/snapshot/}" = "$Line" ] && continue
[ "${Line/pacman/}" = "$Line" ] && continue
(( psl++ ))
done <<< $(btrfs subvolume list /)
if you want these after im done ill re make a new PR with these changes :) but for now this PR will stay as it is :) as i deleted the fork for this repo
@The-Repo-Club . Thank you for helping me out with this. you made these scripts better and even a little faster. I have tested out your changes in my virtual machines, only had to cut out the @'s in the awk commands as they didn't work for me, also I decided to leave the "greps" in for the root subvolume variable as I believe it would be more portable between my desktop and laptop which have different root subvolume names. I will be updating these scripts with your changes very soon. Thank you so much for your help...
P.S. I checked out your project and it looks awesome.
@The-Repo-Club. Sorry it took me so long to respond, My wife and I actually just got home from the hospital with our newest addition... It's a boy!
That's very good news my dude and it took me the weekend to fix the script to get rid of the awks and use builtins instead
@linuxdabbler btw the new way that i did the listing is dynamic so it will show all snapshots of any kind not only @ or @home just a heads up if you wanna test it
I will definitely look into it. I appreciate all your help.
get rid of so many greps and use awk as grep isnt needed