forked from alnux/aps
Merge pull request 'Add locking' (#1) from hiimgoodpack/aps:master into master
Reviewed-on: alnux/aps#1
This commit is contained in:
commit
ee0e1f5f86
1 changed files with 12 additions and 1 deletions
11
aps.sh
11
aps.sh
|
@ -4,6 +4,7 @@ AL_TEMP_LOCATION="/tmp"
|
||||||
AL_INSTALL_ROOT="/tmp/alroot"
|
AL_INSTALL_ROOT="/tmp/alroot"
|
||||||
AL_INSTALLED_PKG_DATABASE="${AL_INSTALL_ROOT}/var/aps/installed"
|
AL_INSTALLED_PKG_DATABASE="${AL_INSTALL_ROOT}/var/aps/installed"
|
||||||
AL_LOCAL_PKG_DATABASE="${AL_INSTALL_ROOT}/var/aps/repos"
|
AL_LOCAL_PKG_DATABASE="${AL_INSTALL_ROOT}/var/aps/repos"
|
||||||
|
AL_LOCK="${AL_INSTALL_ROOT}/var/aps/lock"
|
||||||
|
|
||||||
# Repo config
|
# Repo config
|
||||||
official="https://git.hippoz.xyz/alnux/repo"
|
official="https://git.hippoz.xyz/alnux/repo"
|
||||||
|
@ -192,6 +193,13 @@ upgrade() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
if [ -f "${AL_LOCK}" ]; then
|
||||||
|
echo "[E] A lock file already exists."
|
||||||
|
echo " If you're sure no package manager is running,"
|
||||||
|
echo " remove the file ${AL_LOCK}"
|
||||||
|
fi
|
||||||
|
touch "${AL_LOCK}"
|
||||||
|
|
||||||
case ${1} in
|
case ${1} in
|
||||||
install)
|
install)
|
||||||
install_local_package "${2}"
|
install_local_package "${2}"
|
||||||
|
@ -212,9 +220,12 @@ main() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "[E] Invalid option ${1}, exiting..."
|
echo "[E] Invalid option ${1}, exiting..."
|
||||||
|
rm "${AL_LOCK}"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
rm "${AL_LOCK}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "${1}" "${2}"
|
main "${1}" "${2}"
|
Loading…
Reference in a new issue