From 39bd006a7c219a73851b649288033d56d2c19b81 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Fri, 17 Feb 2023 12:27:17 +0100 Subject: [PATCH] update of assets from refresh script --- bash/workflow_nextcloud/README.md | 15 ++++ bash/workflow_nextcloud/ansible/ansible_hosts | 8 ++ .../ansible/cronjob_workflow.yml | 7 ++ .../ansible/orgcalendar.ics | 0 .../ansible/server_tk_softwares.yml | 53 ++++++++++++ bash/workflow_nextcloud/ansible/snaps.yml | 31 +++++++ .../ansible/tk_softwares.yml | 70 +++++++++++++++ bash/workflow_nextcloud/cronjob_nextcloud.sh | 7 +- .../refresh_from_current_assets.sh | 68 +++++++++++++++ bash/workflow_nextcloud/sync_spaceship.sh | 12 +-- bash/workflow_nextcloud/update_calendar.sh | 17 ++-- .../workflow_nextcloud/update_git_projects.sh | 85 +++++++++++++++++++ bash/workflow_nextcloud/workflow_variables.sh | 29 ++++++- 13 files changed, 387 insertions(+), 15 deletions(-) create mode 100644 bash/workflow_nextcloud/README.md create mode 100644 bash/workflow_nextcloud/ansible/ansible_hosts create mode 100644 bash/workflow_nextcloud/ansible/cronjob_workflow.yml create mode 100644 bash/workflow_nextcloud/ansible/orgcalendar.ics create mode 100644 bash/workflow_nextcloud/ansible/server_tk_softwares.yml create mode 100644 bash/workflow_nextcloud/ansible/snaps.yml create mode 100644 bash/workflow_nextcloud/ansible/tk_softwares.yml create mode 100644 bash/workflow_nextcloud/refresh_from_current_assets.sh create mode 100644 bash/workflow_nextcloud/update_git_projects.sh diff --git a/bash/workflow_nextcloud/README.md b/bash/workflow_nextcloud/README.md new file mode 100644 index 00000000..87afa5d3 --- /dev/null +++ b/bash/workflow_nextcloud/README.md @@ -0,0 +1,15 @@ +# Workflow avec Nextcloud +Gérer ses flux de travaux et autres gestion de projets avec des scripts. +J'unifie le comportement de mes stations de travail avec une gestion syncronisée de certains scripts pemettant d'installer certains programmes avec des configurations par défaut. + +Ce dossier doit être présent dans votre dossier nextcloud, +idéalement dans: +``` +~/Nextcloud/ressources/workflow_nextcloud +``` + +# débuter +Configrer les variables, puis ancer le script d'initialisation +```bash +bash ~/Nextcloud/ressources/workflow_nextcloud/init_workflow_tykayn.sh +``` \ No newline at end of file diff --git a/bash/workflow_nextcloud/ansible/ansible_hosts b/bash/workflow_nextcloud/ansible/ansible_hosts new file mode 100644 index 00000000..8458280b --- /dev/null +++ b/bash/workflow_nextcloud/ansible/ansible_hosts @@ -0,0 +1,8 @@ +[webservers] +localhost +proxmox.coussinet.org +peertube.cipherbliss.com +www.cipherbliss.com +192.168.1.2 +192.168.1.15 +bbb.liness.org diff --git a/bash/workflow_nextcloud/ansible/cronjob_workflow.yml b/bash/workflow_nextcloud/ansible/cronjob_workflow.yml new file mode 100644 index 00000000..0dc6114a --- /dev/null +++ b/bash/workflow_nextcloud/ansible/cronjob_workflow.yml @@ -0,0 +1,7 @@ +- name: cronjob pour le workflow nextcloud toutes les 5 minutes + hosts: localhost + tasks: + ansible.builtin.cron: + name: "backup nextcloud things" + minute: "*/5" + job: "/bin/bash ~/Nextcloud/ressources/workflow_nextcloud/cronjob_nextcloud.sh" diff --git a/bash/workflow_nextcloud/ansible/orgcalendar.ics b/bash/workflow_nextcloud/ansible/orgcalendar.ics new file mode 100644 index 00000000..e69de29b diff --git a/bash/workflow_nextcloud/ansible/server_tk_softwares.yml b/bash/workflow_nextcloud/ansible/server_tk_softwares.yml new file mode 100644 index 00000000..0be4d400 --- /dev/null +++ b/bash/workflow_nextcloud/ansible/server_tk_softwares.yml @@ -0,0 +1,53 @@ +- name: installer des programmes utiles avec apt + hosts: localhost + become: yes + become_user: root + vars: + server_name: localhost + tasks: + - name: ensure latest version of main tools is installed on a headless computer + apt: + state: present + name: + - arp-scan + - borgbackup + - curl + - docker + - docker-compose + - etckeeper + - git + - gnupg + - jq + - meld + - nano + - ncdu + - nginx + - npm + - pandoc + - php + - python3 + - python3-pip + - tig + - zsh + - veracrypt + - testdisk + - htop + - btop + - python3-pip + - python3-setuptools + - autopostgresqlbackup + - automysqlbackup + - certbot + - smartmontools + - fail2ban + - snapd + - unattended-upgrades + - php + - php-fpm + - php-xml + - php-mysql + - rsync + - php-dom + - php-curl + - vrms + - syncthing diff --git a/bash/workflow_nextcloud/ansible/snaps.yml b/bash/workflow_nextcloud/ansible/snaps.yml new file mode 100644 index 00000000..dacc8937 --- /dev/null +++ b/bash/workflow_nextcloud/ansible/snaps.yml @@ -0,0 +1,31 @@ +# Install snaps +- name: Install "emacs" with option --classic + community.general.snap: + name: emacs + classic: true + +- name: Install "blender" with option --classic + community.general.snap: + name: blender + classic: true + +- name: Install "rambox" with option --classic + community.general.snap: + name: rambox + classic: true + +- name: Install "thunderbrid" with option --classic + community.general.snap: + name: thunderbrid + classic: true + +- name: Install "tor-mkg20001" + community.general.snap: + name: tor-mkg20001 + + +# python packages +- name: Install guessfilename + ansible.builtin.pip: + name: guessfilename + extra_args: --user diff --git a/bash/workflow_nextcloud/ansible/tk_softwares.yml b/bash/workflow_nextcloud/ansible/tk_softwares.yml new file mode 100644 index 00000000..3d079535 --- /dev/null +++ b/bash/workflow_nextcloud/ansible/tk_softwares.yml @@ -0,0 +1,70 @@ +- name: installer des programmes utiles avec apt + hosts: localhost + become: yes + become_user: root + vars: + server_name: localhost + tasks: + - name: ensure latest version of main tools for desktop is installed + apt: + state: present + name: + - arp-scan + - audacity + - baobab + - borgbackup + - curl + - docker + - dolphin + - thunar + - docker-compose + - etckeeper + - gajim + - geeqie + - gimp + - git + - gpa + - gnupg + - grsync + - jq + - kdenlive + - keepassxc + - konsole + - krita + - krita-l10n + - meld + - nano + - ncdu + - nginx + - npm + - pandoc + - php + - python3 + - python3-pip + - terminator + - tig + - transmission + - ufw + - zsh + - veracrypt + - testdisk + - htop + - btop + - python3-pip + - python3-setuptools + - autopostgresqlbackup + - automysqlbackup + - certbot + - smartmontools + - fail2ban + - snapd + - unattended-upgrades + - php + - php-fpm + - php-xml + - php-mysql + - rsync + - php-dom + - php-curl + - vrms + - klavaro diff --git a/bash/workflow_nextcloud/cronjob_nextcloud.sh b/bash/workflow_nextcloud/cronjob_nextcloud.sh index 915eb0dc..839d85d3 100644 --- a/bash/workflow_nextcloud/cronjob_nextcloud.sh +++ b/bash/workflow_nextcloud/cronjob_nextcloud.sh @@ -4,8 +4,9 @@ # tâche à effectuer régulièrement sur les ordis portables # # @author functions_sync by @tykayn - contact at cipherbliss.com +source ~/Nextcloud/ressources/workflow_nextcloud/workflow_variables.sh # récupérer les notes du mobile et les stocker dans l'incoming inbox orgmode -bash ~/Nextcloud/ressources/workflow_nextcloud/update_calendar.sh -bash ~/Nextcloud/ressources/workflow_nextcloud/get_nextcloud_notes_todo.sh -bash ~/Nextcloud/ressources/workflow_nextcloud/backup_nextcloud_in_user_home.sh +bash $WORKFLOW_PATH/update_calendar_tkwulfi.sh +bash $WORKFLOW_PATH/get_nextcloud_notes_todo.sh +bash $WORKFLOW_PATH/backup_nextcloud_in_user_home.sh diff --git a/bash/workflow_nextcloud/refresh_from_current_assets.sh b/bash/workflow_nextcloud/refresh_from_current_assets.sh new file mode 100644 index 00000000..7ade31b6 --- /dev/null +++ b/bash/workflow_nextcloud/refresh_from_current_assets.sh @@ -0,0 +1,68 @@ +#/bin/bash +# @author script by @tykayn - contact at cipherbliss.com +# rafraîchir les assets du dépot d'example versionné avec ceux couramment utilisés. +# à installer sur un ordi que l'on utilise en tant que référence d'assets +# à installer en cronjob avec: +# crontab -e +# +# m h dom mon dow command +# */30 * * * * bash /home/tykayn/www/scripts/refresh_from_current_assets.sh + +# configs +source ~/Nextcloud/ressources/workflow_nextcloud/workflow_variables.sh +echo "mise à jour des assets de référence dans les scripts custom $HOME_OF_SCRIPTS depuis l'ordinateur actuel" + + +if [ ! -d $HOME_OF_SCRIPTS ]; then + mkdir -p $HOME_OF_SCRIPTS + git clone https://forge.chapril.org/tykayn/scripts $HOME_OF_SCRIPTS +fi + +# bouger le dossier www +if [ -d $HOME/www ]; then + echo "déplacement du dossier $HOME/www dans $www_folder" + mv $HOME/www/* $www_folder +fi + +# orgmode +echo " " +echo "copie de config emacs vers le dossier $HOME_OF_SCRIPTS" +cp "$WORKFLOW_PATH/.emacs" "$HOME_OF_SCRIPTS/assets/org" -r +cp "$orgmode_path/config.org" "$HOME_OF_SCRIPTS/assets/org" -r +cp "$orgmode_path/style.css" "$HOME_OF_SCRIPTS/assets/org" -r + +cp "$WORKFLOW_PATH/update_calendar.sh" "$HOME_OF_SCRIPTS/assets/org" -r +# sauvegardes +cp "$HOME/test-func.sh" "$HOME_OF_SCRIPTS/bash/backups" + +cp "$WORKFLOW_PATH/workflow_variables.sh" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud/" +cp "$WORKFLOW_PATH/init_workflow_nextcloud.sh" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud/" +cp "$WORKFLOW_PATH/cronjob_nextcloud.sh" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud/" +cp "$WORKFLOW_PATH/git_autocommit.sh" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud/" +cp "$WORKFLOW_PATH/update_calendar.sh" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud/" +cp "$WORKFLOW_PATH/README.md" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud/" +cp "$WORKFLOW_PATH/refresh_from_current_assets.sh" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud/" +cp "$WORKFLOW_PATH/update_git_projects.sh" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud/" +cp "$WORKFLOW_PATH/sync_spaceship.sh" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud" +cp "$WORKFLOW_PATH/functions_sync.sh" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud" +cp -r "$WORKFLOW_PATH/ansible/*" "$HOME_OF_SCRIPTS/bash/workflow_nextcloud/ansible" + +cd $HOME_OF_SCRIPTS +git status + +echo " " +echo "copie de des fichiers d'alias vers la home utilisateur" +# workflow things +cp "$WORKFLOW_PATH/install/.bash_aliases" ~/ +cp "$WORKFLOW_PATH/install/.bash_custom_aliases" ~/ +cp "$WORKFLOW_PATH/install/.bashrc" ~/ +cp "$WORKFLOW_PATH/install/.zshrc" ~/ +cp "$WORKFLOW_PATH/install/.emacs" ~/ + + +echo "HOME_OF_SCRIPTS : $HOME_OF_SCRIPTS" +ls -l "$HOME_OF_SCRIPTS/assets/org" +cd $HOME_OF_SCRIPTS +git add . +git commit -m "update of assets from refresh script" +git push origin diff --git a/bash/workflow_nextcloud/sync_spaceship.sh b/bash/workflow_nextcloud/sync_spaceship.sh index 161ec074..8d48a5d9 100644 --- a/bash/workflow_nextcloud/sync_spaceship.sh +++ b/bash/workflow_nextcloud/sync_spaceship.sh @@ -12,7 +12,7 @@ # crontab -e # # m h dom mon dow command -# */30 * * * * bash ~/Nextcloud/ressources/workflow_nextcloud/sync_spaceship.sh +# */30 * * * * bash ~/sync_spaceship.sh # # ----------------- configs ----------------- # functions_sync.sh définit les constantes utiles @@ -35,8 +35,8 @@ cp ~/.emacs $ARCHIVE_SYNCABLE/archivage/__scripts_syncro cp ~/Nextcloud/ressources/workflow_nextcloud/sync_spaceship.sh $ARCHIVE_SYNCABLE/archivage/__scripts_syncro -cp ~/.bash_aliases ~/Nextcloud/ressources/workflow_nextcloud/install -cp ~/.emacs ~/Nextcloud/ressources/workflow_nextcloud/install +#cp ~/.bash_aliases ~/Nextcloud/ressources/workflow_nextcloud/install +#cp ~/.emacs ~/Nextcloud/ressources/workflow_nextcloud/install echo ' ' >> $LOG_FILE_BACKUP_DATES echo "### ${today} start backup script from sync_spaceship script" >> $LOG_FILE_BACKUP_DATES @@ -51,11 +51,13 @@ dpkg --get-selections>~/list_of_debian_apt_packages.txt # back pictures to ARCHIVE_SYNCABLE logDate 'copy of Nextcloud InstantUpload photos' +mv /home/tykayn/Nextcloud/inbox/instantUpload "$ARCHIVE_SYNCABLE/photos/$CURRENT_YEAR" | tee -a $LOG_FILE_BACKUP 2>&1 +mv ~/Nextcloud/InstantUpload/Camera/* "$ARCHIVE_SYNCABLE/photos/a dispatcher" | tee -a $LOG_FILE_BACKUP 2>&1 mv ~/Nextcloud/inbox/instantUpload/* "$ARCHIVE_SYNCABLE/photos/$CURRENT_YEAR" | tee -a $LOG_FILE_BACKUP 2>&1 echo ' ' >> $LOG_FILE_BACKUP_DATES echo "### ${today} medias in $ARCHIVE_SYNCABLE/photos/$CURRENT_YEAR" >> $LOG_FILE_BACKUP_DATES ls -l "$ARCHIVE_SYNCABLE/photos/$CURRENT_YEAR" | wc -l | tee -a $LOG_FILE_BACKUP 2>&1 - + logDate ' Screenshots et Download' mv ~/Nextcloud/inbox/InstantUpload/Screenshots/* "$ARCHIVE_SYNCABLE/photos/screenshots" | tee -a $LOG_FILE_BACKUP 2>&1 @@ -67,7 +69,7 @@ rsync -avhWP --perms --inplace --delete-before ~/Nextcloud/* $ARCHIVE_SYNCABLE/a # --------- copier la home dans les archives ------------ logDate 'update home backup'; -rsync -avhWP --inplace --delete-before ~/* /home/poule/encrypted/stockage-syncable/archivage/home "${exclude_opts[@]}" --exclude 'Nextcloud' --exclude 'www' | tee -a $LOG_FILE_BACKUP 2>&1 +rsync -avhWP --inplace --delete-before ~/* /home/poule/encrypted/stockage-syncable/archivage/home "${exclude_opts[@]}" --exclude 'Nextcloud' --exclude 'www' --exclude 'VirtualBox VMs' | tee -a $LOG_FILE_BACKUP 2>&1 # --------- sauver les dossiers de développement dans l'archive stockage syncable sans supprimer les projets présents -------- # diff --git a/bash/workflow_nextcloud/update_calendar.sh b/bash/workflow_nextcloud/update_calendar.sh index 26125891..ae5f04e1 100644 --- a/bash/workflow_nextcloud/update_calendar.sh +++ b/bash/workflow_nextcloud/update_calendar.sh @@ -1,17 +1,24 @@ #!/bin/bash # getting a nextcloud calendar without auth and convert it to org file # add this to a cronjob -# nécessite icsorg, installable par : -# npm install icsorg -g - +# echo "updating calendar from nextcloud" -#URL="https://cloud.tykayn.fr/remote.php/dav/public-calendars/ABCDEFFFFFFFFFFFFFFF\?export" # public link to orgmode calendar of nextcloud https://cloud.tykayn.fr/index.php/apps/calendar/timeGridWeek/now +# public link to orgmode calendar of nextcloud https://cloud.tykayn.fr/index.php/apps/calendar/timeGridWeek/now +#URL="https://cloud.tykayn.fr/remote.php/dav/public-calendars/abcdeffffffffffffffffff\?export" -URL_CAL="https://nuage.tykayn.fr/remote.php/dav/public-calendars/ABCDEFFFFFFFFFFFFFFF?export" # calendrier partagé +URL_CAL="https://nuage.tykayn.fr/remote.php/dav/public-calendars/cHkSk5rG445MftpZ?export" # calendrier tkwulfi echo $URL_CAL wget $URL_CAL -O orgcalendar.ics --show-progress +# add content of other calendars +#URL_CAL="https://cloud.tykayn.fr/remote.php/dav/calendars/super_admin_tykayn/mobilizonfr/?export" +#wget $URL_CAL -O ->> orgcalendar.ics --show-progress + +# annivs +#URL_CAL="https://cloud.tykayn.fr/remote.php/dav/calendars/super_admin_tykayn/contact_birthdays/?export" +#wget $URL_CAL -O ->> orgcalendar.ics --show-progress +# convert the ics to an org file du -sch orgcalendar.ics icsorg -i orgcalendar.ics -o calendar.org -p 999999 cat calendar.org |wc -l diff --git a/bash/workflow_nextcloud/update_git_projects.sh b/bash/workflow_nextcloud/update_git_projects.sh new file mode 100644 index 00000000..74c1b8ca --- /dev/null +++ b/bash/workflow_nextcloud/update_git_projects.sh @@ -0,0 +1,85 @@ +#!/bin/bash +##################################################### +# 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 +# ------------------------------------------------------------------------------------------------ +# +# cd ~/Téléchargements +# curl -s https://forge.chapril.org/tykayn/scripts/raw/branch/master/update_git_projects.sh | bash +# +# ------------------------------------------------------------------------------------------------ +##################################################### +source ~/Nextcloud/ressources/workflow_nextcloud/workflow_variables.sh + +###################################################### +# liste de tous les projets pour chaque forge logicielle +##################################################### +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" ) +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") + +prefix_framagit='https://framagit.org/tykayn/' +prefix_forgechapril='https://forge.chapril.org/tykayn/' + +cloning_place=$www_folder + cd $cloning_place +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(){ +#} + +##################################################### +# tout ceci est très verbeux. +# fonctionnement: +# lancer les clonages et git pull sur chaque dépot +# test existence of a folder +# if there is no folder, clone it +# else, update with fetch from origin +##################################################### + +echo "----------- from framagit" + for project_name in "${list_repos_framagit[@]}"; + do + cd $cloning_place + 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" + cd $cloning_place$project_name + 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 + 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 + done + +# vous pouvez ajouter vos autres dépots + + cd $cloning_place +ls -l |wc -l +echo "update done" + diff --git a/bash/workflow_nextcloud/workflow_variables.sh b/bash/workflow_nextcloud/workflow_variables.sh index 2a264009..e0a9794c 100644 --- a/bash/workflow_nextcloud/workflow_variables.sh +++ b/bash/workflow_nextcloud/workflow_variables.sh @@ -1,5 +1,30 @@ #!/bin/bash -export workflow_path=~/Nextcloud/ressources/workflow_nextcloud/ +# ajouter dans les scripts avec cette ligne: +# +# source ~/Nextcloud/ressources/workflow_nextcloud/workflow_variables.sh +# +# +export WORKFLOW_PATH=~/Nextcloud/ressources/workflow_nextcloud +export ALIASES_PATH=$WORKFLOW_PATH/install/.bash_custom_aliases +# fichiers orgmode, wiki personnel export orgmode_path=~/Nextcloud/textes/orgmode +export inbox_orgmode=$orgmode_path/incoming_inbox.org export orgroam_path=~/Nextcloud/textes/orgmode/org-roam -export BORG_PASSCOMMAND="cat /home/$USER/.tk-borg-passphrase-light" \ No newline at end of file +export backup_texts_folder=~/archives/backup_automatique +export HOME_OF_SCRIPTS=$www_folder/scripts + +# archives dans un pool zfs nommé poule +export stockage_syncable_folder=/home/poule/encrypted/stockage-syncable + +# dossier où stocker les projets de dev +export www_folder=$HOME/areas/www + +export node_version_expected=16 + +export today=`date` # to log current time +export ARCHIVE_SYNCABLE=$stockage_syncable_folder # place where we have our things sorted, other than home +export BORG_PASSCOMMAND="cat $ARCHIVE_SYNCABLE/.tk-borg-passphrase-light" # get the borg repo pass +export SPACESHIP_BORG_REPO="/home/poule/borg_archives/backup_land4to" +export LOG_FILE_BACKUP="$ARCHIVE_SYNCABLE/www/backup/log_backup.log" +# log dates of execution of the script +export LOG_FILE_BACKUP_DATES="$ARCHIVE_SYNCABLE/www/backup/summary_log_backup.log" \ No newline at end of file