]> git.argeo.org Git - lgpl/argeo-commons.git/blob - dist/argeo-node/rpm/usr/sbin/argeoctl
Simplify node user admin APIs.
[lgpl/argeo-commons.git] / dist / argeo-node / rpm / usr / sbin / argeoctl
1 #!/bin/sh
2 APP=argeo
3
4 if [ -z "$2" ]; then
5 # Default node
6 echo Argeo default node
7 CONF_DIR=/etc/$APP
8 EXEC_DIR=/var/lib/$APP
9
10 else
11 # Instance
12 INSTANCE=$2
13 echo Argeo instance $INSTANCE
14 if [ -z "$INSTANCE_DIR" ]; then
15 INSTANCE_DIR=$HOME/.local/share/$APP.d/$INSTANCE
16 fi
17 if [ -z "$CONF_DIR" ]; then
18 CONF_DIR=$HOME/.config/$APP.d/$INSTANCE
19 fi
20 EXEC_DIR=$INSTANCE_DIR
21 # Make sure minimal files are available
22 if [ ! -f $CONF_DIR/$APP.ini ]; then
23 cp /etc/$APP/$APP.ini $CONF_DIR
24 fi
25 if [ ! -f $CONF_DIR/log4j.properties ]; then
26 cp /etc/$APP/log4j.properties $CONF_DIR
27 fi
28 fi
29
30 # Java
31 if [ -z "$JVM" ]; then
32 JVM=java
33 fi
34
35 # Directories and files
36
37 BASE_POLICY_ALL=/usr/share/$APP/all.policy
38 BASE_CONFIG_INI=/usr/share/$APP/config.ini
39
40 CONF_DIRS=$CONF_DIR/conf.d
41 DATA_DIR=$EXEC_DIR/data
42 CONF_RW=$EXEC_DIR/state
43 CONFIG_INI=$CONF_RW/config.ini
44
45 # A2 sources can be overridden in *.ini files
46 A2_SOURCES=a2:///
47 OSGI_INSTALL_AREA=/usr/share/osgi/boot
48 OSGI_FRAMEWORK=$OSGI_INSTALL_AREA/org.eclipse.osgi.jar
49
50 # Overwrite variables
51 if [ -f $CONF_DIR/settings.sh ];then
52 . $CONF_DIR/settings.sh
53 fi
54
55 RETVAL=0
56
57 ## START ##
58 start() {
59 mkdir -p $CONF_RW
60 mkdir -p $DATA_DIR
61
62 # Merge config files
63 printf "## Equinox configuration - Generated by /usr/sbin/argeoctl ##\n\n" > $CONFIG_INI
64 cat $BASE_CONFIG_INI >> $CONFIG_INI
65 printf "\n##\n## $CONF_DIR/$APP.ini\n##\n\n" >> $CONFIG_INI
66 cat $CONF_DIR/$APP.ini >> $CONFIG_INI
67 # Concatenate additional .ini files
68 if [ -d "$CONF_DIRS" ]; then
69 for file in `ls -v $CONF_DIRS/*.ini`; do
70 printf "\n##\n## $file\n##\n\n" >> $CONFIG_INI
71 cat $file >> $CONFIG_INI
72 done;
73 fi
74
75 cd $EXEC_DIR
76 $JVM \
77 -Dlog4j.configuration="file:$CONF_DIR/log4j.properties" \
78 $JAVA_OPTS -jar $OSGI_FRAMEWORK \
79 -Dargeo.osgi.sources=$A2_SOURCES \
80 -configuration "$CONF_RW" \
81 -data "$DATA_DIR"
82 }
83
84 ## RELOAD ##
85 reload() {
86 echo Not yet implemented
87 }
88
89 # main
90 case "$1" in
91 start)
92 start
93 ;;
94 reload)
95 reload
96 ;;
97 *)
98 echo $"Usage: $0 {start|reload}"
99 exit 1
100 esac