#!/bin/bash

## Copyright (C) 2012 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

set -x
set -e

sudo apt-get update
sudo apt-get install --yes git github-backup

for project in kicksecure whonix ; do
   mkdir --parents ~/project-backup
   cd ~/project-backup

   mkdir --parents ~/project-backup/$project
   cd ~/project-backup/$project
   github-backup $project || true

   mkdir --parents ~/project-backup/$project-wiki-backup-dump-content-current
   if ! test -d ~/project-backup/$project-wiki-backup-dump-content-current ; then
      git clone https://gitlab.com/$project/$project-wiki-backup-dump-content-current.git || true
   fi
   cd ~/project-backup/$project-wiki-backup-dump-content-current
   git fetch || true

   ## git-mediawiki based backup
   ## git-mediawiki is broken upstream
   #
   #if [ "$project" = "kicksecure" ]; then
      #url=https://www.kicksecure.com/w
   #else
      #url=https://www.whonix.org/w
   #fi
   #
   #mkdir --parents ~/project-backup/$project
   #cd ~/project-backup/$project
   #git clone mediawiki::$url || true
   #cd ~/project-backup/$project/w
   #git fetch || true

done

true "END"
