add stuff in public workflow

This commit is contained in:
Tykayn 2023-08-15 22:23:40 +02:00 committed by tykayn
parent a610a9f945
commit 882fd84c96
13 changed files with 466 additions and 4 deletions

View File

@ -11,8 +11,8 @@ idéalement dans:
# débuter # débuter
Récupérer le script d'initialisation Récupérer le script d'initialisation
```bash ```bash
git clone https://forge.chapril.org/tykayn/scripts git clone https://forge.chapril.org/tykayn/workflow
cd scripts/bash/workflow_nextcloud cd workflow
``` ```
Configrer les variables, puis lancer le script d'initialisation Configrer les variables, puis lancer le script d'initialisation
```bash ```bash

View File

@ -1,2 +0,0 @@
# workflow nextcloud par tykayn
un ensemble d'outils pour gérer sa façon de travailler et ses outils favoris

9
assets/.bash_aliases Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# these bash aliases are meant to be added in your user folder,
# in a file named: .bash_aliases (with the dot at the beginning)
# done for my blog http://www.cipherbliss.com
############################ current
# load aliases from workflow folder
. $WORKFLOW_PATH/assets/.bash_aliases

View File

@ -0,0 +1,48 @@
# -*- coding: utf-8; mode: python; -*-
# Time-stamp: <2017-12-08 15:34:30 vk>
# ===================================================================== ##
# ##
# These are guessfilename configuration settings. ##
# ##
# You might not want to modify anything if you do not know, what ##
# you are doing :-) ##
# ##
# ===================================================================== ##
# INTEGRATION: modify variables in this file according to your requirements
MY_INSURANCE_ID = "1234567"
SOCIAL_SECURITY_NUMBER = "0987654321"
LOAN_INSTITUTE = "My Bank"
LOAN_ID = "123 456 789"
SALARY_STARTSTRING = "salaire"
RECHTSCHUTZVERSICHERUNG = "wtf_is_this_param"
VOLTINO_Kundennummer = "wtf_is_this_param"
# ===================================================================== ##
# ##
# These are INTERNAL configuration settings. ##
# ##
# You might not want to modify anything if you do not REALLY know, ##
# what you are doing :-) ##
# ##
# ===================================================================== ##
# the assert-statements are doing basic sanity checks on the configured variables
# please do NOT change them unless you are ABSOLUTELY sure what this means for the rest of lazyblorg!
#assert type(FILENAME_TAG_SEPARATOR) == unicode
#assert type(BETWEEN_TAG_SEPARATOR) == unicode
# END OF FILE #################################################################
# Local Variables:
# mode: flyspell
# eval: (ispell-change-dictionary "en_US")
# End:

76
assets/konsole.profile Normal file
View File

@ -0,0 +1,76 @@
[Appearance]
AntiAliasFonts=true
BoldIntense=true
ColorScheme=Solarized
DimmValue=56
Font=Noto Mono,16,-1,5,50,0,0,0,0,0
LineSpacing=0
TabColor=invalid
UseFontLineChararacters=false
[Cursor Options]
CursorShape=0
CustomCursorColor=255,255,255
CustomCursorTextColor=0,0,0
UseCustomCursorColor=false
[Encoding Options]
DefaultEncoding=UTF-8
[General]
Command=/usr/bin/zsh
DimWhenInactive=true
Environment=TERM=xterm-256color,COLORTERM=truecolor
Icon=utilities-terminal
LocalTabTitleFormat=%d : %n
Name=Profile 1
RemoteTabTitleFormat=(%u) %H
ShowTerminalSizeHint=true
SilenceSeconds=10
StartInCurrentSessionDir=true
TerminalCenter=true
TerminalColumns=110
TerminalMargin=20
TerminalRows=28
[Interaction Options]
AllowEscapedLinks=false
AlternateScrolling=true
AutoCopySelectedText=false
CopyTextAsHTML=true
CtrlRequiredForDrag=true
DropUrlsAsText=true
EscapedLinksSchema=http://;https://;file://
MiddleClickPasteMode=0
MouseWheelZoomEnabled=true
OpenLinksByDirectClickEnabled=false
PasteFromClipboardEnabled=false
PasteFromSelectionEnabled=true
TrimLeadingSpacesInSelectedText=false
TrimTrailingSpacesInSelectedText=false
TripleClickMode=0
UnderlineFilesEnabled=false
UnderlineLinksEnabled=true
WordCharacters=:@-./_~?&=%+#
[Keyboard]
KeyBindings=default
[Scrolling]
HighlightScrolledLines=true
HistoryMode=1
HistorySize=10000
ScrollBarPosition=1
ScrollFullPage=1
[Terminal Features]
BellMode=1
BidiRenderingEnabled=true
BlinkingCursorEnabled=false
BlinkingTextEnabled=true
FlowControlEnabled=true
PeekPrimaryKeySequence=
ReverseUrlHints=false
UrlHintsModifiers=0
VerticalLine=false
VerticalLineAtChar=80

35
assets/root_bashrc.txt Normal file
View File

@ -0,0 +1,35 @@
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi
##### more things to manage zfs and tykayn scripts : #####
source /home/tykayn/.bash_aliases
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
echo "loading zfs keys"
zfs load-key poule/encrypted
zfs mount -a
##### more things to manage zfs and tykayn scripts : #####

BIN
bin/borg Executable file

Binary file not shown.

5
doc/crontab_example Normal file
View File

@ -0,0 +1,5 @@
#Ansible: run nextcloud workflows of tykayn
*/5 * * * * /bin/bash ~/Nextcloud/ressources/workflow_nextcloud/cronjob_nextcloud.sh
#Ansible: run sync spaceship on spaceship computer, or whichever source of archives
*/4 * * * * /bin/bash ~/Nextcloud/ressources/workflow_nextcloud/sync_spaceship.sh

View File

@ -0,0 +1,141 @@
# /home/poule/backup/rename_photos_testland/07 Juillet 2006/
import re
import sys
import os
import os.path
import time
import logging
from optparse import OptionParser
import colorama
import datetime # for calculating duration of chunks
import json # to parse JSON meta-data files
import appendfilename
# définition du script
USAGE = "\n\
rename_photo_folder [<options>] <list of files>\n\
\n\
This little Python script tries to rename files.\n\
\n\
"
# gestion des options de commande
parser = OptionParser(usage=USAGE)
parser.add_option("--debug", dest="debug", action="store_true",
help="enable debug mode, printing debug information on selected file formats. Currently: just PXL files.")
(options, args) = parser.parse_args()
files = args
# helpers pour clarifier le déroulement
INVOCATION_TIME = time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime())
PROG_VERSION_DATE = "0.5.0"
# dossier de destination de base pour les fichiers de photos
destination_folder_base="/home/poule/backup/rename_photos_testland/"
SUCCESS_DIR=destination_folder_base+'success'
from pathlib import Path
def move_to_success_dir(dirname, newfilename):
"""
Moves a file to SUCCESS_DIR
"""
if os.path.isdir(SUCCESS_DIR):
logging.debug('using hidden feature: if a folder named \"' + SUCCESS_DIR +
'\" exists, move renamed files into it')
os.rename(os.path.join(dirname, newfilename), os.path.join(dirname, SUCCESS_DIR,
newfilename))
logging.info('moved file to sub-directory "' + SUCCESS_DIR + '"')
def make_new_name_from_dirname(filename):
"""
Gets a new name included into a file name
"""
# Split the extension from the path and normalise it to lowercase.
ext_origin = os.path.splitext(filename)[-1]
ext = ext_origin.lower()
current_dir_name = os.path.basename(os.getcwd())
newfile_name = filename.removesuffix(ext_origin).replace(' ',' ')+' '+current_dir_name+' '+ext
print(filename +'\n => '+newfile_name)
return newfile_name
import subprocess
def move_searched_files_to_target_dir(search_path, target_dir):
my_file_search = Path(search_path)
if my_file_search.exists():
bash_command="mv "+my_file_search+" "+current_dir_name+"' "
print(bash_command)
process = subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
from string import Template
# action principale, lecture du dossier pour changer le nom des fichiers
def main():
"""Main function"""
files_counter = 0
folder_counter = 0
current_dir_name = os.path.basename(os.getcwd())
# if options.version:
# print(os.path.basename(sys.argv[0]) + " version " + PROG_VERSION_DATE)
# sys.exit(0)
# print("renommer les photos selon le nom de dossier les contenant")
# print("nom du dossier: ")
print("chemin current_dir_name: ",current_dir_name)
for file in files:
if os.path.isdir(file):
print('hop hop hop voilà un dossier: '+file)
print('on bouge tous les fichiers vidéos qu\'il peut contenir ici')
move_searched_files_to_target_dir(file+'/*.mpg', current_dir_name)
move_searched_files_to_target_dir(file+'/*.mpeg', current_dir_name)
move_searched_files_to_target_dir(file+'/*.mp4', current_dir_name)
folder_counter += 1
# prendre le path de chaque photo donnée en argument du script
# garder le dernier dossier du path en tant que nom à ajouter aux photos
for file in files:
if os.path.isfile(file) and current_dir_name not in file:
new_file_name = make_new_name_from_dirname(file)
# if the current_dir_name is not already present in the file name, add it
old_file_name = os.getcwd()+'/'+file
# bash_command_line = 'appendfilename "'+fullpathfile+'" --text="'+current_dir_name+'"'
# print(' \n '+bash_command_line+' \n')
if os.stat(old_file_name):
print('le fichier existe bien '+ old_file_name)
print('nouveau nom : '+ make_new_name_from_dirname(file))
os.rename(old_file_name, make_new_name_from_dirname(file))
files_counter += 1
# TODO
# faire du append to file name du nom du dossier à chaque photo
print("\n filenames found: " + (str(len(files))))
print(" filenames changed: " + str(files_counter))
print(" folders found: " + str(folder_counter))
print("ça c'est fait")
main()

View File

@ -2,3 +2,138 @@
# #
# mise en place du workflow # mise en place du workflow
# #
echo "========== init de workflow par Tykayn ======="
source ~/Nextcloud/ressources/workflow_nextcloud/workflow_variables.sh
bash ./partials/check_foler_integrity.sh
bash ./partials/git_config_glob.sh
if ! hash ansible > /dev/null; then
echo "* installation de Ansible"
sudo apt install ansible python3-pip
fi
####### lancement des playbooks ansible pour initialisation
ansible-galaxy install coglinev3.veracrypt
echo "vérification et installation des paquets requis"
sudo ansible-playbook "/home/tykayn/Nextcloud/ressources/workflow_nextcloud/ansible/tk_softwares.yml"
ansible-playbook "/home/tykayn/Nextcloud/ressources/workflow_nextcloud/ansible/pip_modules.yml"
sudo ansible-playbook "/home/tykayn/Nextcloud/ressources/workflow_nextcloud/ansible/snaps.yml"
ansible-playbook "/home/tykayn/Nextcloud/ressources/workflow_nextcloud/ansible/node_packages.yml"
ansible-playbook "/home/tykayn/Nextcloud/ressources/workflow_nextcloud/ansible/cronjob_workflow.yml"
sudo ansible-playbook "/home/tykayn/Nextcloud/ressources/workflow_nextcloud/ansible/cronjob_workflow_root.yml"
sudo apt autoremove -y
############ install developping tools
# nvm node version manager
if ! hash nvm > /dev/null; then
echo "installation de nvm"
cd tmp
echo "install nvm"
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
fi
# yarn
corepack enable
#npm i -g yarn
nvm install $node_version_expected
nvm alias default $node_version_expected
nvm alias global $node_version_expected
echo "nvm installé, version des outils js:"
nvm --version
node --version
yarn --version
echo "install des outils en php"
# composer php
# symfony cli tool
# créer le dossier de scripts
if ! hash symfony ; then
wget https://get.symfony.com/cli/installer -O - | bash
fi
if ! hash composer ; then
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
fi
############## java pour josm
if ! hash java ; then
sudo apt install java -y
fi
if ! hash javaws; then
cd tmp
wget https://github.com/karakun/OpenWebStart/releases/download/v1.7.0/OpenWebStart_linux_1_7_0.deb
sudo dpkg -i OpenWebStart_linux_1_7_0.deb
rm -rf OpenWebStart_linux_1_7_0.deb
fi
if ! hash josm ; then
mkdir -p ~/areas/www/misc/josm
cd ~/areas/www/misc/josm
wget https://josm.openstreetmap.de/download/josm.jnlp
sudo apt install josm -y
fi
# bash $WORKFLOW_PATH/update_git_projects.sh
echo "ajouter dans la crontab utilisateur le script cronjob_nextcloud.sh"
echo "# toutes les 5 minutes
#*/5 * * * * bash $WORKFLOW_PATH/cronjob_nextcloud.sh
# vérifiez avec la commande
crontab -e
"
# copier quelques fichiers de config dans la home
cp "$WORKFLOW_PATH"/install/.zshrc ~/
cp "$WORKFLOW_PATH"/install/.bash_aliases ~/
cp "$WORKFLOW_PATH"/install/.bashrc ~/
if ! -d ~/.oh-my-zsh; then
echo "installer oh my zsh"
cd
sudo apt install zsh
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
fi
bash "$WORKFLOW_PATH"/files_management/install.sh
bash "$WORKFLOW_PATH"/install/git_config_glob.sh
bash "$WORKFLOW_PATH"/refresh_from_current_assets.sh

View File

@ -4,3 +4,9 @@
# les créer au besoin, # les créer au besoin,
# alerter sur l'impossibilité de créer en ajoutant une tâche orgmode au dossier de textes # alerter sur l'impossibilité de créer en ajoutant une tâche orgmode au dossier de textes
# #
if ! -d $WORKFLOW_PATH ; then
echo "création du dossier nextcloud workflow_nextcloud"
mkdir -p $WORKFLOW_PATH
fi
mkdir -p $stockage_syncable_folder/www/backup

View File

@ -0,0 +1,9 @@
#!/bin/bash
echo " ------ installation des configurations pour Git ------"
git config --global credential.helper 'store'
git config --global user.email "contact@cipherbliss.com"
git config --global user.name "tykayn"
git config --global rerere.enabled true
git config --global init.defaultBranch main
git config --global checkout.defaultRemote origin