Only allow a instance of simpleaur running at the same time

This commit is contained in:
Eduard Tolosa 2018-07-18 09:15:37 -05:00
parent cf506aaf55
commit 16eb18ee3f

View file

@ -2,7 +2,16 @@
# install AUR packages # install AUR packages
basebuilddir="$HOME/.simpleaur/Build" basebuilddir="$HOME/.simpleaur/Build"
pacmanexist=$(which pacman 2> /dev/null) pacmanexist=$(which pacman 2> /dev/null)
lockfile="$basebuilddir/simpleaur.lock"
#Prevent two instances running at same time
if [ -f "$lockfile" ]; then
printf "\n\e[1;31m%-6s\e[m%s\n" "simpleaur is running, leaving."
printf "\n\e[1;31m%-6s\e[m%s\n" "If you are sure that simpleaur is not running, delete [ '$lockfile' ]"
exit
else
touch "$lockfile"
fi
#Make sure that you are using an ArchLinux system #Make sure that you are using an ArchLinux system
if [ -x "$pacmanexist" ]; then if [ -x "$pacmanexist" ]; then
continue continue
@ -39,7 +48,6 @@ for ipackage in "$@"; do
else else
git clone "https://aur.archlinux.org/${ipackage}.git" git clone "https://aur.archlinux.org/${ipackage}.git"
fi fi
done done
@ -78,3 +86,5 @@ for ipackage in "$@"; do
rm -rf "$basebuilddir/$ipackage" rm -rf "$basebuilddir/$ipackage"
fi fi
done done
rm "$lockfile"
exit