Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61102379
install_bins.sh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, May 4, 13:34
Size
1 KB
Mime Type
text/x-shellscript
Expires
Mon, May 6, 13:34 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17465435
Attached To
R1066 amc-cape
install_bins.sh
View Options
#!/bin/bash
# Set SNAME, SDIR and SPATH
if
[
-h
$0
]
;
then
SNAME
=
$(
readlink
$0
)
;
else
SNAME
=
$0
;
fi
SDIR
=
$(
dirname
$SNAME
)
if
[[
"$SDIR"
=
~ ^/
]]
;
then
SPATH
=
$SDIR
;
else
SPATH
=
$(
realpath
$(
pwd
)
/
$SDIR
)
;
fi
# Set DIR_LIB
DIR_LIB
=
$(
realpath
$SPATH
/../lib/bash
)
# Source libs
source
$DIR_LIB
/colors.sh
source
$DIR_LIB
/io.sh
# Set DESTINATION
if
[
-n
"$1"
]
;
then
DESTINATION
=
"$(realpath $1)"
else
DESTINATION
=
$(
realpath
${
HOME
}
/bin
)
fi
if
[
! -d
$DESTINATION
/
]
;
then
error_echo
"'$DESTINATION' is not a valid directory."
exit
1
fi
info_echo
"Using '$DESTINATION' as binary directory."
function
link_to_binaries
()
{
for
bin in
$(
echo
$BINS
)
;
do
if
[
-r
$DESTINATION
/
$bin
]
;
then
if
[
-h
$DESTINATION
/
$bin
]
;
then
OLD
=
$(
realpath
$DESTINATION
/
$bin
)
if
[
"$OLD"
==
"$DIR_BIN/$bin"
]
;
then
color_echo_n
"Command '$bin' already exists... "
else
color_echo_n
"Moving command '$bin' from '$OLD' to '$DIR_BIN/$bin'... "
rm
$DESTINATION
/
$bin
ln -s
$DIR_BIN
/
$bin
$DESTINATION
/
$bin
fi
else
error_echo
"A similar command already exists: '$OLD'"
exit
2
fi
else
color_echo_n
"Installing command '$bin' to '$DESTINATION/'... "
ln -s
$DIR_BIN
/
$bin
$DESTINATION
/
$bin
fi
[
-h
$DESTINATION
/
$bin
]
check_rc_echo
$?
done
}
DIR_BIN
=
$(
realpath
$SPATH
/../bin
)
BINS
=
'bamc'
link_to_binaries
DIR_BIN
=
$(
realpath
$SPATH
/../local/epfl
)
BINS
=
'search-epfl'
link_to_binaries
# Done
warning_echo
"Make sure '$DESTINATION' is in your \$PATH variable."
;
# RIP
exit
0
Event Timeline
Log In to Comment