10 Commits

Author SHA1 Message Date
40040c264b pipx.sh
bug in pipx -> pips list —quiet
2024-01-09 18:05:36 +01:00
b76e72a1ef Test internet connection
-run scripts only if internet is ok
2023-11-16 15:00:35 +01:00
c8ced14004 venv.sh
-add streamrip to apps list
2023-11-14 20:27:59 +01:00
6ee801d946 Bugfix
-json casks list
2023-08-01 13:53:54 +02:00
feab0bb267 nodejs
-add a do_not_update option
2023-01-05 16:55:18 +01:00
02ed39943b Rust plugin
1st version
2022-11-25 10:26:39 +01:00
bcd4ca41c6 homebrew.sh
-add a test to not proceed any bash upgrade.
2022-11-08 22:03:33 +01:00
d13e3277b1 minor bugfix 2022-08-03 15:39:57 +02:00
de82e3f6a3 kymsu.sh
-bugfix
2022-07-17 16:57:17 +02:00
db3ef113ad Auto-update
-add a preference file $HOME/.kymsu/plugins.d/kymsu.pref
-add a preference for setting auto-update from github repo
2022-07-17 16:56:38 +02:00
12 changed files with 260 additions and 46 deletions

View File

@@ -21,6 +21,7 @@ homebrew and pecl plugins notifie you if apache/php configuration files have bee
- **perl** (Perl modules ([cpan](https://metacpan.org)))
- **pip** ([Python Package index](https://pypi.org)) (pip or pip3)
- **pipx** ([Python Apps in Isolated Environments](https://pypa.github.io/pipx/))
- **rust** ([Rust](https://www.rust-lang.org))
- **venv** ([Environnement virtuel Python](https://docs.python.org/3/library/venv.html))
- **wp** (WordPress [wp-cli](https://wp-cli.org/fr/)) <u>(for testing only)</u>
@@ -77,7 +78,7 @@ Prefix plugin with a _ to ignore it:
There is a <u>settings section</u> on top of each plug-in:
- *[homebrew-pip]* don't update a module, package...: add it to the `do_not_update` array on the top.
- *[homebrew-pip-nodejs]* don't update a module, package...: add it to the `do_not_update` array on the top.
```bash
$ nano homebrew.sh
@@ -85,9 +86,9 @@ declare -a do_not_update=('virtualbox,virtualbox-extension-pack')
```
- *[homebrew]* display info on updated pakages: `display_info=true`
- *[homebrew-npm-pecl-pip]* no distract mode (no user interaction): `no_distract=false`
- *[homebrew-nodejs-pecl-pip]* no distract mode (no user interaction): `no_distract=false`
*If running Homebrew plug-in in no_distract mode, Casks with 'latest' version number won't be updated.*
- *[npm]* run npm maintenance tools: `doctor=true`
- *[nodejs]* run npm maintenance tools: `doctor=true`
- *[pip]* `version=pip or pip3` `user="" or "--user"`

View File

@@ -36,6 +36,7 @@ function showHelp() {
all_plugins=false
no_distract=false
brew_cleanup=false
SCRIPTS_DIR=$HOME/.kymsu/plugins.d
while getopts "hncs: a-:" opt
do
@@ -62,23 +63,26 @@ done
#shift "$((OPTIND-1))"
SCRIPTS_DIR=$HOME/.kymsu/plugins.d
# -n : non vide
if [ -n "$one_script" ]; then
# Un seul script
list_plugins=$(find $SCRIPTS_DIR -maxdepth 1 -type f -name "*$one_script.sh" -a -perm +111)
#list_plugins=$(find $SCRIPTS_DIR -maxdepth 1 -type f -name "*$one_script" -a -perm +111)
list_plugins=$(find $SCRIPTS_DIR -maxdepth 1 -type f -name "$one_script" -o -name "_$one_script" -a -perm +111)
[ -z "$list_plugins" ] && echo -e "❗️ No named plugin ${italic}$one_script${reset}" && exit -1
# [[ $@ =~ "--all" ]] && all_plugins=true || all_plugins=false
elif [ "$all_plugins" = false ]; then
# Tous sauf commençant par _ (les fichiers commençant par '_' ne sont pas pris en compte) "_*.sh"
list_plugins=$(find $SCRIPTS_DIR -maxdepth 1 -type f ! -name "_*" -a -name "*.sh" -a -perm +111 | sort)
[ -z "$list_plugins" ] && echo -e "❗️ No plugin in ${italic}$SCRIPTS_DIR${reset}" && exit -1
else
# Tous (-a = ET; -perm +111 = exec)
list_plugins=$(find $SCRIPTS_DIR -maxdepth 1 -type f -name "*.sh" -a -perm +111 | sort)
[ -z "$list_plugins" ] && echo -e "❗️ No plugin in ${italic}$SCRIPTS_DIR${reset}" && exit -1
fi
cd "$SCRIPTS_DIR"
<<COMMENT
@@ -97,6 +101,7 @@ echo ""
for script in $list_plugins; do
# le $@ permet de passer à chaque script les arguments passés à *ce* script
$script $@
#echo "$script"
done
shift "$((OPTIND-1))"

View File

@@ -1,6 +1,57 @@
#!/usr/bin/env bash
echo "🦄 KYMSU self update"
pushd "$(cat ~/.kymsu/path)" > /dev/null
git pull
popd > /dev/null
echo ""
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
#PREF_FILE="$SCRIPT_DIR/kymsu.pref"
#TEMP_FILE="$SCRIPT_DIR/kymsu.pref.tmp"
PREF_FILE="$HOME/.kymsu/plugins.d/kymsu.pref"
TEMP_FILE="$HOME/.kymsu/plugins.d/kymsu.pref.tmp"
# 5m 5 minutes
# 2h 2 hours
# 4d 4 days
# 3w 3 weeks
# 1M 1 month
# 1Y 1 year
update_interval="1w"
x=${update_interval: -1}
case $x in
m) unite=60;;
h) unite=3600;;
d) unite=$(( 3600*24 ));;
w) unite=$(( 3600*24*7 ));;
M) unite=$(( 3600*24*30 ));;
Y) unite=$(( 3600*24*30*12 ));;
*) echo "Bad update_interval pref" >&2
#exit -1;;
esac
y=$(( ${#update_interval}-1 ))
nb=${update_interval:0:$y}
w=$(( unite*nb ))
if [ -f $PREF_FILE ]; then
last_update=$(cat $PREF_FILE | grep "last.update" | awk -F"=" '{print $2}' )
else
last_update=0
fi
current_timestamp=$(date +"%s")
temps=$(( current_timestamp-last_update))
if [ $(( temps-w)) -gt 0 ]; then
echo "🦄 KYMSU self update"
pushd "$(cat ~/.kymsu/path)" > /dev/null
#git pull
git pull https://Bruno21@github.com/Bruno21/kymsu.git
popd > /dev/null
echo ""
if [ $last_update -eq 0 ]; then
echo "last.update=$current_timestamp" > $PREF_FILE
else
awk -F'=' -v OFS='=' -v newval="$current_timestamp" '/^last.update/{$2=newval;print;next}1' $PREF_FILE > $TEMP_FILE
mv $TEMP_FILE $PREF_FILE
fi
fi

View File

@@ -74,7 +74,7 @@ get_info_cask() {
#auto_updates=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.auto_updates)')
#caveats=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.caveats)')
installed_versions=$(echo "$upd_cask" | jq -r '.[] | select(.name == "'${app}'") | (.installed_versions)')
installed_versions=$(echo "$upd_cask" | jq -r '.[] | select(.name == "'${app}'") | (.installed_versions)' | jq -r '.[]')
current_version=$(echo "$upd_cask" | jq -r '.[] | select(.name == "'${app}'") | (.current_version)')
[[ "$desc" = "null" ]] && desc="${italic}No description${reset}"
@@ -117,6 +117,7 @@ get_info_pkg() {
#echo -e "installed: $installed\n"
installed_versions=$(echo "$upd_package" | jq -r '.[] | select(.name == "'${pkg2}'") | (.installed_versions)' | jq -r '.[]')
current_version=$(echo "$upd_package" | jq -r '.[] | select(.name == "'${pkg2}'") | (.current_version)')
#echo -e "installed_versions: $installed_versions\n"
#echo "stable: $current_version"
@@ -151,6 +152,13 @@ get_info_pkg() {
echo -e "${bold}🍺 Homebrew ${reset}"
curl -Is http://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 !"
exit 1
fi
echo -e "\n🍺 ${underline}Updating brew...${reset}\n"
brew update
@@ -240,6 +248,11 @@ if [ -n "$upd_pkg_notpinned" ]; then
if [ "$choice" == "y" ] || [ "$choice" == "Y" ] || [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
for i in $upd_pkg_notpinned;
do
if [ "$i" == "bash" ]; then
echo -e "\nBash update available !"
echo -e "You should run ${bold}brew upgrade bash${reset} in another terminal !\n"
continue
fi
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
echo "$i" | xargs -p -n 1 brew upgrade
elif [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
@@ -272,11 +285,12 @@ upd_cask=$(echo "$brew_outdated" | jq '{casks} | .[]')
# parse error: Unfinished string at EOF at line 2, column 0
# parse error: Invalid numeric literal at line 1, column 7
#echo "$upd_cask"
for row in $(jq -c '.[]' <<< "$upd_cask");
do
name=$(echo "$row" | jq -j '.name')
installed_versions=$(echo "$row" | jq -j '.installed_versions')
installed_versions=$(echo "$row" | jq -j '.installed_versions | .[]')
current_version=$(echo "$row" | jq -j '.current_version')
if [ "$current_version" != "latest" ]; then

1
plugins.d/kymsu.pref Normal file
View File

@@ -0,0 +1 @@
last.update=1658067929

View File

@@ -30,6 +30,11 @@ update_node=false
# run 'npm init' in local_path to create package.json
local_path=$HOME/Sites/
# Add module to the do_not_update array for prevent to update.
#declare -a do_not_update=()
#declare -a do_not_update=("parso" "asgiref")
declare -a do_not_update=("@squoosh/cli")
#########################################
: <<'END_COMMENT'
@@ -44,6 +49,8 @@ red="\033[1;31m"
bold="\033[1m"
bold_ita="\033[1;3m"
box="\033[1;41m"
redbold="\033[1;31m"
redbox="\033[1;41m"
reset="\033[0m"
upd_nvm() {(
@@ -75,6 +82,14 @@ echo -e "\n${underline}🌿 npm:${reset}"
echo -e " - current version: ${italic}$npm_v${reset}"
echo -e " - install path: ${italic}$npm_ins${reset}"
curl -Is http://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 !"
exit 1
fi
# version installée de nvm par Homebrew
# nvm_installed=$(brew info nvm | grep Cellar)
@@ -142,6 +157,19 @@ echo -e "You need to run \"nvm install 10.18.0\" to install it before using it.$
echo ""
# Do not update packages
if (( ${#do_not_update[@]} )); then
nbp=${#do_not_update[*]}
echo -e "${underline}🌿 List of${reset} ${redbox} $nbp ${reset} ${underline}'do not update' packages:${reset}"
echo -e "${redbold}${do_not_update[*]}${reset}"
echo -e "To remove package from this list, you need to edit the ${italic}do_not_update${reset} array."
echo ""
fi
##################
# Local packages #
##################
@@ -203,21 +231,27 @@ if find "$local_path/node_modules" -mindepth 1 -maxdepth 1 | read; then
j=$(echo "$current" | awk -F "." '{print $1}')
k=$(echo "$latest" | awk -F "." '{print $1}')
# Update major version 1.x.y to 2.x.y
if [ $current = $wanted ] && [ "$j" -lt "$k" ]; then
if [ "$no_distract" = false ]; then
echo "$package@latest" | xargs -p npm install
if [[ ! " ${do_not_update[@]} " =~ " ${package} " ]]; then
# Update major version 1.x.y to 2.x.y
if [ $current = $wanted ] && [ "$j" -lt "$k" ]; then
if [ "$no_distract" = false ]; then
echo "$package@latest" | xargs -p npm install
else
echo "$package@latest" | xargs npm install
#npm install "$package@latest"
fi
# Update minor or patch version
else
echo "$package@latest" | xargs npm install
#npm install "$package@latest"
fi
# Update minor or patch version
else
if [ "$no_distract" = false ]; then
echo "$package" | xargs -p npm update
else
echo "$package" | xargs npm update
if [ "$no_distract" = false ]; then
echo "$package" | xargs -p npm update
else
echo "$package" | xargs npm update
fi
fi
else
echo -e "${redbold}$package is pinned to version $current !${reset} Don't update !"
fi
done <<< "$outdated"
@@ -287,20 +321,28 @@ if [ -n "$glong_outdated" ]; then
while IFS= read -r line
do
pkg=$(echo "$line" | awk '{print $1}')
curr=$(echo "$line" | awk '{print $2}')
vers=$(echo "$line" | awk '{print $4}')
outdated="$pkg@$vers"
# TEST
#version=$(echo "$line" | awk '{print $1 "@" $4}')
#echo "$version"
# /test
if [ "$no_distract" = false ]; then
echo "$outdated" | xargs -p -n 1 npm --location=global install
echo ""
if [[ ! " ${do_not_update[@]} " =~ " ${pkg} " ]]; then
# TEST
#version=$(echo "$line" | awk '{print $1 "@" $4}')
#echo "$version"
# /test
if [ "$no_distract" = false ]; then
echo "$outdated" | xargs -p -n 1 npm --location=global install
echo ""
else
echo "$outdated" | xargs -n 1 npm --location=global install
echo ""
fi
else
echo "$outdated" | xargs -n 1 npm --location=global install
echo ""
echo -e "${redbold}$pkg is pinned to version $curr !${reset} Don't update !"
fi
done <<< "$glong_outdated"

View File

@@ -79,8 +79,8 @@ version=$(php --info | grep 'PHP Version' | sed -n '1p' | awk -F" " '{print $NF}
v=${version:0:3}
echo -e "${ita_under}${blue}Current PHP version:${reset} ${bold}$version${reset}\n"
latest="8.0"
versions=("7.2" "7.3" "7.4" "8.1" "$latest")
latest="8.2"
versions=("7.4" "8.0" "8.1" "8.3" "$latest")
php_installed=$(ls -1 $(brew --prefix)/opt/ | grep php@)
echo -e "${ita_under}${blue}Installed PHP versions:${reset}"
echo -e "$php_installed\n"
@@ -94,6 +94,12 @@ fi
pecl version
curl -Is http://www.google.com | head -1 | grep 200
if [[ $? -eq 1 ]]; then
echo -e "\n${red}No Internet connection !${reset}"
echo -e "Exit !"
exit 1
fi
# Note that all public channels can be synced using "update-channels"
echo -e "\n${ita_under}${blue}Updating all channels...${reset}"

View File

@@ -16,6 +16,20 @@ display_info=true
# Also add module for prevent to update it.
declare -a do_not_update=('')
italic="\033[3m"
underline="\033[4m"
ita_under="\033[3;4m"
bgd="\033[1;4;31m"
red="\033[1;31m"
bold="\033[1m"
bold_ita="\033[1;3m"
box="\033[1;41m"
redbold="\033[1;31m"
redbox="\033[1;41m"
reset="\033[0m"
echo -e "${bold}🐪 Perl ${reset}"
echo
perl_app=$(which perl)
perl_v=$(perl -v | sed -n '2p')
@@ -42,10 +56,17 @@ else
install_ok=true
fi
curl -Is http://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 !"
exit 1
fi
if [ "$install_ok" == "true" ]; then
echo "$module installed"
# install with cpan
# install with cpan
# % cpan-outdated | xargs cpan -i
# install with cpanm

View File

@@ -33,7 +33,7 @@ user=""
# Add module to the do_not_update array for prevent to update.
#declare -a do_not_update=()
#declare -a do_not_update=("parso" "asgiref")
declare -a do_not_update=("charset-normalizer")
declare -a do_not_update=("geomet")
#
#########################################
@@ -78,6 +78,13 @@ if (( ${#do_not_update[@]} )); then
fi
curl -Is http://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 !"
exit 1
fi
#Packages update
echo -e "🐍 ${underline}Search for packages update...${reset}\n"
@@ -126,10 +133,12 @@ if [ -n "$upd" ]; then
dependencies=$(echo "$x" | xargs pipdeptree -r -p | grep -E $y)
echo -e ""
while IFS= read -r line; do
z=$(echo "${line}" | grep -i ^[a-z])
k=$(echo "${line}" | awk -F'==' '{print $1}')
l=$(echo "${line}" | awk -F':' '{print $2}')
k=$(echo "${line}" | awk -F'==' '{print $1}')
l=$(echo "${line}" | awk -F':' '{print $2}')
# Si la ligne commence par une lettre (aka. paquet à mettre à jour)
if [ -n "$z" ] ; then

View File

@@ -36,10 +36,17 @@ then
exit
fi
list=$(pipx list --include-injected)
list=$(pipx list --include-injected) # pipx list --quiet
echo -e "\n${underline}List installed packages:${reset}"
echo "$list"
curl -Is http://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 !"
exit 1
fi
pipx-outdated() {
echo -e "\n${underline}Outdated Packages:${reset}"
while read -sr pyPkgName pyPkyVersion; do

50
plugins.d/rustup.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
italic="\033[3m"
underline="\033[4m"
ita_under="\033[3;4m"
bgd="\033[1;4;31m"
red="\033[1;31m"
bold="\033[1m"
box="\033[1;41m"
reset="\033[0m"
echo -e "\n${bold}🦀 Rust${reset}\n"
curl -Is http://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 !"
exit 1
fi
if hash rustup 2>/dev/null; then
echo -e "🦀 ${underline}rustup check${reset}\n"
rustup check
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
echo ""
fi
if hash cargo 2>/dev/null; then
echo -e "\n🦀 ${underline}Update cargo packages !${reset}\n"
if hash ggrep 2>/dev/null; then
cargo install $(cargo install --list | ggrep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ')
else
cargo install $(cargo install --list | egrep '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ')
fi
echo ""
fi
echo ""

View File

@@ -18,7 +18,7 @@ reset="\033[0m"
# Liste des apps:
# - le venv doit avoir le même nom que l'app
declare -a apps=("soco-cli" "mkdocs")
declare -a apps=("soco-cli" "mkdocs" "streamrip")
# Liste des extensions pour Mkdocs
mkdocs_ext=("mkdocs-material" "mkdocs-material-extensions" "mkdocs-git-revision-date-localized-plugin" "mkdocs-minify-plugin" "fontawesome_markdown" "mkdocs-pdf-export-plugin")
@@ -40,8 +40,15 @@ elif [[ "$OSTYPE" == "linux_gnu" ]]; then
elif [[ "$OSTYPE" == "linux_gnueabihf" ]]; then
v=$HOME/venv
fi
#
###############################################################################################
curl -Is http://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 !"
exit 1
fi
################################################################################################
for app in ${apps[*]}
do