-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.sh
executable file
·99 lines (86 loc) · 2.31 KB
/
update.sh
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
92
93
94
95
96
97
98
#!/bin/bash
# UPDATE SCRIPT
# assumes that getopts is installed
# possible options:
# -h (print usage)
# -q (quiet do not print progress)
# -p <prefix> (path to install, default is ../)
# -c <file> (config file that has plugins, default plugins.json)
function readJSON {
VALUE=`grep -m 1 "\"${2}\"" ${1} | sed 's/^ *//;s/.*: *//;s/,?//' | sed 's/,//'`
if [ ! "$VALUE" ]; then
echo false;
else
echo $VALUE;
fi;
}
function useage(){
echo ""
echo "Usage: update.sh [-h] [-p <prefix>] [-c <config file>]"
echo ""
echo " Will updated the plugins specified in the config file located at path"
echo ""
echo "Options:"
echo "-h Print help menu"
echo "-q Quiet; don't print progress"
echo "-p prefix Install in this directory; default is '../' which"
echo " should be the JBrowse plugin folder"
echo "-c config JSON file specifying which plugins to update"
echo " default is 'plugins.json'"
}
function updatePlugin {
# $1 PREFIX $2 name $3 quiet
prefix=$1
name=$2
quiet=$3
cu=`pwd`
cd ${prefix}${name}
#echo "git pull" >&2
git pull ${quiet}
cd $cu
}
PREFIX="../"
CONFIG="plugins.json"
QUIET=""
while getopts "hqp:c:" opt; do
case $opt in
q)
QUIET="-q"
;;
p)
PREFIX=$OPTARG
;;
c)
CONFIG=$OPTARG
;;
h)
useage
exit 1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "Use -h for help"
exit 1
;;
:)
echo "Option -$OPTARG requires an argument" >&2
echo "Use -h for help"
exit 1
;;
esac
done
# make sure path ends in /
PREFIX=`echo "${PREFIX}/" | sed 's/\/\//\//'`
BASE=https://github.com/bhofmei/
URLS=(jbplugin-hierarchicalcheckbox jbplugin-methylation jbplugin-motifdens jbplugin-seqview jbplugin-screenshot jbplugin-smallrna jbplugin-strandedplot jbplugin-trackscores jbplugin-wigglesvg jbplugin-yscale)
NAMES=(HierarchicalCheckboxPlugin MethylationPlugin MotifDensityPlugin SeqViewsPlugin ScreenShotPlugin SmallRNAPlugin StrandedPlotPlugin TrackScorePlugin WiggleSVGPlotPlugin YScaleMenuPlugin)
for i in ${!NAMES[@]}; do
name=${NAMES[i]}
b=`readJSON ${CONFIG} ${name}`
if [[ $b == "true" ]]; then
if [[ $QUIET == "" ]]; then
echo "Updating ${name}"
fi;
t=`updatePlugin ${PREFIX} ${name} ${QUIET}`
fi;
done