sonic-buildimage/src/sonic-build-hooks/scripts/symlink_build_hooks
xumia 1dcab4d1e3
Fix py3 version changed even version control enabled issue (#6422)
* Fix py3 version changed even version control enabled issue

* Add some comments and simplify the script

* Add the comment to explain how to get the not hooked command
2021-01-13 18:40:39 +08:00

35 lines
576 B
Bash
Executable File

#!/bin/bash
HOOK_PATH=/usr/local/share/buildinfo/hooks
TARGET_PATH=/usr/local/sbin
FILES=$(ls $HOOK_PATH)
usage()
{
echo "Usage: $0 [-d]"
exit 1
}
DISABLE=n
while getopts "d" opt; do
case $opt in
d)
DISABLE=y
;;
*)
usage
;;
esac
done
for f in $FILES
do
if [ $DISABLE == "n" ]; then
[ ! -e $TARGET_PATH/$f ] && ln -s $HOOK_PATH/$f $TARGET_PATH/$f
else
([ -e $TARGET_PATH/$f ] && ls -l $TARGET_PATH/$f | grep -q $HOOK_PATH) && rm -f $TARGET_PATH/$f
fi
done
exit 0