-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-bin
More file actions
executable file
·72 lines (66 loc) · 1.62 KB
/
Copy pathcreate-bin
File metadata and controls
executable file
·72 lines (66 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /bin/bash
if [ "$1" = "-y" -o "$1" = "--yes" ]; then
OK_TO_UPDATE=true
else
OK_TO_UPDATE=false
fi
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd $DIR
if [ `pwd` != $DIR ]
then
echo "Could not change to the directory $DIR"
else
SCRIPTS_TO_UPDATE=0
for script in `ls src`; do
if [ ! -x $HOME/bin/$script ];then
if [ ${SCRIPTS_TO_UPDATE} -eq 0 ];then
echo -e "\n+------------------------------------------------------"
echo -e "| The following scripts will be added to $HOME/bin "
SCRIPTS_TO_UPDATE=`expr ${SCRIPTS_TO_UPDATE} + 1`
fi
echo "| $script"
fi
done
if [ ${SCRIPTS_TO_UPDATE} -eq 0 ];then
echo -e "\n*** No scripts to update ***\n"
for script in `ls src`; do
if [ -x $HOME/bin/$script ]
then
echo "Script src/$script already in $HOME/bin"
fi
done
OK_TO_UPDATE=false
else
if [ $OK_TO_UPDATE != true ]; then
echo -e "|\n| Update ${SCRIPTS_TO_UPDATE} scripts (y/N) \c"
read ok
if [ "$ok" == 'y' -o "$ok" == "Y" ]
then
OK_TO_UPDATE=true
fi
fi
fi
fi
# N.B. only do this with trusted variables (i.e. set directly your script)
if $OK_TO_UPDATE ; then
if [ ! -d $HOME/bin ]
then
mkdir $HOME/bin/
echo "Created $HOME/bin - add this directory to your PATH enviroment variable in .bashrc"
fi
for script in `ls src`; do
if [ ! -x $HOME/bin/$script ]
then
if [ -x src/$script ]
then
ln -s `pwd`/src/$script $HOME/bin/
# chmod u+x $HOME/bin/$script
echo "Added '$script' to $HOME/bin/"
else
echo "Ignoring src/$script since it is not executable"
fi
else
echo "Script src/$script already in $HOME/bin"
fi
done
fi