Compare commits

...

2 Commits

Author SHA1 Message Date
8506efeeca Merge pull request 'add volume for config and script to edit config files' (#2) from ammar_volumes into main
Reviewed-on: #2
2024-11-29 06:06:26 +00:00
Ammar Hussein
fe9944fbd8 config volume 2024-11-28 12:11:58 -08:00
3 changed files with 79 additions and 0 deletions

View File

@ -23,4 +23,44 @@
> Warning: trying to access <app-name> before db instance finishes initialization results in failure to initialize the xwiki instance, recommended to wait for about 5 minutes (that is plenty of time) before accessing the app from your browser.
## How to edit configs
Method 1: You can mount the volume `xwiki_cfg` in `rw` mode, navigate to the files, and make the edits.
Method2: You can also use `abra app cmd`, here is an example:
```
$ abra app cmd -l <app-name> edit_config
Which config file do you wish to edit?
/usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.cfg
/usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.properties
/usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
/usr/local/tomcat/webapps/ROOT/WEB-INF/classes/logback.xml
/usr/local/tomcat/webapps/ROOT/WEB-INF/web.xml
Enter file name (without the path)
web.xml
Enter file path (including the file name)
/usr/local/tomcat/webapps/ROOT/WEB-INF/web.xml
Pulling web.xml from the app
web.xml is temporarily available
edit the file, save and exit, then press enter to continue
Moving the edited file to the app
deleting the local copy
Done!
```
TODO: on macos, the associative arrays won't work (declare -A throws an error)
You can use a brew version of bash to make it work, but abra currently [defaults to /bin/bash](https://git.coopcloud.tech/coop-cloud/abra/src/branch/main/cli/app/cmd.go#L98)
To simplify the interactive script above, we would first need abra to allow us to choose the shell path.
For more, see [`docs.coopcloud.tech`](https://docs.coopcloud.tech).

37
abra.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
CONTEXT_PATH=ROOT
WEBINF=/usr/local/tomcat/webapps/$CONTEXT_PATH/WEB-INF
# Config files
xwiki_cfg=$WEBINF/xwiki.cfg
xwiki_properties=$WEBINF/xwiki.properties
hibernate_cfg_xml=$WEBINF/hibernate.cfg.xml
logback_xml=$WEBINF/classes/logback.xml
web_xml=$WEBINF/web.xml
ALL_FILES=($xwiki_cfg $xwiki_properties $hibernate_cfg_xml $logback_xml $web_xml)
edit_config() {
select_file
echo -e "Pulling $FILE_NAME from the app\n"
abra app cp $APP_NAME app:$FILE_PATH ./
echo -e "$FILE_NAME is temporarily available\n"
echo -e "edit the file, save and exit, then press enter to continue\n"
read </dev/tty
echo -e "Moving the edited file to the app\n"
abra app cp $APP_NAME $FILE_NAME app:$FILE_PATH
echo -e "deleting the local copy\n"
rm $FILE_NAME
echo "Done!"
}
select_file() {
echo -e "Which config file do you wish to edit?\n"
for f in ${ALL_FILES[*]}; do
echo -e $f
done
echo -e "Enter file name (without the path)"
read FILE_NAME </dev/tty
echo -e "Enter file path (including the file name)"
read FILE_PATH </dev/tty
}

View File

@ -10,6 +10,7 @@ services:
- DB_HOST=${STACK_NAME}_db
volumes:
- xwiki-data:/usr/local/xwiki
- xwiki_cfg:/usr/local/tomcat/webapps/ROOT/WEB-INF/
secrets:
- db_password
networks:
@ -62,6 +63,7 @@ networks:
volumes:
mysql-data:
xwiki-data:
xwiki_cfg:
secrets:
db_password: