Compare commits
No commits in common. "a2e088438360ea602ae92637d7d907bb916522a9" and "8f31873ceb427d4c4fa83b370606ca7f346ae0f5" have entirely different histories.
a2e0884383
...
8f31873ceb
5 changed files with 3 additions and 66 deletions
|
|
@ -14,9 +14,7 @@ command="$PODMAN"
|
||||||
command_args="start --all --filter restart-policy=always"
|
command_args="start --all --filter restart-policy=always"
|
||||||
name="podman-containers"
|
name="podman-containers"
|
||||||
command_background=true
|
command_background=true
|
||||||
command_user=hane
|
|
||||||
pidfile="/var/run/${RC_SVCNAME}.pid"
|
pidfile="/var/run/${RC_SVCNAME}.pid"
|
||||||
#pidfile="/tmp/xdg/$UID-xdg-runtime-dir/${RC_SVCNAME}.pid"
|
|
||||||
output_log="/home/${CONTAINER_USER:-$DEFAULT_CONTAINER_USER}/pihanepi/orchestrating/${RC_SVCNAME}.log"
|
output_log="/home/${CONTAINER_USER:-$DEFAULT_CONTAINER_USER}/pihanepi/orchestrating/${RC_SVCNAME}.log"
|
||||||
error_log="/home/${CONTAINER_USER:-$DEFAULT_CONTAINER_USER}/pihanepi/orchestrating/${RC_SVCNAME}.err"
|
error_log="/home/${CONTAINER_USER:-$DEFAULT_CONTAINER_USER}/pihanepi/orchestrating/${RC_SVCNAME}.err"
|
||||||
|
|
||||||
|
|
@ -27,18 +25,18 @@ error_log="/home/${CONTAINER_USER:-$DEFAULT_CONTAINER_USER}/pihanepi/orchestrati
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
ebegin "Starting Podman containers with restart policy"
|
ebegin "Starting Podman containers with restart policy"
|
||||||
"$PODMAN" start --all --filter restart-policy=$RESTART_POLICY
|
doas -u "$CONTAINER_USER" "$PODMAN" start --all --filter restart-policy=$RESTART_POLICY
|
||||||
eend $?
|
eend $?
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
ebegin "Stopping Podman containers with restart policy"
|
ebegin "Stopping Podman containers with restart policy"
|
||||||
|
|
||||||
CONTAINERS=$("$PODMAN" container ls --filter restart-policy=$RESTART_POLICY -q)
|
CONTAINERS=$(doas -u "$CONTAINER_USER" "$PODMAN" container ls --filter restart-policy=$RESTART_POLICY -q)
|
||||||
|
|
||||||
if [ -n "$CONTAINERS" ]; then
|
if [ -n "$CONTAINERS" ]; then
|
||||||
for CONTAINER in $CONTAINERS; do
|
for CONTAINER in $CONTAINERS; do
|
||||||
"$PODMAN" stop "$CONTAINER"
|
doas -u "$CONTAINER_USER" "$PODMAN" stop "$CONTAINER"
|
||||||
done
|
done
|
||||||
eend $?
|
eend $?
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Make sure crond is running, and add each script to the user's crontab
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
. secrets
|
|
||||||
#TODO check secrets file exists
|
|
||||||
|
|
||||||
#Retrieve token user
|
|
||||||
user_json=$(curl -s -X 'GET' \
|
|
||||||
'https://$GIT_DOMAIN/api/v1/user' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${AUTH_TOKEN}")
|
|
||||||
|
|
||||||
user_id=$(jq ".id" <(echo "$user_json"))
|
|
||||||
user_username=$(jq ".username" <(echo "$user_json"))
|
|
||||||
echo $user_username
|
|
||||||
|
|
||||||
#Retrieve repos from user, including private repos
|
|
||||||
repo_json=$(curl -s -X 'GET' \
|
|
||||||
"https://$GIT_DOMAIN/api/v1/repos/search?uid=${user_id}?private=true" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${AUTH_TOKEN}")
|
|
||||||
|
|
||||||
#Listing only the HTTPS repo clone URL
|
|
||||||
repo_urls=$(jq ".data" <(echo "$repo_json") | jq ".[] | .html_url" | grep Hane)
|
|
||||||
echo $repo_urls
|
|
||||||
echo "----\n"
|
|
||||||
|
|
||||||
#Cloning each repo to destdir
|
|
||||||
i=0;
|
|
||||||
finished=false;
|
|
||||||
while ! $finished
|
|
||||||
do
|
|
||||||
i=$(($i+1));
|
|
||||||
repo=$(awk "{print \$$i}" <(echo $repo_urls))
|
|
||||||
if [ "$repo" = "" ]
|
|
||||||
then
|
|
||||||
finished=true
|
|
||||||
else
|
|
||||||
#Retrieve repo name for folder
|
|
||||||
repo_name="$(awk -F/ '{print $5}' <(echo $repo))"
|
|
||||||
repo_name="${repo_name%\"}"
|
|
||||||
#echo $repo_name
|
|
||||||
#Remove quotes from user_username
|
|
||||||
username=${user_username%\"}
|
|
||||||
username=${username#\"}
|
|
||||||
#Clone repo
|
|
||||||
#TODO: what do if repo already exists? if it!
|
|
||||||
if [ -e "$REPO_DIR$repo_name" ]
|
|
||||||
then
|
|
||||||
echo "REPO: $repo_name"
|
|
||||||
git -C "$REPO_DIR$repo_name" fetch --all
|
|
||||||
#git -C "$REPO_DIR$repo_name" rebase --update-refs
|
|
||||||
else
|
|
||||||
git clone https://$user_username:$AUTH_TOKEN@$GIT_DOMAIN/$username/$repo_name /home/$USER/pihanepi/datamount/gitbackup/$repo_name --recurse-submodules
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
REPO_DIR=/home/$USER/pihanepi/datamount/gitbackup/
|
|
||||||
GIT_DOMAIN=git.roboces.dev
|
|
||||||
AUTH_TOKEN=
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue