File tree Expand file tree Collapse file tree 13 files changed +79
-55
lines changed Expand file tree Collapse file tree 13 files changed +79
-55
lines changed Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/sh
2
2
3
3
HELP=" Usage: lifecap [command]
4
4
5
5
lifecap captures a stream of events about your life, to feed into summarization
6
6
and aggregation systems. The idea is that we use collectors to gather data,
7
7
which publish events to topics that other collectors might be interested in.
8
8
"
9
- . $( dirname $0 ) /lifecap_lib.sh
9
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
10
10
11
+ echo " $HELP "
11
12
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/sh
2
2
3
3
HELP=" Lifecap collectors
4
4
@@ -8,5 +8,7 @@ below by adding programs with lifecap-collector-name* to your path.
8
8
See --help on the collectors themselves for configuration and use.
9
9
"
10
10
11
- . $( dirname $0 ) /lifecap_lib.sh
11
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
12
+
13
+ echo " $HELP "
12
14
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/sh
2
2
3
3
HELP=" Usage: lifecap config [command]
4
4
5
5
Lists the config"
6
6
7
- . $( dirname $0 ) /lifecap_lib.sh
7
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
8
8
9
- echo config_dir: $config_dir
10
- echo cache_dir: $cache_dir
11
- echo data_dir: $data_dir
9
+ echo config_dir: " $config_dir "
10
+ echo cache_dir: " $cache_dir "
11
+ echo data_dir: " $data_dir "
12
12
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/sh
2
2
3
3
HELP=" Usage: lifecap job [command]
4
4
5
5
Commands to do with data collection jobs."
6
6
7
- . $( dirname $0 ) /lifecap_lib.sh
7
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
8
8
9
9
echo " $HELP "
10
10
Original file line number Diff line number Diff line change @@ -5,27 +5,28 @@ HELP="Usage: lifecap job add <name> <collector_name> [collector options]
5
5
Adds a data collection job.
6
6
"
7
7
8
- . $( dirname $0 ) /lifecap_lib.sh
8
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
9
9
10
10
name=" $1 "
11
11
collector=" $2 "
12
- shift 2
13
12
14
13
if [ -z " $name " ] || [ -z " $collector " ]; then
15
14
echo " $HELP " >&2
16
15
exit 1
17
16
fi
18
17
19
- job_dir=" $data_dir /jobs/$name "
18
+ shift 2
19
+
20
+ job_dir=" $config_dir /jobs/$name "
20
21
21
- safe_path " $data_dir /jobs " " $name "
22
+ safe_path " $job_dir "
22
23
23
24
if [ -e " $job_dir " ]; then
24
25
echo " Job '$name ' already exists" >&2
25
26
exit 1
26
27
fi
27
28
28
- if [ -z " $( lifecap collector options | grep " $collector " ) " ] ; then
29
+ if ! " $( lifecap collector options | grep -q " $collector " ) " ; then
29
30
echo " Collector '$collector ' doesn't exist" >&2
30
31
echo " Options: $( lifecap collector options) " >&2
31
32
exit 1
@@ -37,6 +38,7 @@ mkdir -p "$job_dir"
37
38
# Configure the collector
38
39
if ! lifecap collector " $collector " setup " $job_dir " " $@ " ; then
39
40
echo " Job creation failed." >&2
40
- rm -r $job_dir
41
+ rm -r " $job_dir "
42
+ exit 1
41
43
fi
42
44
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/sh
2
2
3
3
HELP=" Usage: lifecap collector ls
4
4
5
5
Lists currently installed collectors"
6
6
7
- . $( dirname $0 ) /lifecap_lib.sh
7
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
8
8
9
- ls -1 $config_dir /collectors
9
+ ls -1 " $config_dir /collectors"
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/sh
2
2
3
- HELP=" Usage: lifecap collector ls
3
+ HELP=" Usage: lifecap job rm <name>
4
4
5
5
Lists currently installed collectors"
6
6
7
- . $( dirname $0 ) /lifecap_lib.sh
7
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
8
8
9
- set -e
9
+ if [ -z " $1 " ]; then
10
+ echo " No such job"
11
+ echo " Jobs: $( ls " $config_dir " /collectors) "
12
+ fi
13
+
14
+ path=" $config_dir /collectors/$1 "
15
+
16
+ path_exists " $path "
17
+
18
+ rm " $path "
10
19
11
- rm " $config_dir /collectors/$1 "
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ HELP="Usage: lifecap topic [command]
4
4
5
5
Topics are channels where data flows."
6
6
7
- . $( dirname $0 ) /lifecap_lib.sh
7
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
8
8
9
- echo $HELP >&2
9
+ echo " $HELP " >&2
10
10
exit 1
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/sh
2
2
3
3
HELP=" Usage: lifecap topic ls [pattern]
4
4
5
5
List existing topics"
6
6
7
- . $( dirname $0 ) /lifecap_lib.sh
7
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
8
8
9
9
ls -1 " $data_dir /topics/$1 "
10
10
Original file line number Diff line number Diff line change @@ -4,24 +4,10 @@ HELP="Usage: lifecap topic rm <name>
4
4
5
5
Remove a topic by name"
6
6
7
- . $( dirname $0 ) /lifecap_lib.sh
7
+ . " $( dirname " $0 " ) " /lifecap_lib.sh
8
8
9
- # Reject wildcards/globs
10
- case " $1 " in
11
- * [\*\? ]* )
12
- echo " Wildcards not allowed!"
13
- exit 1
14
- ;;
15
- * \.\. * )
16
- echo " No traversal, thanks."
17
- exit 1
18
- ;;
19
- esac
9
+ path=" $data_dir /topics/$1 "
10
+ path_exists " $path "
20
11
21
- # Resolve full path and ensure it’s under
22
- path=$data_dir /topics/$1
23
- real_path=$( cd " $( dirname " $path " ) " && pwd -P) /$( basename " $path " )
24
- [ ! " $real_path " = " $path " ] && echo " Invalid path!" && exit 1
25
-
26
- rm -r $path
12
+ rm -r " $path "
27
13
You can’t perform that action at this time.
0 commit comments