scripts and gitignore

This commit is contained in:
Belal Elsabbagh
2025-03-05 10:16:02 +02:00
parent 31bad7d3a4
commit 71032c5dd6
4 changed files with 50 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.log

12
scripts/refresh-minecraft.sh Executable file
View File

@@ -0,0 +1,12 @@
#back up
cp -r .minecraft .minecraft-backup
#delete
rm -rf .minecraft
mkdir -p .minecraft
#restore saves
cp -r .minecraft-backup/saves .minecraft/saves
cp -r .minecraft-backup/options.txt .minecraft/options.txt

37
scripts/rollback-pacman.sh Executable file
View File

@@ -0,0 +1,37 @@
# get date YYYY-MM-DD from first arg
date=$1
verbose=$2
# check date not exists or is not valid
if [[ ! $date =~ ^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ ]]; then
echo "Usage: $0 YYYY-MM-DD"
exit 1
fi
if [ -z "$verbose" ]; then
verbose=false
fi
grep -a upgraded /var/log/pacman.log| grep "$date" > /tmp/lastupdates.txt
if [ "$verbose" = true ]; then
echo "Last updates:"
cat /tmp/lastupdates.txt
fi
awk '{print $4}' /tmp/lastupdates.txt > /tmp/lines1;awk '{print $5}' /tmp/lastupdates.txt | sed 's/(/-/g' > /tmp/lines2
if [ "$verbose" = true ]; then
echo "Lines 1:"
cat /tmp/lines1
echo "Lines 2:"
cat /tmp/lines2
fi
paste /tmp/lines1 /tmp/lines2 > /tmp/lines
if [ "$verbose" = true ]; then
echo "Lines:"
cat /tmp/lines
fi
tr -d "[:blank:]" < /tmp/lines > /tmp/packages
if [ "$verbose" = true ]; then
echo "Packages:"
cat /tmp/packages
fi
cd /var/cache/pacman/pkg/
for i in $(cat /tmp/packages); do sudo pacman --noconfirm -U "$i"*; done