forked from msioda/BioLockJ
-
Notifications
You must be signed in to change notification settings - Fork 12
/
install
executable file
·91 lines (80 loc) · 3.56 KB
/
install
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
###################################################################################
## ##
## This script updates user profile to ##
## include the key variables $BLJ and $BLJ_PROJ ##
## include the $BLJ/script dir in the $PATH ##
## ##
## By default, the script determines the user's profile. ##
## Optionally, supply the profile to use as an argument. ##
## ex: ./install ~/.bashrc ##
## ##
###################################################################################
BLJ="$( cd "$( dirname ${BASH_SOURCE[0]} )" && pwd )"
# If an arg is given, assume this is the user-profile that user has selected
# otherwise, determine the user_profile
user_profile=$1
if [ ${#user_profile} -eq 0 ]; then
# Look for a default profile in the $USER $HOME dir
get_default_profile() {
if [ ${SHELL} == "/bin/bash" ]; then
user_profile="${HOME}"/.bash_profile
[ ! -f "${user_profile}" ] && user_profile="${HOME}"/.bashrc
[ ! -f "${user_profile}" ] && user_profile="${HOME}"/.profile
[ ! -f "${user_profile}" ] && user_profile="${HOME}"/.bash_login
elif [ ${SHELL} == "/bin/zsh" ]; then
user_profile="${HOME}"/.zshrc
[ ! -f "${user_profile}" ] && user_profile="${HOME}"/.zshenv
[ ! -f "${user_profile}" ] && user_profile="${HOME}"/.zprofile
[ ! -f "${user_profile}" ] && user_profile="${HOME}"/.profile
[ ! -f "${user_profile}" ] && user_profile="${HOME}"/.zlogin
fi
[ -f "${user_profile}" ] && echo "${user_profile}"
}
user_profile=$(get_default_profile)
if [ ${#user_profile} -eq 0 ]; then
echo "Could not determine user profile. Please supply one, example:"
echo "./install ~/.bashrc"
exit 1
fi
fi
echo "Appending lines to user profile: $user_profile"
# If the profile already exists, back it up.
if [ ! -f "$user_profile" ]; then
printf '%s\n' '#BioLockJ generated profile' > $user_profile
echo " Created profile: $user_profile"
elif [ ! -x "$user_profile" ]; then
cp $user_profile $user_profile~
echo " Saved backup: $user_profile~"
fi
echo "" >> $user_profile
echo "# installing BioLockJ" >> $user_profile
echo 'export BLJ='"$BLJ" >> $user_profile
echo " Setting BLJ=$BLJ"
if [ ${#BLJ_PROJ} -gt 0 ] && [ -d ${BLJ_PROJ} ]; then
echo ' Found existing $BLJ_PROJ: '"$BLJ_PROJ"
echo "export BLJ_PROJ=$BLJ_PROJ" >> $user_profile
else
echo ' Setting default BLJ_PROJ=$BLJ/pipelines'
echo 'export BLJ_PROJ=$BLJ/pipelines' >> $user_profile
fi
echo 'export PATH=$BLJ/script:$PATH' >> $user_profile
echo "alias cd-blj='"'cd $(last-pipeline); quick_pipeline_view'"'" >> $user_profile
# should appear in the profile as:
# alias cd-blj='cd $(last-pipeline); quick_pipeline_view'
echo ""
export BLJ
export BLJ_PROJ=$BLJ/pipelines
VER=$(. $user_profile &>/dev/null ; biolockj --version 2>/dev/null )
if [ $? -eq 0 ] && [ ${#VER} -gt 0 ] ; then
echo "Successfully installed BioLockJ version $VER"
echo ""
echo 'Start a new session and run "biolockj --help" to see options.'
else
echo "Installation process complete."
echo 'To verify installation, open a new session and type "biolockj --help"'
fi
echo ""
echo 'Then run a small pipeline:'
echo '"biolockj $BLJ/templates/myFirstPipeline/myFirstPipeline.properties" '
echo ""