fix cagettepei

This commit is contained in:
pvincent
2024-10-14 13:07:01 +04:00
parent e60d90c7e7
commit ceb3a7b467
3 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash
function check_db_maria_exists() {
db-maria list | grep -q "$1"
db-maria list | grep -q "^$1$"
}
function check_db_postgres_exists() {
+7 -6
View File
@@ -27,20 +27,20 @@ function _read() {
}
function _create() {
echo "creating Cagettei instance for <$shortname> ... "
echo "creating cagettepei instance for <$shortname> ... "
mkdir -p "$MIAOU_CONFIGDIR/apps/cagettepei"
APP_PORT=$port APP_NAME=$shortname tera -e --env-key env -t "$MIAOU_BASEDIR/templates/apps/cagettepei/cagettepei-host.j2" -o "$MIAOU_CONFIGDIR/apps/cagettepei/$longname.conf" "$MIAOU_CONFIGDIR/miaou.expanded.yaml"
echo "creating templates ... OK"
echo "template $longname.conf... OK"
echo "copying files to container <$container> ... "
lxc file push --uid 0 --gid 0 "$MIAOU_CONFIGDIR/apps/cagettepei/$longname.conf" "$container/etc/apache2/sites-available/$longname.conf"
echo "copying files to container <$container> ... OK"
if ! (db-maria list | grep -q "$longname"); then
echo "create empty database <$longname> ... "
if ! check_db_maria_exists "$longname"; then
echo -n "create empty database <$longname> ... "
db-maria create "$longname"
echo "create empty database <$longname> ... OK"
PREFIX="" echoinfo "DONE"
DB_INIT=true
else
echo "database already exists!"
@@ -106,10 +106,11 @@ EOT2
a2ensite $longname.conf
mkdir -p /var/log/apache2/cagettepei/$shortname
systemctl restart apache2
curl localhost:$port
sleep 5
if [[ $DB_INIT == true ]]; then
echo "Force TABLES initialization"
curl localhost:$port
echo "Set administrator password..."
echo "insert into User values (1,'fr','c3513c793b13471f3a49bdb22acb66de',1,'$credential_username','Admin', '$credential_email', null, null, null, null, null, null, null, null, null, now(), now(),6,null, null);" | mariadb cagettepei-$shortname -u cagettepei-$shortname -pcagettepei-$shortname -h ct1.lxd
echo "TODO: password \`cagette\` should be changed soon!!!"