... | ... |
@@ -120,3 +120,24 @@ function piwigo_private () { |
120 | 120 |
_turn 20 || return |
121 | 121 |
test "$(curl --silent 'http://192.168.0.71/photos/ws.php?format=json&method=pwg.categories.getList' | sum)" = "00569 1" || echo "albums visibles publiquement" |
122 | 122 |
} |
123 |
+ |
|
124 |
+function snappymail_version () { |
|
125 |
+ _turn 24 || return |
|
126 |
+ local installed_version=$(</var/www/rainloop/data/VERSION) |
|
127 |
+ local release_url='https://api.github.com/repos/the-djmaze/snappymail/releases/latest' |
|
128 |
+ local version=$(curl -sL -H "Accept: application/vnd.github+json" $release_url | jq -r '.name | ltrimstr("v")') |
|
129 |
+ if test $version != $installed_version; then |
|
130 |
+ echo "nouvelle version dispo: $version" |
|
131 |
+ fi |
|
132 |
+} |
|
133 |
+ |
|
134 |
+function navidrome_version () { |
|
135 |
+ _turn 24 || return |
|
136 |
+ local installed_version=$(find ~navidrome/navidrome -printf "%C@") |
|
137 |
+ local release_url='https://api.github.com/repos/navidrome/navidrome/releases/latest' |
|
138 |
+ local version=$(curl -sL -H "Accept: application/vnd.github+json" $release_url \ |
|
139 |
+ | jq -r '.assets | .[] | select(.name | contains("linux_armv7")) | .updated_at | fromdateiso8601') |
|
140 |
+ if test $version -gt ${installed_version%.*}; then |
|
141 |
+ echo "nouvelle version dispo" |
|
142 |
+ fi |
|
143 |
+} |
... | ... |
@@ -46,8 +46,8 @@ function help (rc) { |
46 | 46 |
if (/^#help:BEGIN/) help_started = 1 |
47 | 47 |
if (/^#help:END/) help_started = 0 |
48 | 48 |
if (help_started) { |
49 |
- if (/^[[:blank:]]*case \/\^(.+)\$\/[[:blank:]]*\:[[:blank:]]*$/) { |
|
50 |
- option = gensub(/^[[:blank:]]*case \/\^(.+)\$\/[[:blank:]]*\:[[:blank:]]*$/, "\\1", "1") |
|
49 |
+ if (/^[[:blank:]]*case \/\^(.+)\$\/[[:blank:]]*:[[:blank:]]*$/) { |
|
50 |
+ option = gensub(/^[[:blank:]]*case \/\^(.+)\$\/[[:blank:]]*:[[:blank:]]*$/, "\\1", "1") |
|
51 | 51 |
line = line "\n\n\033[1m" option "\033[0m" |
52 | 52 |
} |
53 | 53 |
else if (/^#help:/ && option != "") { |
... | ... |
@@ -47,7 +47,7 @@ if ! which convert > /dev/null; then |
47 | 47 |
exit 1 |
48 | 48 |
fi |
49 | 49 |
|
50 |
-sqlcmd="select path from ${dbprefix}images |
|
50 |
+sqlcmd="select distinct path from ${dbprefix}images |
|
51 | 51 |
where id in ( |
52 | 52 |
select distinct image_id from ${dbprefix}image_category |
53 | 53 |
where category_id in ( |
... | ... |
@@ -55,35 +55,57 @@ sqlcmd="select path from ${dbprefix}images |
55 | 55 |
) |
56 | 56 |
)" |
57 | 57 |
|
58 |
-IFS=$'\n' |
|
59 |
-for file in $(mysql -N -u $dbuser -p${dbpasswd} $dbname <<< $sqlcmd); do |
|
60 |
- format="" |
|
61 |
- fnNoExt="${file%.*}" |
|
62 |
- fnExt="${file##*.}" |
|
63 |
- fnPath="${file%/*}" |
|
64 |
- test $fnExt = 'mp4' && continue |
|
65 |
- cmd="sudo -u www-data convert \"$site/$file\" -write mpr:image +delete " |
|
66 |
- count=0 |
|
67 |
- for size in ${!imgsize[@]}; do |
|
68 |
- if ! test -e "${destDir}/${fnNoExt}-${size:0:2}.$fnExt" -a -z "$FORCE"; then |
|
69 |
- format+="$size " |
|
70 |
- cmd+="mpr:image -filter Lanczos -auto-orient -strip -quality 95 -interlace line -sampling-factor 4:2:2 " |
|
71 |
- cmd+="-resize ${width[$size]}x${height[$size]} -write \"${destDir}/${fnNoExt}-${size:0:2}.$fnExt\" +delete " |
|
72 |
- let count++ |
|
73 |
- fi |
|
58 |
+function get_ext_fn () { |
|
59 |
+ fnNoExt="${1%.*}" |
|
60 |
+ fnExt="${1##*.}" |
|
61 |
+ fnPath="${1%/*}" |
|
62 |
+} |
|
63 |
+ |
|
64 |
+function get_formats () { |
|
65 |
+ local IFS=$'\n' |
|
66 |
+ for file in $(mysql -N -u $dbuser -p${dbpasswd} $dbname <<< $sqlcmd); do |
|
67 |
+ get_ext_fn "$file" |
|
68 |
+ test $fnExt = 'mp4' && continue |
|
69 |
+ for size in ${!imgsize[@]}; do |
|
70 |
+ if ! test -e "${destDir}/${fnNoExt}-${size:0:2}.$fnExt" -a -z "$FORCE"; then |
|
71 |
+ formats[$file]+="$size " |
|
72 |
+ let total_ext++ |
|
73 |
+ fi |
|
74 |
+ done |
|
74 | 75 |
done |
75 |
- if test -n "$format"; then |
|
76 |
- echo "$site/$file : $format" |
|
77 |
- if test -n "$LIST"; then |
|
78 |
- continue |
|
79 |
- fi |
|
80 |
- echo -n "please wait... " |
|
81 |
- cmd=$(sed -r 's/^(.+) -write (.*) \+delete $/\1 \2/' <<< $cmd) |
|
82 |
- eval $(echo -e nice -20 $cmd) |
|
76 |
+} |
|
77 |
+ |
|
78 |
+function calc_left () { |
|
79 |
+ local format=(${formats[$file]}) |
|
80 |
+ unset formats[$file] |
|
81 |
+ total_ext=$(( $total_ext - ${#format[@]} )) |
|
82 |
+} |
|
83 |
+ |
|
84 |
+declare -A formats |
|
85 |
+get_formats |
|
86 |
+ |
|
87 |
+if test -n "$LIST"; then |
|
88 |
+ for file in ${!formats[@]}; do |
|
89 |
+ echo "[${#formats[@]}/$total_ext] $file : ${formats[$file]}" |
|
90 |
+ calc_left |
|
91 |
+ done |
|
92 |
+else |
|
93 |
+ for file in ${!formats[@]}; do |
|
94 |
+ unset cmd sleep_duration |
|
95 |
+ get_ext_fn "$file" |
|
96 |
+ for size in ${formats[$file]}; do |
|
97 |
+ cmd+=(mpr:image -resize ${width[$size]}x${height[$size]} -write "${destDir}/${fnNoExt}-${size:0:2}.$fnExt" +delete) |
|
98 |
+ let sleep_duration++ |
|
99 |
+ done |
|
100 |
+ printf "\r\033[K[${#formats[@]}/$total_ext] $file : ${formats[$file]}" |
|
101 |
+ cmd[-1]="null:" |
|
102 |
+ sudo -u www-data nice -20 convert \ |
|
103 |
+ -filter Lanczos -strip -auto-orient -quality 95 -interlace line -sampling-factor 4:2:2 \ |
|
104 |
+ "$site/$file" +write ${cmd[@]} |
|
83 | 105 |
for size in ${!imgsize[@]}; do |
84 |
- test -s "${destDir}/${fnNoExt}-${size:0:2}.$fnExt" || echo "missing extension ${size:0:2}.$fnExt" |
|
106 |
+ test -s "${destDir}/${fnNoExt}-${size:0:2}.$fnExt" || echo -e "\nmissing extension ${size:0:2}.$fnExt" |
|
85 | 107 |
done |
86 |
- echo "done, sleeping..." |
|
87 |
- sleep $(( 2 + $count )) |
|
88 |
- fi |
|
89 |
-done |
|
108 |
+ sleep $sleep_duration |
|
109 |
+ calc_left |
|
110 |
+ done |
|
111 |
+fi |