27 lines
972 B
Bash
Executable File
27 lines
972 B
Bash
Executable File
#!/bin/bash
|
|
builder=$(dirname "$(realpath "$BASH_SOURCE")")
|
|
target=$1
|
|
[[ $# -eq 2 ]] && target=$1/$2
|
|
target=${target:-/opt/bin/dbuild}
|
|
cmd=$(basename $target)
|
|
parent=$(dirname $target)
|
|
echo NOTE: the uci build script can be called directly at $builder
|
|
# echo "$PATH --- $parent"
|
|
declare -a a="(${PATH//:/ })"
|
|
for i in ${a[*]}; do [[ $i == $parent ]] && found=true; done
|
|
if [[ $found ]]; then
|
|
echo creating a link \'$cmd\' in \'$parent\' to \'$builder\'
|
|
if ln -ns $builder/build ${1:-/opt/bin/dbuild}; then
|
|
[[ ! $(command -v $cmd) ]] && echo FATAL: link failed $cmd not found in path \
|
|
|| echo install success: try \'$cmd -h\' now
|
|
else
|
|
echo Error creating link
|
|
echo if \': Permission denied\' 'then' run \'sudo ./install\'
|
|
fi
|
|
else
|
|
echo $parent not in current path
|
|
echo $PATH
|
|
echo link to script not created
|
|
echo Alternatively export an environment variable with $builder
|
|
echo and use that to invoke the script
|
|
fi |