#!/bin/bash
# Info: Script to patch Gita app.ini after init 
# Author: JesusPerezLorenzo 
# Release: 1.0
# Date: 19-11-2023

ROOT_DATA=${ROOT_DATA:-/data}
DATA_REPO=${DATA_REPO:-$ROOT_DATA/repo}

[ ! -r "$DATA_REPO/gitea/conf/app.ini" ] && echo "Error: app.ini not found " && exit 1

[ ! -r "gitea/webhook_app.ini" ]  && echo "Error: no gitea/webhook_api.ini" && exit 1 

if ! grep -q "\[webhook\]" "$DATA_REPO/gitea/conf/app.ini" ; then
     	cat gitea/webhook_app.ini >> "$DATA_REPO/gitea/conf/app.ini" 
	sudo systemctl restart pod-repo.service
fi

