File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- 0.0.51
1+ 0.0.52
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ if [ " $( id -u) " -ne " 0" ] && [ " $USER " != " aris" ]; then
4+ echo This script must be run as root
5+ exit 1
6+ fi
7+
8+ function getParam() {
9+ NAME=$1
10+ unset PARAM
11+ shopt -s globstar
12+ CFG=$( cat /etc/aris.cfg | grep config-dir | grep -vm 1 ' #' )
13+ if [ $? -eq 0 ]; then
14+ CFG=$( echo ${CFG# " config-dir" } | xargs)
15+ for f in $( ls -d -1 $CFG //** /* ) ; do
16+ PARAM=$( cat $f | grep $NAME | grep -vm 1 ' #' )
17+ if [ $? -eq 0 ]; then
18+ PARAM=$( echo ${PARAM# " $NAME " } | xargs)
19+ break
20+ else
21+ unset PARAM
22+ fi
23+ done
24+ fi
25+ if [ -z " $PARAM " ]; then
26+ PARAM=$( cat /etc/aris.cfg | grep $NAME | grep -vm 1 ' #' )
27+ if [ $? -eq 0 ]; then
28+ PARAM=$( echo ${PARAM# " $NAME " } | xargs)
29+ else
30+ unset PARAM
31+ fi
32+ fi
33+ }
34+
35+ getParam db-name
36+ if [ -z " $PARAM " ]; then
37+ echo db-name not set in config
38+ exit 1
39+ else
40+ DBNAME=$PARAM
41+ fi
42+
43+ getParam db-user
44+ if [ -z " $PARAM " ]; then
45+ echo db-user not set in config
46+ exit 1
47+ else
48+ DBUSER=$PARAM
49+ fi
50+
51+ getParam db-pass
52+ if [ -z " $PARAM " ]; then
53+ echo db-pass not set in config
54+ exit 1
55+ else
56+ DBPASS=$PARAM
57+ fi
58+
59+ sudo -u postgres psql -c " CREATE DATABASE $DBNAME ;"
60+ sudo -u postgres psql -c " CREATE USER $DBUSER ;"
61+ sudo -u postgres psql -c " ALTER USER $DBUSER with encrypted password '$DBPASS ';"
62+ sudo -u postgres psql -c " grant all privileges on database $DBNAME to $DBUSER ;"
Original file line number Diff line number Diff line change @@ -12,11 +12,11 @@ run_aris() {
1212 if [ ! pgrep -x " aris-server" & > /dev/null ]; then
1313 rm /tmp/aris*
1414 fi
15- CFG=$( cat /etc/aris.cfg | grep config-dir)
15+ CFG=$( cat /etc/aris.cfg | grep config-dir | grep -vm 1 ' # ' )
1616 if [ $? -eq 0 ]; then
1717 CFG=$( echo ${CFG# " config-dir" } | xargs)
1818 for f in $( ls -d -1 $CFG //** /* ) ; do
19- LOGDIR=$( cat $f | grep log-dir)
19+ LOGDIR=$( cat $f | grep log-dir | grep -vm 1 ' # ' )
2020 if [ $? -eq 0 ]; then
2121 LOGDIR=$( echo ${LOGDIR# " log-dir" } | xargs)
2222 break
@@ -26,7 +26,7 @@ run_aris() {
2626 done
2727 fi
2828 if [ -z " $LOGDIR " ]; then
29- LOGDIR=$( cat /etc/aris.cfg | grep log-dir)
29+ LOGDIR=$( cat /etc/aris.cfg | grep log-dir | grep -vm 1 ' # ' )
3030 if [ $? -eq 0 ]; then
3131 LOGDIR=$( echo ${LOGDIR# " log-dir" } | xargs)
3232 else
Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ update_aris() {
1111 rm /tmp/aris*
1212 fi
1313 TMP=$( dirname $( mktemp -u) )
14- CFG=$( cat /etc/aris.cfg | grep config-dir)
14+ CFG=$( cat /etc/aris.cfg | grep config-dir | grep -vm 1 ' # ' )
1515 if [ $? -eq 0 ]; then
1616 CFG=$( echo ${CFG# " config-dir" } | xargs)
1717 for f in $( ls -d -1 $CFG //** /* ) ; do
18- LOGDIR=$( cat $f | grep log-dir)
18+ LOGDIR=$( cat $f | grep log-dir | grep -vm 1 ' # ' )
1919 if [ $? -eq 0 ]; then
2020 LOGDIR=$( echo ${LOGDIR# " log-dir" } | xargs)
2121 break
@@ -25,7 +25,7 @@ update_aris() {
2525 done
2626 fi
2727 if [ -z " $LOGDIR " ]; then
28- LOGDIR=$( cat /etc/aris.cfg | grep log-dir)
28+ LOGDIR=$( cat /etc/aris.cfg | grep log-dir | grep -vm 1 ' # ' )
2929 if [ $? -eq 0 ]; then
3030 LOGDIR=$( echo ${LOGDIR# " log-dir" } | xargs)
3131 else
You can’t perform that action at this time.
0 commit comments