scripts/update_git_projects.sh

85 lines
3.4 KiB
Bash
Raw Normal View History

2022-07-06 16:06:27 +02:00
#!/bin/bash
2022-10-20 13:48:10 +02:00
#####################################################
2022-10-20 12:52:44 +02:00
# author: @tykayn@mastodon.cipherbliss.com
# website: https://www.cipherbliss.com
#
# update all listed git projects in the home folder/www
# list of framagit repos to clone. Run this command to make it work
2022-10-20 13:48:10 +02:00
# ------------------------------------------------------------------------------------------------
2022-10-20 12:52:44 +02:00
#
2022-10-20 13:41:04 +02:00
# cd ~/Téléchargements
2022-10-20 12:52:44 +02:00
# curl -s https://forge.chapril.org/tykayn/scripts/raw/branch/master/update_git_projects.sh | bash
#
2022-10-20 13:48:10 +02:00
# ------------------------------------------------------------------------------------------------
#####################################################
2022-07-06 16:06:27 +02:00
2022-10-20 13:48:10 +02:00
######################################################
2022-10-20 13:41:04 +02:00
# liste de tous les projets pour chaque forge logicielle
2022-10-20 13:48:10 +02:00
#####################################################
2022-10-21 11:24:40 +02:00
declare -a list_repos_framagit=("caisse-bliss" "joinfediverse" "date-poll-api" "mastodon" "peertube" "events-liberator" "gitall" "dotclear-importer" "mobilizon" "fanzine-log" "crossed-words" "generator-tk" "circles" "card-deck" "sfprobe" "mastermind" "portfolio" "time-tracker" "cipherbliss.com" "caisse-bliss-frontend" "compta" "trafficjam" "ical-generator" "blueprint-cipherbliss" "dotclear2wordpress" "api" "diaspora" )
2022-10-20 12:52:44 +02:00
declare -a list_repos_forge_chapril=("transcription" "org-report-stats" "multi-account-post-schedule-mastodon" "framalibre-scraping" "scripts" "melting-pot" "funky-framadate-front" "rss-feeder-mobilizon" "mastodon-archive-stats" "gtg2json" "libreavous-audio-reader" "osm_my_commerce" "fromage-js" "ueberauth_openstreetmap" "events-liberator")
2022-07-06 16:06:27 +02:00
prefix_framagit='https://framagit.org/tykayn/'
prefix_forgechapril='https://forge.chapril.org/tykayn/'
cloning_place="/home/$USER/www/"
2022-10-20 13:48:10 +02:00
cd $cloning_place
2022-10-20 13:41:04 +02:00
pwd
# fonction qui prend une url de base et une liste de noms de dépots à cloner
# si vous trouvez comment passer facilement un array en argument à une fonction bash, go faire la fonction pour que l'on puisse faire " pullOrCreateRepo base_url liste_de_dépots"
#function pullOrCreateRepo(){
#}
2022-10-20 13:48:10 +02:00
#####################################################
2022-10-20 13:41:04 +02:00
# tout ceci est très verbeux.
# fonctionnement:
2022-10-20 12:52:44 +02:00
# lancer les clonages et git pull sur chaque dépot
2022-10-20 13:48:10 +02:00
# test existence of a folder
# if there is no folder, clone it
# else, update with fetch from origin
#####################################################
2022-10-20 13:41:04 +02:00
echo "----------- from framagit"
for project_name in "${list_repos_framagit[@]}";
do
2022-10-20 13:48:10 +02:00
cd $cloning_place
2022-10-20 13:41:04 +02:00
if [ ! -d "$project_name" ]
then
echo "+++++ cloning ${project_name}"
echo "from ${prefix_framagit}${project_name}.git"
git clone "${prefix_framagit}${project_name}.git"
else
echo "##### update project $project_name"
2022-10-20 13:48:10 +02:00
cd $cloning_place$project_name
2022-10-20 13:41:04 +02:00
git fetch origin
git config pull.ff only
git pull
fi
done
echo "----------- from forge chapril"
for project_name in "${list_repos_forge_chapril[@]}";
do
2022-10-20 13:48:10 +02:00
cd $cloning_place
if [ ! -d "$project_name" ]
then
echo "+++++ cloning ${project_name}"
echo "from ${prefix_forgechapril}${project_name}.git"
git clone "${prefix_forgechapril}${project_name}.git"
else
echo "##### update project $project_name"
cd $cloning_place$project_name
git fetch origin
git config pull.ff only
git pull
fi
2022-10-20 13:41:04 +02:00
done
2022-10-20 13:48:10 +02:00
# vous pouvez ajouter vos autres dépots
cd $cloning_place
2022-10-20 13:41:04 +02:00
ls -l |wc -l
2022-07-06 16:06:27 +02:00
echo "update done"