diff --git a/libaris/res/edu/rpi/aris/VERSION b/libaris/res/edu/rpi/aris/VERSION index c4132bc6..62077419 100644 --- a/libaris/res/edu/rpi/aris/VERSION +++ b/libaris/res/edu/rpi/aris/VERSION @@ -1 +1 @@ -0.0.51 +0.0.52 diff --git a/packaging/extra/server/bin/aris-createdb b/packaging/extra/server/bin/aris-createdb new file mode 100755 index 00000000..cffc43d8 --- /dev/null +++ b/packaging/extra/server/bin/aris-createdb @@ -0,0 +1,62 @@ +#!/bin/bash + +if [ "$(id -u)" -ne "0" ] && [ "$USER" != "aris" ]; then + echo This script must be run as root + exit 1 +fi + +function getParam() { + NAME=$1 + unset PARAM + shopt -s globstar + CFG=$(cat /etc/aris.cfg | grep config-dir | grep -vm 1 '#') + if [ $? -eq 0 ]; then + CFG=$(echo ${CFG#"config-dir"} | xargs) + for f in $(ls -d -1 $CFG//**/*); do + PARAM=$(cat $f | grep $NAME | grep -vm 1 '#') + if [ $? -eq 0 ]; then + PARAM=$(echo ${PARAM#"$NAME"} | xargs) + break + else + unset PARAM + fi + done + fi + if [ -z "$PARAM" ]; then + PARAM=$(cat /etc/aris.cfg | grep $NAME | grep -vm 1 '#') + if [ $? -eq 0 ]; then + PARAM=$(echo ${PARAM#"$NAME"} | xargs) + else + unset PARAM + fi + fi +} + +getParam db-name +if [ -z "$PARAM" ]; then + echo db-name not set in config + exit 1 +else + DBNAME=$PARAM +fi + +getParam db-user +if [ -z "$PARAM" ]; then + echo db-user not set in config + exit 1 +else + DBUSER=$PARAM +fi + +getParam db-pass +if [ -z "$PARAM" ]; then + echo db-pass not set in config + exit 1 +else + DBPASS=$PARAM +fi + +sudo -u postgres psql -c "CREATE DATABASE $DBNAME;" +sudo -u postgres psql -c "CREATE USER $DBUSER;" +sudo -u postgres psql -c "ALTER USER $DBUSER with encrypted password '$DBPASS';" +sudo -u postgres psql -c "grant all privileges on database $DBNAME to $DBUSER;" diff --git a/packaging/extra/server/bin/aris-server b/packaging/extra/server/bin/aris-server index 6078dcdf..ba33cafa 100755 --- a/packaging/extra/server/bin/aris-server +++ b/packaging/extra/server/bin/aris-server @@ -12,11 +12,11 @@ run_aris() { if [ ! pgrep -x "aris-server" &> /dev/null ]; then rm /tmp/aris* fi - CFG=$(cat /etc/aris.cfg | grep config-dir) + CFG=$(cat /etc/aris.cfg | grep config-dir | grep -vm 1 '#') if [ $? -eq 0 ]; then CFG=$(echo ${CFG#"config-dir"} | xargs) for f in $(ls -d -1 $CFG//**/*); do - LOGDIR=$(cat $f | grep log-dir) + LOGDIR=$(cat $f | grep log-dir | grep -vm 1 '#') if [ $? -eq 0 ]; then LOGDIR=$(echo ${LOGDIR#"log-dir"} | xargs) break @@ -26,7 +26,7 @@ run_aris() { done fi if [ -z "$LOGDIR" ]; then - LOGDIR=$(cat /etc/aris.cfg | grep log-dir) + LOGDIR=$(cat /etc/aris.cfg | grep log-dir | grep -vm 1 '#') if [ $? -eq 0 ]; then LOGDIR=$(echo ${LOGDIR#"log-dir"} | xargs) else diff --git a/packaging/extra/server/bin/aris-update b/packaging/extra/server/bin/aris-update index c9b04d90..1ce1b980 100755 --- a/packaging/extra/server/bin/aris-update +++ b/packaging/extra/server/bin/aris-update @@ -11,11 +11,11 @@ update_aris() { rm /tmp/aris* fi TMP=$(dirname $(mktemp -u)) - CFG=$(cat /etc/aris.cfg | grep config-dir) + CFG=$(cat /etc/aris.cfg | grep config-dir | grep -vm 1 '#') if [ $? -eq 0 ]; then CFG=$(echo ${CFG#"config-dir"} | xargs) for f in $(ls -d -1 $CFG//**/*); do - LOGDIR=$(cat $f | grep log-dir) + LOGDIR=$(cat $f | grep log-dir | grep -vm 1 '#') if [ $? -eq 0 ]; then LOGDIR=$(echo ${LOGDIR#"log-dir"} | xargs) break @@ -25,7 +25,7 @@ update_aris() { done fi if [ -z "$LOGDIR" ]; then - LOGDIR=$(cat /etc/aris.cfg | grep log-dir) + LOGDIR=$(cat /etc/aris.cfg | grep log-dir | grep -vm 1 '#') if [ $? -eq 0 ]; then LOGDIR=$(echo ${LOGDIR#"log-dir"} | xargs) else