Imported a locking script
This commit is contained in:
parent
43a2016d54
commit
17d084cb08
1
Makefile
1
Makefile
|
@ -24,6 +24,7 @@ dist:
|
|||
$(PACKAGE)-$(VERSION)/src/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/src/deforaos-build.sh \
|
||||
$(PACKAGE)-$(VERSION)/src/deforaos-document.sh \
|
||||
$(PACKAGE)-$(VERSION)/src/deforaos-lock.sh \
|
||||
$(PACKAGE)-$(VERSION)/src/deforaos-package.sh \
|
||||
$(PACKAGE)-$(VERSION)/src/deforaos-release.sh \
|
||||
$(PACKAGE)-$(VERSION)/src/deforaos-update.sh \
|
||||
|
|
|
@ -17,6 +17,8 @@ install:
|
|||
$(MKDIR) $(DESTDIR)$(PREFIX)/bin
|
||||
$(INSTALL) -m 0755 deforaos-document.sh $(DESTDIR)$(PREFIX)/bin/deforaos-document.sh
|
||||
$(MKDIR) $(DESTDIR)$(PREFIX)/bin
|
||||
$(INSTALL) -m 0755 deforaos-lock.sh $(DESTDIR)$(PREFIX)/bin/deforaos-lock.sh
|
||||
$(MKDIR) $(DESTDIR)$(PREFIX)/bin
|
||||
$(INSTALL) -m 0755 deforaos-package.sh $(DESTDIR)$(PREFIX)/bin/deforaos-package.sh
|
||||
$(MKDIR) $(DESTDIR)$(PREFIX)/bin
|
||||
$(INSTALL) -m 0755 deforaos-release.sh $(DESTDIR)$(PREFIX)/bin/deforaos-release.sh
|
||||
|
@ -26,6 +28,7 @@ install:
|
|||
uninstall:
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-build.sh
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-document.sh
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-lock.sh
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-package.sh
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-release.sh
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/bin/deforaos-update.sh
|
||||
|
|
65
src/deforaos-lock.sh
Executable file
65
src/deforaos-lock.sh
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2014 Pierre Pronchery <khorben@defora.org>
|
||||
#This file is part of DeforaOS Devel scripts
|
||||
#This program is free software: you can redistribute it and/or modify
|
||||
#it under the terms of the GNU General Public License as published by
|
||||
#the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
#This program is distributed in the hope that it will be useful,
|
||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
#GNU General Public License for more details.
|
||||
#
|
||||
#You should have received a copy of the GNU General Public License
|
||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
#variables
|
||||
#executables
|
||||
LOCK="mkdir"
|
||||
UNLOCK="rmdir"
|
||||
|
||||
|
||||
#functions
|
||||
#lock
|
||||
_lock()
|
||||
{
|
||||
lockfile="/var/tmp/deforaos-lock.$1"
|
||||
|
||||
$LOCK -- "$lockfile" || return 2
|
||||
"$@"
|
||||
ret=$?
|
||||
$UNLOCK -- "$lockfile"
|
||||
return $ret
|
||||
}
|
||||
|
||||
|
||||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: deforaos-lock.sh -- command [arguments...]" 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#main
|
||||
#parse the arguments
|
||||
while getopts "" name; do
|
||||
case $name in
|
||||
*)
|
||||
_usage
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#check the usage
|
||||
shift $(($OPTIND - 1))
|
||||
if [ $# -eq 0 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
||||
_lock "$@"
|
|
@ -1,4 +1,4 @@
|
|||
dist=Makefile,deforaos-build.sh,deforaos-document.sh,deforaos-package.sh,deforaos-release.sh,deforaos-update.sh
|
||||
dist=Makefile,deforaos-build.sh,deforaos-document.sh,deforaos-lock.sh,deforaos-package.sh,deforaos-release.sh,deforaos-update.sh
|
||||
|
||||
[deforaos-build.sh]
|
||||
install=$(PREFIX)/bin
|
||||
|
@ -8,6 +8,10 @@ mode=0755
|
|||
install=$(PREFIX)/bin
|
||||
mode=0755
|
||||
|
||||
[deforaos-lock.sh]
|
||||
install=$(PREFIX)/bin
|
||||
mode=0755
|
||||
|
||||
[deforaos-package.sh]
|
||||
install=$(PREFIX)/bin
|
||||
mode=0755
|
||||
|
|
Loading…
Reference in New Issue
Block a user