1
0

Compare commits

..

2 Commits

Author SHA1 Message Date
unfr
7147b81529 modification update 2025-02-21 11:50:20 +01:00
unfr
7e264c0272 Modification update.sh 2025-02-21 11:43:02 +01:00
4 changed files with 47 additions and 15 deletions

View File

@ -10,6 +10,7 @@ checkdb(){
}
do_start() {
do_update
checkdb
if screen -list | grep -q "$SCREEN_NAME"; then
echo "Le screen '$SCREEN_NAME' est déjà en cours d'exécution."
@ -179,6 +180,10 @@ EOF
sqlite3 "$DB_FILE" "PRAGMA busy_timeout = 5000;"
}
do_update() {
wget -qO update.sh https://tig.unfr.pw/UNFR/postauto/raw/branch/main/update.sh && chmod +x update.sh && ./update.sh
}
case "$1" in
start)
do_start
@ -195,6 +200,9 @@ case "$1" in
status)
do_status
;;
update)
do_update
;;
check)
if [ -z "$2" ]; then
echo "Usage: $0 add <release_path>"
@ -220,7 +228,7 @@ case "$1" in
do_add "$@"
;;
*)
echo "Usage: $0 {start|stop|restart|show|add <release_path>}"
echo "Usage: $0 {start|stop|restart|show|log|check|update|add <release_path>}"
exit 1
;;
esac

View File

@ -164,7 +164,7 @@ _autopost_completion() {
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Liste des commandes disponibles
opts="start stop restart show status createdb add log check"
opts="start stop restart show status createdb add log check update"
# Si l'utilisateur est en train de taper le premier argument, proposer les commandes
if [ $COMP_CWORD -eq 1 ]; then

View File

@ -74,6 +74,8 @@ postauto createdb
| add | Ajouté un fichier MKV à traiter dans la base (doit être suivi du chemin complet de votre fichier). |
| createdb | Permet de créer la DB (si vous souhaitez écraser la DB une confirmation vous sera demandé). |
| log | Permet de voir le log de ppost d'un fichier précis. |
| check | Permet de vérifier la présence d'un fichier sur le site. |
| update | Permet d'updater le script. |
#### Désinstallation.

View File

@ -45,12 +45,34 @@ echo -e "$BLEU""Téléchargement de autopost""$NORMAL"
mkdir -p "$AUTOPOST_DIR"
# Télécharger les fichiers dans autopost
wget -q -O "$AUTOPOST_DIR/analyzer.sh" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/analyzer.sh"
wget -q -O "$AUTOPOST_DIR/common.sh" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/common.sh"
wget -q -O "$AUTOPOST_DIR/posteur.sh" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/posteur.sh"
# Télécharger le fichier dans bin
wget -q -O "$BIN_DIR/postauto" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/bin/postauto"
# Liste des fichiers à vérifier et mettre à jour
declare -A FILES
FILES["$HOME/autopost/analyzer.sh"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/analyzer.sh"
FILES["$HOME/autopost/posteur.sh"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/posteur.sh"
FILES["$HOME/autopost/common.sh"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/common.sh"
FILES["$HOME/bin/postauto"]="https://tig.unfr.pw/UNFR/postauto/raw/branch/main/bin/postauto"
# Vérification et mise à jour des fichiers
for LOCAL_FILE in "${!FILES[@]}"; do
URL="${FILES[$LOCAL_FILE]}"
TMP_FILE=$(mktemp)
# Télécharger le fichier distant
curl -s "$URL" -o "$TMP_FILE"
# Comparer avec le fichier local et mettre à jour si nécessaire
if ! diff -q "$LOCAL_FILE" "$TMP_FILE" > /dev/null 2>&1; then
#diff -u "$LOCAL_FILE" "$TMP_FILE" || echo "Le fichier local n'existe pas encore."
echo "Mise à jour de $LOCAL_FILE..."
mv "$TMP_FILE" "$LOCAL_FILE"
chmod +x "$LOCAL_FILE"
else
echo "Aucune mise à jour nécessaire pour $LOCAL_FILE."
rm "$TMP_FILE"
fi
done
# Définir le chemin du fichier bashrc
BASHRC_FILE="$HOME/.bashrc"
@ -69,7 +91,7 @@ _autopost_completion() {
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Liste des commandes disponibles
opts="start stop restart show status createdb add log check"
opts="start stop restart show status createdb add log check update"
# Si l'utilisateur est en train de taper le premier argument, proposer les commandes
if [ $COMP_CWORD -eq 1 ]; then
@ -90,6 +112,7 @@ complete -F _autopost_completion postauto
EOF
# Vérifier si le code est déjà présent dans le fichier bashrc
echo "Modification de la configuration de complétion dans $BASHRC_FILE..."
if grep -q "$DEBUT_MARKER" "$BASHRC_FILE"; then
# Faire une sauvegarde de sécurité du fichier .bashrc
cp "$BASHRC_FILE" "${BASHRC_FILE}.bak"
@ -97,14 +120,13 @@ if grep -q "$DEBUT_MARKER" "$BASHRC_FILE"; then
# Supprimer le bloc de code entre les marqueurs (inclusifs)
sed -i "/$DEBUT_MARKER/,/$FIN_MARKER/d" "$BASHRC_FILE"
else
echo "Ajout de la configuration de complétion dans $BASHRC_FILE..."
fi
# Ajouter une ligne vide pour séparer (optionnel)
echo "" >> "$BASHRC_FILE"
# Ajouter le code de complétion
echo "$COMPLETION_CODE" >> "$BASHRC_FILE"
echo "Mise à jour effectuée."
fi
echo "Suppression du script après exécution..."
rm -- "$0