From d3afa4788b21cca75923410a540f4ec23618223c Mon Sep 17 00:00:00 2001 From: Bruno21 Date: Mon, 20 Apr 2026 13:28:59 +0200 Subject: [PATCH] 20-04-2026 --- plugins.d/homebrew.sh | 2 +- plugins.d/installed.sh | 2 +- plugins.d/nodejs.sh | 35 ++++++++++++-- plugins.d/rustup.sh | 29 +++++++++--- plugins.d/venv.sh | 2 +- plugins.d/wp.sh | 103 +++++++++++++++++++++++++---------------- 6 files changed, 119 insertions(+), 54 deletions(-) diff --git a/plugins.d/homebrew.sh b/plugins.d/homebrew.sh index 27169be..02d46a5 100755 --- a/plugins.d/homebrew.sh +++ b/plugins.d/homebrew.sh @@ -12,7 +12,7 @@ display_info=true # Casks don't have pinned cask. So add Cask to the do_not_update array for prevent to update. # declare -a do_not_update=("xnconvert" "yate") -declare -a cask_to_not_update=() +declare -a cask_to_not_update=(ff-works) # No distract mode (no user interaction)(Casks with 'latest' version number won't be updated) #[[ $@ =~ "--nodistract" ]] && no_distract=true || no_distract=false diff --git a/plugins.d/installed.sh b/plugins.d/installed.sh index 816215f..51f2256 100755 --- a/plugins.d/installed.sh +++ b/plugins.d/installed.sh @@ -246,7 +246,7 @@ y=$(find . -type f -name 'Brewfile*' -mtime +10 -maxdepth 1) if [ -n "$y" ]; then nb=$(echo "$y" | wc -l) echo "$y" | xargs rm - [ $? ] && echo -e "\033[93m$nb Brewfile_*\033[0m files removed !" + [ $? ] && echo -e "\033[93m$nb Brewfile_*\033[0m files removed !\n\n" fi #iconv -f macroman -t utf-8 Installed.md > Installed-utf8.md diff --git a/plugins.d/nodejs.sh b/plugins.d/nodejs.sh index 205717c..ac8ec9f 100755 --- a/plugins.d/nodejs.sh +++ b/plugins.d/nodejs.sh @@ -28,7 +28,7 @@ update_node=true # Local install: # run 'npm init' in local_path to create package.json -local_path=$HOME/Sites/ +local_path=$HOME/Sites # Add module to the do_not_update array for prevent to update. #declare -a do_not_update=() @@ -54,6 +54,7 @@ redbold="\033[1;31m" redbox="\033[1;41m" reset="\033[0m" + upd_nvm() {( cd "$NVM_DIR" git fetch --tags origin @@ -226,9 +227,9 @@ if find "$local_path/node_modules" -mindepth 1 -maxdepth 1 | read; then while IFS= read -r i do package=$(echo "$i" | awk '{print $1}') - current=$(echo "$i" | awk '{print $2}') - wanted=$(echo "$i" | awk '{print $3}') - latest=$(echo "$i" | awk '{print $4}') + current=$(echo "$i" | awk '{print $2}') # 2.8.3 + wanted=$(echo "$i" | awk '{print $3}') # 2.8.3 + latest=$(echo "$i" | awk '{print $4}') # 2.9.0-beta.1 j=$(echo "$current" | awk -F "." '{print $1}') k=$(echo "$latest" | awk -F "." '{print $1}') @@ -393,6 +394,8 @@ if [ "$doctor" = true ]; then old_node=$(echo "$no" | awk '{print $5}' | sed 's/.//;s/.$//') if [ "$new_node" != "$old_node" ] && [ "$update_node" = true ]; then + +: <<'END_COMMENT' b=$(echo -e "\nCurrent node: v$old_node. Update ${bold}node${reset} to ${bold}v$new_node${reset} [y/n] ? ") read -e -p "$b" rep2 @@ -407,6 +410,30 @@ if [ "$doctor" = true ]; then echo -e "\n${bold}Reinstall packages from v$old_node...${reset}" nvm reinstall-packages "$old_node" fi + +END_COMMENT + + echo -e "\nCurrent node: v$old_node. Press \"u\" to update ${bold}node${reset} to ${bold}v$new_node${reset}" + + #read -sn1 c && printf "You Pressed: %s\n" "$c" + + + read -sn1 c + if [ "$c" == "u" ] || [ "$c" == "U" ]; then + sleep 3 + + . $HOME/.nvm/nvm.sh + echo -e "\n${bold}Updating node to v$new_node...${reset}" + nvm install "$new_node" + echo -e "\n${bold}Updating npm...${reset}" + npm --location=global install npm + # + nvm use $new_node + echo -e "\n${bold}Reinstall packages from v$old_node...${reset}" + nvm reinstall-packages "$old_node" + fi + + fi fi diff --git a/plugins.d/rustup.sh b/plugins.d/rustup.sh index 06ee7ed..f6c3b0f 100755 --- a/plugins.d/rustup.sh +++ b/plugins.d/rustup.sh @@ -5,6 +5,7 @@ underline="\033[4m" ita_under="\033[3;4m" bgd="\033[1;4;31m" red="\033[1;31m" +greenbold="\033[1;32m" bold="\033[1m" box="\033[1;41m" reset="\033[0m" @@ -21,16 +22,30 @@ fi if hash rustup 2>/dev/null; then echo -e "🦀 ${underline}rustup check${reset}\n" - rustup check + #rustup check + check=$(rustup check) + #check=$(echo "$check" | sed 's/Up\ to\ date/${bold}Up\ to\ dateee${reset}/g') + #echo ${check/Up to date/\{greenbold\}Up to dateee\{reset\}\} + #Update available + echo -e "$check" - - if [[ ! $(which rustup-init) =~ "homebrew" ]]; then - echo -e "\n🦀 ${underline}Upgrading rustup itself !${reset}\n" - rustup self update - fi + #if [[ ! $(which rustup-init) =~ "homebrew" ]]; then + # echo -e "\n🦀 ${underline}Upgrading rustup itself !${reset}\n" + # rustup self update + #fi echo -e "\n🦀 ${underline}Upgrading rust toolchains !${reset}\n" - rustup update + check_rust=$(echo "$check" | awk 'NR==1' | awk -F" - " '{print $2}') + + if [[ $check_rust =~ "Update available" ]]; then + echo "$check_rust" + rustup update + elif [[ $check_rust =~ "Up to date" ]]; then + rust_version=$(echo "$check_rust" | awk -F" : " '{print $2}') + echo -e "${greenbold}Rust is up to date!${reset}"" ($rust_version)" + fi + + # si erreur rustup update => rustup toolchain uninstall stable && rustup toolchain install stable echo "" fi diff --git a/plugins.d/venv.sh b/plugins.d/venv.sh index 1a2914a..81c5c8d 100755 --- a/plugins.d/venv.sh +++ b/plugins.d/venv.sh @@ -41,7 +41,7 @@ elif [[ "$OSTYPE" == "linux_gnueabihf" ]]; then v=$HOME/venv fi -curl -Is http://www.google.com | head -1 | grep 200 1>/dev/null +curl -Is https://www.google.com | head -1 | grep 200 1>/dev/null if [[ $? -eq 1 ]]; then echo -e "\n${red}No Internet connection !${reset}" echo -e "Exit !" diff --git a/plugins.d/wp.sh b/plugins.d/wp.sh index 2a24021..e06399e 100755 --- a/plugins.d/wp.sh +++ b/plugins.d/wp.sh @@ -25,12 +25,25 @@ emptytrash=true # Sauvegarde de la base backup=true # Maintenance de la base (optimize & repair) -database=false +database=true # Effacer les transients expirés transient=true # Ouvrir la page d'aministration admin=false +: <<'END_COMMENT' +blabla +END_COMMENT + +italic="\033[3m" +underline="\033[4m" +ita_under="\033[3;4m" +bgd="\033[1;4;31m" +redbold="\033[1;31m" +bold="\033[1m" +box="\033[1;41m" +reset="\033[0m" + #add module to do_not_update array declare -a do_not_update=() @@ -49,20 +62,23 @@ if ! [ -x "$(command -v wp)" ]; then exit 1 fi -echo -e "\033[1mWP wp-cli \033[0m" +echo -e "${redbold}Updates${reset}" echo "" -cd $rep_wordpress +cd $rep_wordpress || exit #echo $(pwd) # *** plugins *** -if [ "$test" = true ]; then +#if [ "$test" = true ]; then + +#: <<'END_COMMENT2' + # *** core update *** - echo "Search for core update..." + echo -e "${bold}Search for core update...${reset}" core_cu=$(wp core check-update) if ! [[ $core_cu = *"latest version"* ]]; then echo "New version available!" @@ -80,10 +96,11 @@ if [ "$test" = true ]; then echo "" # *** plugins *** - echo "Search for all plugins update..." - plugin_cu_all=$(wp plugin update --all --dry-run) - - plugins_outdated=$(echo "$plugin_cu_all" | sed '1,2d' | awk '{print $1}') + echo -e "${bold}Search for all plugins update...${reset}" + wp plugin list --format=table # --update=available + plugin_update=$(wp plugin list --format=table --update=available) + echo + plugins_outdated=$(echo "$plugin_update" | sed '/^+/d' | sed '1d' | awk '{print $1}') if [ -z "$plugins_outdated" ]; then echo "No plugins update available !" else @@ -95,10 +112,11 @@ if [ "$test" = true ]; then echo "" # *** themes *** - echo "Search for all themes update..." - theme_cu_all=$(wp theme update --all --dry-run) - - themes_outdated=$(echo "$theme_cu_all" | sed '1,2d' | awk '{print $1}') + echo -e "${bold}Search for all themes update...${reset}" + wp theme list --format=table #--update=available + theme_update=$(wp theme list --format=table --update=available) + echo + themes_outdated=$(echo "$theme_update" | sed '/^+/d' | sed '1d' | awk '{print $1}') if [ -z "$themes_outdated" ]; then echo "No themes update available !" else @@ -110,10 +128,11 @@ if [ "$test" = true ]; then echo "" # *** languages core *** - echo "Search for languages core update..." - list_lang_core_upd=$(wp language core list --update=available --all --format=csv) + echo -e "${bold}Search for languages core update...${reset}" + wp language core list --update=available --all --format=table + list_lang_core_upd=$(wp language core list --update=available --all --format=table) - lang_core_outdated=$(echo "$list_lang_core_upd" | sed '1d' | awk '{print $1}') + lang_core_outdated=$(echo "$list_lang_core_upd" | sed '/^+/d' | sed '1d' | awk '{print $1}') if [ -z "$lang_core_outdated" ]; then echo "No languages core update available !" else @@ -123,12 +142,13 @@ if [ "$test" = true ]; then done fi echo "" - + + # *** languages plugin *** - echo "Search for languages plugins update..." - list_lang_plugin_upd=$(wp language plugin list --update=available --all --format=csv) - - lang_plugin_outdated=$(echo "$list_lang_plugin_upd" | sed '1d' | awk '{print $1}') + echo -e "${bold}Search for languages plugins update...${reset}" + wp language plugin list --update=available --all --format=table + list_lang_plugin_upd=$(wp language plugin list --update=available --all --format=table) + lang_plugin_outdated=$(echo "$list_lang_plugin_upd" | sed '/^+/d' | sed '1d' | awk '{print $1}') if [ -z "$lang_plugin_outdated" ]; then echo "No languages plugins update available !" else @@ -140,10 +160,11 @@ if [ "$test" = true ]; then echo "" # *** languages theme *** - echo "Search for languages themes update..." - list_lang_theme_upd=$(wp language theme list --update=available --all --format=csv) + echo -e "${bold}Search for languages themes update...${reset}" + wp language theme list --update=available --all --format=table + list_lang_theme_upd=$(wp language theme list --update=available --all --format=table) - lang_theme_outdated=$(echo "$list_lang_theme_upd" | sed '1d' | awk '{print $1}') + lang_theme_outdated=$(echo "$list_lang_theme_upd" | sed '/^+/d' | sed '1d' | awk '{print $1}') if [ -z "$lang_theme_outdated" ]; then echo "No languages themes update available !" else @@ -153,9 +174,10 @@ if [ "$test" = true ]; then done fi -fi +#fi echo "" +#END_COMMENT2 # *** Maintenance *** @@ -164,19 +186,20 @@ if [ "$maint" = true ]; then echo -e "\n\033[1;31mMaintenance...\033[0m" #On récupère la liste des packages installés + echo -e "\n\033[1mInstalled package list...\033[0m" packages_list=$(wp package list | sed -n '1!p' | awk '{print $1'}) -echo "$packages_list" + echo "$packages_list" if [ "$transient" = true ]; then echo -e "\n\033[1mRemove expired transients...\033[0m" - wp transient delete --expired --path=$path + wp transient delete --expired --path=$rep_wordpress fi if [ "$database" = true ]; then echo -e "\n\033[1mDatabase maintenance...\033[0m" - wp db optimize --quiet --path=$path + wp db optimize --quiet --path=$rep_wordpress #wp db repair --quiet --path=$path fi @@ -187,19 +210,19 @@ echo "$packages_list" DATE=`date +%Y-%m-%d_%H:%M:%S` file="wp-$blogname-$DATE.sql" - wp db export "$file" --add-drop-table --path=$path + wp db export "$file" --add-drop-table --path=$rep_wordpress mv "$file" "../$file" fi if [ "$removespam" = true ]; then echo -e "\n\033[1mRemove spam comments...\033[0m" - #spam=$($wp_exec comment list --status=spam --format=ids --path=$path) + spam=$(wp comment list --status=spam --format=ids --path=$rep_wordpress) echo "$spam" if [ -n "$spam" ]; then echo "$spam" #wp comment delete "$spam" --path=$path - wp comment delete $($wp_exec comment list --status=spam --format=ids --path=$path) --path=$path --dry-run + wp comment delete $(wp comment list --status=spam --format=ids --path=$rep_wordpress) --path=$rep_wordpress --dry-run else echo "No SPAM" fi @@ -208,9 +231,9 @@ echo "$packages_list" if [ "$emptytrash" = true ]; then echo -e "\n\033[1mRemove comments in trash and comment from deleted posts...\033[0m" - trashed=$(wp comment list --status=trash,post-trashed --format=ids --path=$path) + trashed=$(wp comment list --status=trash,post-trashed --format=ids --path=$rep_wordpress) if [ -n "$trashed" ]; then - wp comment delete "$trashed" --path=$path + wp comment delete "$trashed" --path=$rep_wordpress echo $? else @@ -221,7 +244,7 @@ echo "$packages_list" #if [[ "$($wp_exec cli has-command 'revisions' --path=$path && echo $?)" -eq 0 ]] && [[ "$rev" = true ]]; then if [[ -n "$(echo "$packages_list" | awk '$1 ~ /trepmal\/wp-revisions-cli/')" ]] && [[ "$rev" = true ]]; then echo -e "\n\033[1mKeep only $revisions revisions...\033[0m" - wp revisions clean $revisions --path=$path --dry-run + wp revisions clean $revisions --path=$rep_wordpress --dry-run elif [ "$rev" = true ]; then printf "Voulez-vous installer wp-revisions-cli ? (y/n)" @@ -239,18 +262,18 @@ echo "$packages_list" if [ "$back" = true ]; then echo -e "\n\033[1mTrackback list...\033[0m" - trackback=$(wp comment list --type=trackback --format=ids --path=$path) + trackback=$(wp comment list --type=trackback --format=ids --path=$rep_wordpress) if [ -n "$trackback" ]; then - wp comment delete "$trackback" --path=$path --dry-run + wp comment delete "$trackback" --path=$rep_wordpress --dry-run else echo "No trackback post" fi echo -e "\n\033[1mPingback list...\033[0m" - pingback=$(wp comment list --type=pingback --format=ids --path=$path) + pingback=$(wp comment list --type=pingback --format=ids --path=$rep_wordpress) if [ -n "$pingback" ]; then - wp comment delete "$pingback" --path=$path --dry-run + wp comment delete "$pingback" --path=$rep_wordpress --dry-run else echo "No pingback post" fi @@ -262,12 +285,12 @@ echo "$packages_list" if [[ -n "$(echo "$packages_list" | awk '$1 ~ /wp-cli\/admin-command/')" ]] && [[ "$admin" = true ]]; then echo -e "\n\033[1mOpen wp-admin/ page in browser...\033[0m" - wp admin --path=$path + wp admin --path=$rep_wordpress elif [ "$admin" = true ]; then wp package install wp-cli/admin-command echo "" echo -e "\n\033[1mOpen wp-admin/ page in browser...\033[0m" - wp admin --path=$path + wp admin --path=$rep_wordpress fi