2024-05-12 17:43:07 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
workdir=$(realpath $(dirname "$0"))
|
|
|
|
cd $workdir
|
|
|
|
|
2024-08-30 13:49:39 +02:00
|
|
|
function update_venv()
|
|
|
|
{
|
|
|
|
if [ -d "venv" ]; then
|
2024-08-30 18:29:14 +02:00
|
|
|
venv/bin/pip install -r requirements.txt >/dev/null
|
2024-08-30 13:49:39 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-05-12 17:43:07 +02:00
|
|
|
function git_pull_and_update_cron_and_restart_services_if_needed()
|
|
|
|
{
|
2024-09-09 14:42:37 +02:00
|
|
|
git pull &>/dev/null || sendxmpppy "[apps repo] Couldn't pull, maybe local changes are present?"
|
2024-05-12 17:43:07 +02:00
|
|
|
|
|
|
|
# Cron
|
|
|
|
cat cron | sed "s@__BASEDIR__@$workdir@g" > /etc/cron.d/app_list
|
|
|
|
|
|
|
|
# App store
|
|
|
|
chown -R appstore store
|
|
|
|
pushd store >/dev/null
|
2024-05-12 18:24:30 +02:00
|
|
|
modified_after_service_start="$(find *.py translations/ templates/ assets/ -newermt "$(systemctl show --property=ActiveEnterTimestamp appstore | cut -d= -f2 | cut -d' ' -f2-3)")"
|
2024-05-12 17:43:07 +02:00
|
|
|
if [ -n "$modified_after_service_start" ]
|
|
|
|
then
|
2024-08-30 13:49:39 +02:00
|
|
|
update_venv
|
|
|
|
|
2024-05-12 17:43:07 +02:00
|
|
|
pushd assets >/dev/null
|
|
|
|
./tailwindcss-linux-x64 --input tailwind-local.css --output tailwind.css --minify
|
|
|
|
popd >/dev/null
|
|
|
|
systemctl restart appstore
|
|
|
|
sleep 3
|
|
|
|
fi
|
|
|
|
popd >/dev/null
|
|
|
|
|
|
|
|
systemctl --quiet is-active appstore || sendxmpppy "[appstore] Uhoh, failed to (re)start the appstore service?"
|
|
|
|
|
|
|
|
# App generator
|
|
|
|
chown -R appgenerator tools/app_generator
|
|
|
|
pushd tools/app_generator >/dev/null
|
2024-05-12 18:24:30 +02:00
|
|
|
modified_after_service_start="$(find *.py translations/ templates/ static/ -newermt "$(systemctl show --property=ActiveEnterTimestamp appgenerator | cut -d= -f2 | cut -d' ' -f2-3)")"
|
2024-05-12 17:43:07 +02:00
|
|
|
if [ -n "$modified_after_service_start" ]
|
|
|
|
then
|
2024-08-30 13:49:39 +02:00
|
|
|
update_venv
|
2024-05-12 17:43:07 +02:00
|
|
|
pushd assets >/dev/null
|
|
|
|
./tailwindcss-linux-x64 --input tailwind-local.css --output tailwind.css --minify
|
|
|
|
popd >/dev/null
|
|
|
|
systemctl restart appgenerator
|
|
|
|
sleep 3
|
|
|
|
fi
|
|
|
|
popd >/dev/null
|
|
|
|
|
|
|
|
systemctl --quiet is-active appgenerator || sendxmpppy "[appgenerator] Uhoh, failed to (re)start the appgenerator service?"
|
|
|
|
|
|
|
|
# Autoreadme
|
|
|
|
pushd tools/readme_generator >/dev/null
|
2024-06-08 19:19:19 +02:00
|
|
|
modified_after_service_start="$(find *.py translations/ templates/ -newermt "$(systemctl show --property=ActiveEnterTimestamp webhooks | cut -d= -f2 | cut -d' ' -f2-3)")"
|
2024-05-12 17:43:07 +02:00
|
|
|
if [ -n "$modified_after_service_start" ]
|
|
|
|
then
|
2024-08-30 13:49:39 +02:00
|
|
|
update_venv
|
2024-06-08 19:19:19 +02:00
|
|
|
systemctl restart webhooks
|
2024-05-12 17:43:07 +02:00
|
|
|
sleep 3
|
|
|
|
fi
|
|
|
|
popd >/dev/null
|
|
|
|
|
2024-06-08 19:19:19 +02:00
|
|
|
# Autoreadme
|
|
|
|
pushd tools/webhooks >/dev/null
|
|
|
|
modified_after_service_start="$(find *.py -newermt "$(systemctl show --property=ActiveEnterTimestamp webhooks | cut -d= -f2 | cut -d' ' -f2-3)")"
|
|
|
|
if [ -n "$modified_after_service_start" ]
|
|
|
|
then
|
2024-08-30 13:49:39 +02:00
|
|
|
update_venv
|
2024-06-08 19:19:19 +02:00
|
|
|
systemctl restart webhooks
|
|
|
|
sleep 3
|
|
|
|
fi
|
|
|
|
popd >/dev/null
|
|
|
|
|
2024-08-30 13:49:39 +02:00
|
|
|
pushd tools/autoupdate_app_sources >/dev/null
|
|
|
|
update_venv
|
|
|
|
popd >/dev/null
|
|
|
|
|
2024-06-08 19:19:19 +02:00
|
|
|
systemctl --quiet is-active webhooks || sendxmpppy "[autoreadme] Uhoh, failed to (re)start the autoreadme service?"
|
2024-05-12 17:43:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function rebuild_catalog()
|
|
|
|
{
|
|
|
|
log=$workdir/app_list_auto_update.log
|
|
|
|
date >> $log
|
|
|
|
git_pull_and_update_cron_and_restart_services_if_needed
|
|
|
|
./tools/list_builder.py &>> $log || sendxmpppy "[listbuilder] Rebuilding the application list failed miserably"
|
|
|
|
}
|
|
|
|
|
|
|
|
function autoupdate_app_sources()
|
|
|
|
{
|
|
|
|
log=$workdir/app_sources_auto_update.log
|
|
|
|
date >> $log
|
|
|
|
git_pull_and_update_cron_and_restart_services_if_needed
|
2024-05-13 17:36:04 +02:00
|
|
|
tools/autoupdate_app_sources/venv/bin/python3 tools/autoupdate_app_sources/autoupdate_app_sources.py \
|
2024-07-08 20:27:52 +02:00
|
|
|
--latest-commit-weekly --edit --commit --pr --paste -j1 \
|
2024-05-12 17:43:07 +02:00
|
|
|
&> $log || sendxmpppy "[appsourcesautoupdate] App sources auto-update failed miserably"
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_app_levels()
|
|
|
|
{
|
|
|
|
pushd tools/update_app_levels >/dev/null
|
|
|
|
python3 update_app_levels.py
|
|
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetch_main_dashboard()
|
|
|
|
{
|
|
|
|
pushd store >/dev/null
|
2024-05-14 14:34:24 +02:00
|
|
|
venv/bin/python3 fetch_main_dashboard.py 2>&1 | grep -v 'Following Github server redirection'
|
2024-05-12 17:43:07 +02:00
|
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fetch_level_history()
|
|
|
|
{
|
|
|
|
pushd store >/dev/null
|
|
|
|
venv/bin/python3 fetch_level_history.py
|
|
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
$1
|