maj des chemins

This commit is contained in:
Jephte CLAIN 2014-07-07 22:06:38 +04:00
parent ee78740382
commit 4100152139
94 changed files with 545 additions and 402 deletions

View File

@ -3,10 +3,10 @@
gendefault
etitle "Documentation de ulib"
array_from_lines ulibnames "$(list_files ulib)"
array_from_lines ulibnames "$(list_files lib/ulib)"
# faire les pages
for ulibname in "${ulibnames[@]}"; do
awkrun <"ulib/$ulibname" 'BEGIN {
awkrun <"lib/ulib/$ulibname" 'BEGIN {
in_func = 0
dump_doc = 0
dumped_doc = 0

2
.udir
View File

@ -6,7 +6,7 @@ udir_note=""
udir_types=("uinst")
uinc=true
uinc_options=()
uinc_args=(ucrontab reptyr.cgo ulib/ulibsh ulib/support/install-pubkeys.sh lib/uinst/system_caps.legacy)
uinc_args=(ucrontab reptyr.cgo lib/ulib/ulibsh lib/ulib/support/install-pubkeys.sh lib/uinst/system_caps.legacy)
# Faut-il désinstaller les fichiers de configuration de utools?
uninst_utools=

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS service
function display_help() {
uecho "$scriptname: s'assurer que les services sont lancés pour un type de virtualisation
@ -10,10 +12,6 @@ USAGE
Les types supportés sont virtualbox et kvm (par défaut)"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS service ||
exit 1
function ensure_kvm() {
# S'assurer que les modules VirtualBox sont déchargés et que les modules kvm
# sont chargés, et que le service libvirt-bin est démarré

6
SKvm
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS virsh
function display_help() {
uecho "$scriptname: lancer une machine virtuelle kvm
@ -34,10 +36,6 @@ OPTIONS
Afficher le gestionnaire de machines virtuelle"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS virsh ||
exit 1
function build_arrays() {
# Construire les listes avms, rvms, svms
# rvms: les vms qui tournent

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: lancer une machine virtuelle VirtualBox
@ -23,10 +25,6 @@ OPTIONS
-g Afficher le gestionnaire de machines virtuelle"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
function build_arrays() {
# Construire les listes avms, rvms, svms
# rvms: les vms qui tournent

6
_root
View File

@ -1,15 +1,13 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire base
function display_help() {
uecho "$scriptname: devenir l'utilisateur root, avec 'sudo' si possible, ou 'su' si
'sudo' n'est pas installé"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire base ||
exit 1
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
@ args -- "$@" && set -- "${args[@]}" || die "$args"

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Se connecter sur un site FTP authentifié
@ -30,10 +32,6 @@ façon dont le proxy ftp est configuré, il n'est pas possible de se connecter
avec un mot de passe qui contient le caractère @"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
AUTHFTP_PROXY_DISABLED=1 # par défaut, ne pas utiliser le proxy
set_defaults proxy
set_defaults authftp

2
bashrc
View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
function uprovide() { :; }
source @@dest@@/ulib/uenv || return
source @@dest@@/lib/ulib/uenv || return
__uenv_source_dirs @@dest@@/bashrc.d "$HOME/etc/bashrc.d"
__uenv_cleanup

6
caturl
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Afficher une url
@ -8,10 +10,6 @@ USAGE
$scriptname <file.url|file.desktop|URL>"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
@ args -- "$@" && set -- "${args[@]}" || die "$args"

2
cssh
View File

@ -1,6 +1,6 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {

View File

@ -1,13 +1,9 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/../ulib/ulib" &&
urequire DEFAULTS ||
exit 1
OENC="$UTF8"
source "$(dirname "$0")/../lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
local OENC="$UTF8"
uecho "$scriptname: Mettre à jour la documentation pour les outils de nutools
USAGE
@ -93,7 +89,7 @@ $("$cmd" --help)
fi
if [ -n "$ulib" ]; then
array_from_lines ulibnames "$(list_files ../ulib)"
array_from_lines ulibnames "$(list_files ../lib/ulib)"
# faire l'entête
dump_content ulib.twp "$oldcontent"
echo "
@ -104,7 +100,7 @@ if [ -n "$ulib" ]; then
write_twpage "$oldcontent" ulib "$newcontent" ulib.twp
# faire les pages
for ulibname in "${ulibnames[@]}"; do
ulib="../ulib/$ulibname"
ulib="../lib/ulib/$ulibname"
twpage="ulib_$ulibname.twp"
title="ulib/$ulibname"
dump_content "$twpage" "$oldcontent"

View File

@ -43,9 +43,8 @@ if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
exit 0
fi
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
# Traduire le nom du script
for script_alias in "${SCRIPT_ALIASES[@]}"; do

5
fconv
View File

@ -30,9 +30,8 @@ if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
exit 0
fi
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
from=detect
case "${scriptname#fconv2}" in

5
fnconv
View File

@ -28,9 +28,8 @@ if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
exit 0
fi
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
from=detect
case "${scriptname#fnconv2}" in

6
geturl
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Télécharger un fichier avec wget ou curl
@ -8,10 +10,6 @@ USAGE
$scriptname <file.url|file.desktop|URL> [wget options]"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
parse_opts + "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
@ args -- "$@" && set -- "${args[@]}" || die "$args"

View File

@ -7,7 +7,7 @@ if [ -n "$UTOOLS_BASH_COMPLETION" ]; then
6*|squeeze*)
# le code suivant n'est compatible qu'avec debian squeeze
if [ -z "$BASH_COMPLETION" -a "${BASH_VERSINFO[0]}" -ge 4 ]; then
source "@@dest@@/ulib/bash_completion"
source "@@dest@@/lib/ulib/bash_completion"
fi
if [ -n "$BASH_COMPLETION" ]; then
if [ -n "$BASH_COMPLETION_DIR" -a -f "$BASH_COMPLETION_DIR/ssh" ]; then

View File

@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
. "$(dirname "$0")/../../ulib/ulib" && urequire DEFAULTS || exit 1
. "$(dirname "$0")/../../lib/ulib/ulib" || exit 1
urequire DEFAULTS
check_sysinfos -s linux -d debian || exit 0
run_as_root "$@"

View File

@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
. "$(dirname "$0")/../../ulib/ulib" && urequire DEFAULTS || exit 1
. "$(dirname "$0")/../../lib/ulib/ulib" || exit 1
urequire DEFAULTS
check_sysinfos -s linux -d debian || exit 0
run_as_root "$@"

View File

@ -1,11 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/../ulib/ulib" &&
urequire DEFAULTS ||
exit 1
OENC="$UTF8"
MAKESELFDIR="$scriptdir/makeself-2.1.5"
source "$(dirname "$0")/../lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Créer une archive auto-extractible qui installe nutools
@ -22,6 +18,8 @@ OPTIONS
s'auto-détruit après utilisation."
}
MAKESELFDIR="$scriptdir/makeself-2.1.5"
mode=755
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \

View File

@ -6,7 +6,7 @@
# gourmandes en resources.
# Au 18/06/2013, cela ne concerne que les scripts/fichiers suivants:
# - lib/profile.d/bash_prompt
# - ulib/vcs {git_commit}
# - lib/ulib/vcs {git_commit}
: "${UTOOLS_AUTO:=1}" "${UTOOLS_NOPUSH:=}"
export UTOOLS_AUTO UTOOLS_NOPUSH

View File

@ -17,5 +17,5 @@ else
nutoolsdir="$(cd "$(dirname "$0")"; pwd)"
fi
source "$nutoolsdir/ulib/nutools/pyulib"
exec "$nutoolsdir/pyulib/src/uapps/$scriptname.py" "$@"
source "$nutoolsdir/lib/ulib/nutools/pyulib"
exec "$nutoolsdir/lib/pyulib/src/uapps/$scriptname.py" "$@"

View File

@ -1,6 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1; urequire DEFAULTS
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname:

View File

@ -23,10 +23,9 @@ if [ $# -eq 2 ]; then
fi
fi
#source /etc/ulib &&
source "$(dirname "$0")/../../ulib/ulib" &&
urequire DEFAULTS ||
exit 1
#source /etc/ulib || exit 1
source "$(dirname "$0")/../../ulib/ulib" || exit 1
urequire DEFAULTS
[ $# -eq 1 -a "$1" == "--help" ] && exit_with display_help

View File

@ -46,10 +46,9 @@ if [ $# -eq 2 ]; then
fi
fi
#source /etc/ulib &&
source "$(dirname "$0")/../../ulib/ulib" &&
urequire DEFAULTS ||
exit 1
#source /etc/ulib || exit 1
source "$(dirname "$0")/../../lib/ulib/ulib" || exit 1
urequire DEFAULTS
function check_overwrite() {
if [ -e "$1" -a -z "$overwrite" ]; then

View File

@ -46,10 +46,9 @@ if [ $# -eq 2 ]; then
fi
fi
#source /etc/ulib &&
source "$(dirname "$0")/../../ulib/ulib" &&
urequire DEFAULTS ||
exit 1
#source /etc/ulib || exit 1
source "$(dirname "$0")/../../lib/ulib/ulib" || exit 1
urequire DEFAULTS
function check_overwrite() {
if [ -e "$1" -a -z "$overwrite" ]; then

View File

@ -49,10 +49,9 @@ if [ $# -eq 2 ]; then
fi
fi
#source /etc/ulib &&
source "$(dirname "$0")/../../ulib/ulib" &&
urequire DEFAULTS ||
exit 1
#source /etc/ulib || exit 1
source "$(dirname "$0")/../../lib/ulib/ulib" || exit 1
urequire DEFAULTS
function check_overwrite() {
if [ -e "$1" -a -z "$overwrite" ]; then

View File

@ -53,7 +53,7 @@ if [ $# -eq 2 ]; then
fi
#source /etc/ulib || exit 1
source "$(dirname "$0")/../../ulib/ulib" || exit 1
source "$(dirname "$0")/../../lib/ulib/ulib" || exit 1
urequire DEFAULTS
set_defaults nutools

View File

@ -46,10 +46,9 @@ if [ $# -eq 2 ]; then
fi
fi
#source /etc/ulib &&
source "$(dirname "$0")/../../ulib/ulib" &&
urequire DEFAULTS ||
exit 1
#source /etc/ulib || exit 1
source "$(dirname "$0")/../../lib/ulib/ulib" || exit 1
urequire DEFAULTS
function check_overwrite() {
if [ -e "$1" -a -z "$overwrite" ]; then

View File

@ -46,10 +46,9 @@ if [ $# -eq 2 ]; then
fi
fi
#source /etc/ulib &&
source "$(dirname "$0")/../../ulib/ulib" &&
urequire DEFAULTS ||
exit 1
#source /etc/ulib || exit 1
source "$(dirname "$0")/../../lib/ulib/ulib" || exit 1
urequire DEFAULTS
function check_overwrite() {
if [ -e "$1" -a -z "$overwrite" ]; then

View File

@ -1,10 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/../../ulib/ulib" &&
urequire DEFAULTS tiddlywiki ||
exit 1
OENC="$UTF8"
source "$(dirname "$0")/../../lib/ulib/ulib" || exit 1
urequire DEFAULTS tiddlywiki
function display_help() {
echo "$scriptname: Télécharger la dernière version de TiddlyWiki"

View File

@ -1,7 +1,8 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$@" || exit 1
source "$ULIBDIR/ulib" && urequire DEFAULTS uenv uenv_update || exit 1
source "$ULIBDIR/ulib" || exit 1
urequire DEFAULTS uenv uenv_update
cd "$scriptdir/../.."
# supprimer les fichiers de VCS
@ -11,13 +12,13 @@ rm -rf .git
rm -f .nutools-devel
# supprimer fichiers de développement
rm -rf pyulib/{build,devel,migrate,test}
rm -rf lib/pyulib/{build,devel,migrate,test}
# liens pour les scripts python
for i in plver plbck uencdetect urandomize umail uxpath wofixsql; do
ln -s lib/pywrapper "$i"
done
ln -s ulib/support/cgiupload.py
ln -s lib/ulib/support/cgiupload.py
# liens pour les scripts shell
for i in cg cgs; do

View File

@ -1,24 +1,25 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$@" || exit 1
source "$ULIBDIR/ulib" && urequire DEFAULTS || exit 1
source "$ULIBDIR/ulib" || exit 1
urequire DEFAULTS
cd "$scriptdir/../../"
cd "$scriptdir/../.."
log=/tmp/nutools-pyulib-install.log
etitle -s "Installation des packages python"
enote "Le log de l'installation se trouve dans $log"
./uinst -y pyulib >&"$log"
./uinst -y lib/pyulib >&"$log"
eend
# setup.py laisse des fichiers avec les droits de root, et ces fichiers ne
# peuvent être supprimés par l'utilisateur qui lance uinst. Les supprimer ici.
rm -rf pyulib/build
rm -rf lib/pyulib/build
dest="@@dest@@"
for i in ulib ulibsh; do
sed "s|@@""dest""@@|$dest|g" "ulib/$i" >"/etc/$i"
sed "s|@@""dest""@@|$dest|g" "lib/ulib/$i" >"/etc/$i"
done
cp ulib/.ulib_version /etc/.ulib_version
cp lib/ulib/.ulib_version /etc/.ulib_version
echo >/etc/ulibauto '# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
if [ x"$BASH" != x -a -f /etc/ulib ]; then
. /etc/ulib

View File

@ -11,6 +11,11 @@ elif [ "$0" == "-bash" ]; then
scriptname=
scriptdir=
script=
elif [ ! -f "$0" -a -f "${0#-}" ]; then
scriptname="$(basename -- "${0#-}")"
scriptdir="$(dirname -- "${0#-}")"
scriptdir="$(cd "$scriptdir"; pwd)"
script="$scriptdir/$scriptname"
else
scriptname="$(basename -- "$0")"
scriptdir="$(dirname -- "$0")"

View File

@ -29,6 +29,79 @@ export TMPDIR="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}"
[ -f /etc/nutoolsrc ] && . /etc/nutoolsrc
[ -f ~/.nutoolsrc ] && . ~/.nutoolsrc
function recho() {
if [[ "${1:0:2}" == -[eEn] ]]; then
echo -n -
local first="${1:1}"; shift
echo "$first$@"
else
echo "$@"
fi
}
function recho_() {
if [[ "${1:0:2}" == -[eEn] ]]; then
echo -n -
local first="${1:1}"; shift
echo -n "$first$@"
else
echo -n "$@"
fi
}
function qval() {
local s="$*"
s="${s//\\/\\\\}"
s="${s//\"/\\\"}"
s="${s//\$/\\\$}"
s="${s//\`/\\\`}"
recho_ "$s"
}
function should_quote() {
[ -z "$1" ] && return 0
local s="${*//[a-zA-Z0-9]/}"
s="${s//,/}"
s="${s//./}"
s="${s//+/}"
s="${s//\//}"
s="${s//-/}"
s="${s//_/}"
s="${s//=/}"
[ -n "$s" ]
}
function qvals() {
local arg first=1
for arg in "$@"; do
[ -z "$first" ] && echo -n " "
if should_quote "$arg"; then
echo -n \"
qval "$arg"
echo -n \"
else
recho_ "$arg"
fi
first=
done
}
function qlines() {
sed "s/'/'\\\\''/g; s/.*/'&'/g"
}
function setv() {
local __s_var="$1"; shift
eval "$__s_var=\"$(qval "$*")\""
}
function setx() {
local __s_var="$1"; shift
eval "$__s_var=\"\$(\"\$@\")\""
}
function seta() {
local __s_array="$1"; shift
eval "$__s_array=($("$@" | qlines))"
}
function e2of() {
"$@" 2>&1
}
function nef() {
"$@" | sed '/^$/d'
}
function isnum() {
[ ${#1} -gt 0 ] || return 1
@ -53,14 +126,10 @@ function isrnum() {
[ -z "$v" ]
}
function is_yes() {
[ "$1" == "o" -o "$1" == "O" -o "$1" == "oui" -o "$1" == "OUI" ] && return 0
[ "$1" == "y" -o "$1" == "Y" -o "$1" == "yes" -o "$1" == "YES" ] && return 0
[ "$1" == "v" -o "$1" == "V" -o "$1" == "vrai" -o "$1" == "VRAI" ] && return 0
[ "$1" == "t" -o "$1" == "T" -o "$1" == "true" -o "$1" == "TRUE" ] && return 0
[ "$1" == "on" -o "$1" == "ON" ] && return 0
if isnum "$1"; then
[ "$1" -ne 0 ] && return 0
fi
case "${1,,}" in
o|oui|y|yes|v|vrai|t|true|on) return 0;;
esac
isnum "$1" && [ "$1" -ne 0 ] && return 0
return 1
}
function yesval() {
@ -79,14 +148,10 @@ function normyesvals() {
done
}
function is_no() {
[ "$1" == "n" -o "$1" == "N" -o "$1" == "non" -o "$1" == "NON" ] && return 0
[ "$1" == "no" -o "$1" == "NO" ] && return 0
[ "$1" == "f" -o "$1" == "F" -o "$1" == "faux" -o "$1" == "FAUX" ] && return 0
[ "$1" == "false" -o "$1" == "FALSE" ] && return 0
[ "$1" == "off" -o "$1" == "OFF" ] && return 0
if isnum "$1"; then
[ "$1" -eq 0 ] && return 0
fi
case "${1,,}" in
n|non|no|f|faux|false|off) return 0;;
esac
isnum "$1" && [ "$1" -eq 0 ] && return 0
return 1
}
function rawecho() {
@ -115,18 +180,6 @@ function quote_arg() {
s="${s//\`/\\\`}"
rawecho "$s"
}
function should_quote() {
[ -z "$1" ] && return 0
local s="${1//[a-zA-Z0-9]/}"
s="${s//,/}"
s="${s//./}"
s="${s//+/}"
s="${s//\//}"
s="${s//-/}"
s="${s//_/}"
s="${s//=/}"
[ -n "$s" ]
}
function quoted_arg() {
should_quote "$1" && echo "\"$(quote_arg "$1")\"" || quote_arg "$1"
}
@ -403,6 +456,18 @@ function array_fillrange() {
done
array_copy "$1" __af_vs
}
function array_eq() {
local -a __ae_a1 __ae_a2
array_copy __ae_a1 "$1"
array_copy __ae_a2 "$2"
[ ${#__ae_a1[*]} -eq ${#__ae_a2[*]} ] || return 1
local __ae_v __ae_i=0
for __ae_v in "${__ae_a1[@]}"; do
[ "$__ae_v" == "${__ae_a2[$__ae_i]}" ] || return 1
__ae_i=$(($__ae_i + 1))
done
return 0
}
function array_contains() {
local __ac_v
eval 'for __ac_v in "${'"$1"'[@]}"; do
@ -512,14 +577,14 @@ function array_extend_lasts() {
eval "$1=(\"\${$1[@]}\" \"\${$2[@]:1}\")"
}
function array_xsplit() {
eval "$1=($(<<<"$2" stripnl | awkrun RS="${3:-:}" '
eval "$1=($(recho_ "$2" | awkrun RS="${3:-:}" '
{
gsub(/'\''/, "'\'\\\\\'\''")
print "'\''" $0 "'\''"
}'))" #"
}
function array_split() {
eval "$1=($(<<<"$2" stripnl | awkrun RS="${3:-:}" '
eval "$1=($(recho_ "$2" | awkrun RS="${3:-:}" '
/^$/ { next }
{
gsub(/'\''/, "'\'\\\\\'\''")
@ -530,14 +595,14 @@ function array_from_path() {
array_split "$1" "$2" ":"
}
function array_from_xlines() {
eval "$1=($(<<<"$2" _nl2lf | awk '
eval "$1=($(recho_ "$2" | _nl2lf | awk '
{
gsub(/'\''/, "'\'\\\\\'\''")
print "'\''" $0 "'\''"
}'))" #"
}
function array_from_lines() {
eval "$1=($(<<<"$2" _nl2lf | awk '
eval "$1=($(recho_ "$2" | _nl2lf | awk '
/^$/ { next }
{
gsub(/'\''/, "'\'\\\\\'\''")
@ -591,7 +656,7 @@ function array_fix_paths() {
array_copy __afp_vs "$__afp_an"
array_new "$__afp_an"
for __afp_v in "${__afp_vs[@]}"; do
array_split __afp_v "$__afp_v"
array_split __afp_v "$__afp_v" "$__afp_s"
array_extend "$__afp_an" __afp_v
done
}
@ -624,12 +689,9 @@ function parse_date() {
}')"
esac
case "$type" in
d|date)
awk '{ print strftime("%d/%m/%Y", $0 + 0) }' <<<"$value"
;;
l|ldap)
awk '{ print strftime("%Y%m%d%H%M%S+0400", $0 + 0) }' <<<"$value"
;;
d|date) awk '{ print strftime("%d/%m/%Y", $0 + 0) }' <<<"$value";;
l|ldap) awk '{ print strftime("%Y%m%d%H%M%S+0400", $0 + 0) }' <<<"$value";;
m|mysql) awk '{ print strftime("%Y-%m-%d", $0 + 0) }' <<<"$value";;
*)
rawecho "$value"
;;
@ -899,6 +961,13 @@ function testsame() {
function testdiff() {
! quietdiff "$@"
}
function testupdated() {
if [ -f "$2" ]; then
testdiff "$1" "$2"
else
return 0
fi
}
function testnewer() {
test ! -e "$2" -o "$1" -nt "$2"
}
@ -989,15 +1058,16 @@ function rm_maybe() {
done
[ -n "$rm" ] && /bin/rm "$@"
}
__CPDIR_RSYNC_ARGS=()
__CPDIR_RSYNC_SLOW=1 # synchro potentiellement plus lente, mais plus fidèle (option -c)
__CPDIR_RSYNC_ARGS=(-q)
function cpdir() {
if progexists rsync; then
[ -d "$2" ] || mkdir -p "$2" || return 1
if [ -d "$1" ]; then
rsync -qa "${__CPDIR_RSYNC_ARGS[@]}" "$1/" "$2/"
rsync -a ${__CPDIR_RSYNC_SLOW:+-c} "${__CPDIR_RSYNC_ARGS[@]}" "$1/" "$2/"
else
rsync -qa "${__CPDIR_RSYNC_ARGS[@]}" "$1" "$2/"
rsync -a ${__CPDIR_RSYNC_SLOW:+-c} "${__CPDIR_RSYNC_ARGS[@]}" "$1" "$2/"
fi
else
__cpdir "$@"
@ -1033,17 +1103,17 @@ function __cpdir() {
fi
fi
}
CPNOVCS_OPTS=() # deprecated
__CPNOVCS_RSYNC_ARGS=()
__CPNOVCS_RSYNC_SLOW=1 # synchro potentiellement plus lente, mais plus fidèle (option -c)
__CPNOVCS_RSYNC_ARGS=(-q)
function cpnovcs() {
local src="$1" destdir="$2"
[ -d "$destdir" ] || mkdir -p "$destdir" || return 1
if progexists rsync; then
local gitexclude=/.git/
if [ "${src%/}" != "$src" ]; then
if [ "${src%/}" == "$src" ]; then
gitexclude="/$(basename -- "$src")$gitexclude"
fi
rsync -qa --exclude CVS --exclude .svn --exclude "$gitexclude" "${CPNOVCS_OPTS[@]}" "${__CPNOVCS_RSYNC_ARGS[@]}" "$src" "$destdir/"
rsync -a ${__CPNOVCS_RSYNC_SLOW:+-c} --exclude CVS/ --exclude .svn/ --exclude "$gitexclude" "${__CPNOVCS_RSYNC_ARGS[@]}" "$src" "$destdir/"
elif [ "${src%/}" != "$src" ]; then
__cpdir "$src" "$destdir"
else
@ -1271,11 +1341,25 @@ function get_archive_appname() {
print substr($0, 1, RSTART - 1)
} else if (match($0, /([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/)) {
print substr($0, 1, RSTART - 1)
} else if (match($0, /([0-9]+[a-z][a-z][a-z0-9]?)$/, vs)) {
print substr($0, 1, RSTART - 1)
} else {
print $0
}
}'
}
function get_archive_versionsuffix() {
local basename="$(get_archive_basename "$1")"
echo "$basename" | awk '{
if (match($0, /([-_.][0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) {
print vs["1"]
} else if (match($0, /([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) {
print vs["1"]
} else if (match($0, /([0-9]+[a-z][a-z][a-z0-9]?)$/, vs)) {
print vs["1"]
}
}'
}
function get_archive_version() {
local basename="$(get_archive_basename "$1")"
echo "$basename" | awk '{
@ -1283,7 +1367,7 @@ function get_archive_version() {
print vs["1"]
} else if (match($0, /([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) {
print vs["1"]
} else if (match($0, /([0-9]+[a-z][a-z][a-z]?)$/, vs)) {
} else if (match($0, /([0-9]+[a-z][a-z][a-z0-9]?)$/, vs)) {
print vs["1"]
}
}'
@ -1504,6 +1588,13 @@ function quote_sql(s) {'"
gsub(/'/, \"''\", s)
return \"'\" s \"'\"
"'}
function unquote_mysqlcsv(s) {
gsub(/\\n/, "\n", s)
gsub(/\\t/, "\t", s)
gsub(/\\0/, "\0", s)
gsub(/\\\\/, "\\", s)
return s
}
function array_new(dest) {
dest[0] = 0 # forcer awk à considérer dest comme un tableau
delete dest
@ -1807,7 +1898,7 @@ function array_formatcsv2(fields, colsep, mvsep, qchar, echar, count, indic
if (echar != "") gsub(qchar, quote_subrepl(echar) "&", value);
else gsub(qchar, "&&", value);
}
if (qchar != "" && (index(value, mvsep) != 0 || index(value, colsep) != 0 || __csv_should_quote(value))) {
if (qchar != "" && (index(value, mvsep) != 0 || index(value, colsep) != 0 || index(value, qchar) != 0 || __csv_should_quote(value))) {
line = line qchar value qchar
} else {
line = line value
@ -1981,12 +2072,12 @@ function awkdef() {
}
function lawkrun() {
local -a __ar_defs __ar_args
while [ -n "$1" -a "$1" != "--" ]; do
while [ $# -gt 0 -a "$1" != "--" ]; do
__ar_defs=("${__ar_defs[@]}" "$1")
shift
done
shift
while [ -n "$1" ]; do
while [ $# -gt 0 ]; do
__ar_args=("${__ar_args[@]}" "$1")
shift
done
@ -2341,6 +2432,13 @@ function pidfile_check() {
fi
return 1
}
function page_maybe() {
if isatty; then
less -XF
else
cat
fi
}
function utools_local() {
@ -2638,6 +2736,29 @@ function eecho_() {
function edebug() {
show_debug || return; eflush; __edebug "$*" 1>&2
}
function trace() {
local r cmd="$(quoted_args "$@")"
show_info && { eflush; __eecho "\$ $cmd" 1>&2; }
"$@"; r=$?
if [ $r -ne 0 ]; then
if show_info; then
eflush; __eecho "^ [EC #$r]" 1>&2
elif show_error; then
eflush; __eecho "^ $cmd [EC #$r]" 1>&2;
fi
fi
return $r
}
function trace_error() {
local r
"$@"; r=$?
if [ $r -ne 0 ]; then
local cmd="$(quoted_args "$@")"
show_error && { eflush; __eecho "^ $cmd [EC #$r]" 1>&2; }
fi
return $r
}
function etitle() {
local __t_deferred=
__t_etitle "$@"

View File

@ -3,8 +3,8 @@
# charger le fichier de configuration $1 pour avoir ULIBDIR
source "$1" || exit 1
source "$ULIBDIR/ulib" && urequire DEFAULTS uinst || exit 1
OENC="$UTF8"
source "$ULIBDIR/ulib" || exit 1
urequire DEFAULTS uinst
is_root || die "Ce script doit être lancé avec les droits de root"

View File

@ -3,8 +3,8 @@
# charger le fichier de configuration $1 pour avoir ULIBDIR
source "$1" || exit 1
source "$ULIBDIR/ulib" && urequire DEFAULTS uinst || exit 1
OENC="$UTF8"
source "$ULIBDIR/ulib" || exit 1
urequire DEFAULTS uinst
is_root || die "Ce script doit être lancé avec les droits de root"

View File

@ -2,10 +2,8 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$1" || exit 1 # pour avoir la définition de ULIBDIR
source "$ULIBDIR/ulib" &&
urequire DEFAULTS prefixes apache webobjects wosign ||
exit 1
OENC="$UTF8"
source "$ULIBDIR/ulib" || exit 1
urequire DEFAULTS prefixes apache webobjects wosign
is_root || die "Ce script doit être lancé avec les droits de root"

View File

@ -8,7 +8,8 @@
# Ensuite, des librairies individuelles de ulib peuvent être chargées avec la
# fonction urequire(), e.g.
# source /etc/ulib && urequire DEFAULTS conf || exit 1
# source /etc/ulib || exit 1
# urequire DEFAULTS conf
# 'DEFAULTS' permet de charger base, pretty, sysinfos et compat.
function eerror() { echo "error: $*" 1>&2; }
@ -18,9 +19,9 @@ function die() { [ -n "$*" ] && eerror "$*"; exit 1; }
# il est possible de forcer la valeur de ULIBDIR avec FORCED_ULIBDIR. ceci est
# utile avec bash 2.x qui ne supporte pas la variable BASH_SOURCE
ULIBDIR="${FORCED_ULIBDIR:-@@dest@@/ulib}"
ULIBDIR="${FORCED_ULIBDIR:-@@dest@@/lib/ulib}"
if [ "$ULIBDIR" = "@@""dest""@@/ulib" ]; then
if [ "$ULIBDIR" = "@@""dest""@@/lib/ulib" ]; then
# La valeur "@@"dest"@@" n'est remplacée que dans la copie de ce script
# faite dans /etc. Sinon, il faut toujours faire le calcul. Cela permet de
# déplacer la librairie n'importe ou sur le disque, ce qui est

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Gestion de la version de ulib
@ -19,10 +21,6 @@ OPTIONS
juste tester la version et ne pas afficher le message d'information."
}
source "$(dirname "$0")/ulib" &&
urequire DEFAULTS ||
exit 1
action=show
version=0
set_version=

View File

@ -24,9 +24,9 @@ function eerror() { echo "error: $*" 1>&2; }
function die() { [ -n "$*" ] && eerror "$*"; exit 1; }
ULIBDIR="${FORCED_ULIBDIR:-@@dest@@/ulib}"
ULIBDIR="${FORCED_ULIBDIR:-@@dest@@/lib/ulib}"
if [ "$ULIBDIR" = "@@""dest""@@/ulib" ]; then
if [ "$ULIBDIR" = "@@""dest""@@/lib/ulib" ]; then
ULIBDIR="${BASH_SOURCE[0]}"
if [ -n "$ULIBDIR" -a -f "$ULIBDIR" ]; then
ULIBDIR="$(dirname "$ULIBDIR")"

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS awk
function display_help() {
uecho "$scriptname: Outils pour gérer une installation de MediaWiki
@ -42,10 +44,6 @@ if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
exit 0
fi
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS awk ||
exit 1
# Traduire le nom du script
for script_alias in "${SCRIPT_ALIASES[@]}"; do
splitpair "$script_alias" src dest

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Créer un fichier de redirections pour Apache à partir d'un certain
@ -80,10 +82,6 @@ Dans les exemples donnés ci-dessus, $URL est l'\''url générée par la réécr
et $proxy_acls la valeur du champ proxy_acls spécifiée ci-dessus.'
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
proxy_enabled=
infile=
outfile="RewriteRules.conf"

6
mkiso
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: créer une image iso d'un répertoire
@ -12,10 +14,6 @@ OPTIONS
créer une image hybride ISO/HFS"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
hfsmode=
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \

6
mkurl
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Enregistrer une url dans un fichier raccourci
@ -14,10 +16,6 @@ raccourci utilisable aussi sous Windows, ou avec l'extension .desktop pour
compatibilité avec le standard XDG"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
@ args -- "$@" && set -- "${args[@]}" || die "$args"

6
mkusfx
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Créer une archive auto-extractible qui installe son contenu avec uinst
@ -29,10 +31,6 @@ OPTIONS
locale de ulib et uinst.sh"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
MAKESELFDIR="$scriptdir/lib/makeself-2.1.5"
sfxtype=uinst

6
mocifs
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Monter un partage Windows/Samba/CIFS
@ -24,10 +26,6 @@ OPTIONS
Spécifier les credentials à utiliser pour la connexion"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
if ! progexists mount.cifs; then
[ -x /sbin/mount.cifs ] || die "Ce script nécessite cifs-utils. Sur debian, vous pouvez l'installer avec la commande
sudo apt-get install cifs-utils"

6
modav
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Monter un répertoire sur un hôte distant avec davfs
@ -38,10 +40,6 @@ OPTIONS
mountpoint username password"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
if ! progexists mount.davfs; then
[ -x /usr/sbin/mount.davfs ] || die "Ce script nécessite davfs2. Sur debian, vous pouvez l'installer avec la commande
sudo apt-get install davfs2"

6
moiso
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Monter une image ISO
@ -18,10 +20,6 @@ OPTIONS
Forcer le démontage"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
action=auto
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \

2
mossh
View File

@ -1,6 +1,6 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Faire une requête MySQL et formater la sortie pour traitement avec awkcsv
@ -63,10 +65,6 @@ OPTIONS
arguments."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
host=
port=
user=

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS awk
function display_help() {
uecho "$scriptname: Charger une table MySQL avec un fichier csv
@ -82,8 +84,6 @@ OPTIONS
est quand même honoré."
}
source "$(dirname "$0")/ulib/ulib" || exit 1; urequire DEFAULTS awk
__AWK_MYSQLFUNCS='
function format_sqlvalue(value) {
if (value ~ /^[0-9]+$/) {

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Ouvrir une URL dans un navigateur
@ -8,10 +10,6 @@ USAGE
$scriptname <file.url|file.desktop|URL>"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
@ args -- "$@" && set -- "${args[@]}" || die "$args"

View File

@ -3,6 +3,6 @@
[ -z "$USER" -a -n "$LOGNAME" ] && export USER="$LOGNAME"
function uprovide() { :; }
source @@dest@@/ulib/uenv || return
source @@dest@@/lib/ulib/uenv || return
__uenv_source_dirs @@dest@@/profile.d "$HOME/etc/profile.d"
__uenv_cleanup

2
rruns
View File

@ -1,6 +1,6 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS runs
function display_help() {

2
ruinst
View File

@ -1,6 +1,6 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS nutools/pyulib
function display_help() {

6
runs
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS runs
function display_help() {
uecho "$scriptname: Lancer un script avec le protocole runs
@ -56,10 +58,6 @@ Gestion des scripts
-z Forcer la réinstallation des scripts qui se basent sur shouldrun/setdone"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS runs ||
exit 1
set_defaults runs
function runs_path_required() {

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS woinst
function display_help() {
uecho "$scriptname: Déploiement distant avec woinst
@ -32,10 +34,6 @@ OPTIONS
user@host, e.g -H user@host"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS woinst ||
exit 1
set_defaults pubkeys
action=deploy

6
twsync
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS udir tiddlywiki javaproperties
function display_help() {
uecho "$scriptname: synchroniser un répertoire de wiki avec un tiddlywiki
@ -33,10 +35,6 @@ OPTIONS
située dans $(ppath "$TEMPLATE")"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS udir tiddlywiki javaproperties ||
exit 1
TEMPLATE="$scriptdir/lib/tiddlywiki/empty.html"
function find_wikifile() {

3
uawk
View File

@ -12,7 +12,8 @@ if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
exit 0
fi
source "$(dirname "$0")/ulib/ulib" || exit 1; urequire DEFAULTS awk
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS awk
# si on lance le script uawk, donner la possibilité de choisir l'outil
if [ "$scriptname" == uawk ] && array_contains ALIASES "${1#l}"; then

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: faire une sauvegarde des fichiers
@ -18,10 +20,6 @@ OPTIONS
-H Arrêter la machine après une sauvegarde REUSSIE."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
action=getargs
profile=
HOMEDIR="$HOME"

6
ucalc
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Afficher une valeur dans plusieurs unités
@ -29,10 +31,6 @@ OPTIONS
en cylindres"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
unit=
ounit=
cyl=

6
uconf
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS conf
function display_help() {
local OENC="$UTF8"
@ -51,10 +53,6 @@ OPTIONS
automatiquement."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS conf ||
exit 1
action=enable
quoted=
type=auto

236
ucrontab
View File

@ -1,5 +1,10 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
#source "$(dirname "$0")/lib/ulib/ulib" || exit 1
#urequire DEFAULTS crontab
# Pour pouvoir être copié le cas échéant sur un hôte distant, la librairie ulib
# est inclue avec uinc à partir de lib/ulib. En mode développement, il faut
# replier les inclusions avec uinc -f et décommenter les lignes ci-dessus
function display_help() {
uecho "$scriptname: Ajouter/Supprimer une ligne dans crontab
@ -84,10 +89,6 @@ OPTIONS
Afficher simplement les modifications qui doivent être effectuées."
}
#source "$(dirname "$0")/ulib/ulib" &&
#urequire DEFAULTS crontab ||
#exit 1
DEFAULT_ADELAY=1
DEFAULT_GDELAY=15
@ -116,6 +117,79 @@ export TMPDIR="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}"
[ -f /etc/nutoolsrc ] && . /etc/nutoolsrc
[ -f ~/.nutoolsrc ] && . ~/.nutoolsrc
function recho() {
if [[ "${1:0:2}" == -[eEn] ]]; then
echo -n -
local first="${1:1}"; shift
echo "$first$@"
else
echo "$@"
fi
}
function recho_() {
if [[ "${1:0:2}" == -[eEn] ]]; then
echo -n -
local first="${1:1}"; shift
echo -n "$first$@"
else
echo -n "$@"
fi
}
function qval() {
local s="$*"
s="${s//\\/\\\\}"
s="${s//\"/\\\"}"
s="${s//\$/\\\$}"
s="${s//\`/\\\`}"
recho_ "$s"
}
function should_quote() {
[ -z "$1" ] && return 0
local s="${*//[a-zA-Z0-9]/}"
s="${s//,/}"
s="${s//./}"
s="${s//+/}"
s="${s//\//}"
s="${s//-/}"
s="${s//_/}"
s="${s//=/}"
[ -n "$s" ]
}
function qvals() {
local arg first=1
for arg in "$@"; do
[ -z "$first" ] && echo -n " "
if should_quote "$arg"; then
echo -n \"
qval "$arg"
echo -n \"
else
recho_ "$arg"
fi
first=
done
}
function qlines() {
sed "s/'/'\\\\''/g; s/.*/'&'/g"
}
function setv() {
local __s_var="$1"; shift
eval "$__s_var=\"$(qval "$*")\""
}
function setx() {
local __s_var="$1"; shift
eval "$__s_var=\"\$(\"\$@\")\""
}
function seta() {
local __s_array="$1"; shift
eval "$__s_array=($("$@" | qlines))"
}
function e2of() {
"$@" 2>&1
}
function nef() {
"$@" | sed '/^$/d'
}
function isnum() {
[ ${#1} -gt 0 ] || return 1
@ -140,14 +214,10 @@ function isrnum() {
[ -z "$v" ]
}
function is_yes() {
[ "$1" == "o" -o "$1" == "O" -o "$1" == "oui" -o "$1" == "OUI" ] && return 0
[ "$1" == "y" -o "$1" == "Y" -o "$1" == "yes" -o "$1" == "YES" ] && return 0
[ "$1" == "v" -o "$1" == "V" -o "$1" == "vrai" -o "$1" == "VRAI" ] && return 0
[ "$1" == "t" -o "$1" == "T" -o "$1" == "true" -o "$1" == "TRUE" ] && return 0
[ "$1" == "on" -o "$1" == "ON" ] && return 0
if isnum "$1"; then
[ "$1" -ne 0 ] && return 0
fi
case "${1,,}" in
o|oui|y|yes|v|vrai|t|true|on) return 0;;
esac
isnum "$1" && [ "$1" -ne 0 ] && return 0
return 1
}
function yesval() {
@ -166,14 +236,10 @@ function normyesvals() {
done
}
function is_no() {
[ "$1" == "n" -o "$1" == "N" -o "$1" == "non" -o "$1" == "NON" ] && return 0
[ "$1" == "no" -o "$1" == "NO" ] && return 0
[ "$1" == "f" -o "$1" == "F" -o "$1" == "faux" -o "$1" == "FAUX" ] && return 0
[ "$1" == "false" -o "$1" == "FALSE" ] && return 0
[ "$1" == "off" -o "$1" == "OFF" ] && return 0
if isnum "$1"; then
[ "$1" -eq 0 ] && return 0
fi
case "${1,,}" in
n|non|no|f|faux|false|off) return 0;;
esac
isnum "$1" && [ "$1" -eq 0 ] && return 0
return 1
}
function rawecho() {
@ -202,18 +268,6 @@ function quote_arg() {
s="${s//\`/\\\`}"
rawecho "$s"
}
function should_quote() {
[ -z "$1" ] && return 0
local s="${1//[a-zA-Z0-9]/}"
s="${s//,/}"
s="${s//./}"
s="${s//+/}"
s="${s//\//}"
s="${s//-/}"
s="${s//_/}"
s="${s//=/}"
[ -n "$s" ]
}
function quoted_arg() {
should_quote "$1" && echo "\"$(quote_arg "$1")\"" || quote_arg "$1"
}
@ -490,6 +544,18 @@ function array_fillrange() {
done
array_copy "$1" __af_vs
}
function array_eq() {
local -a __ae_a1 __ae_a2
array_copy __ae_a1 "$1"
array_copy __ae_a2 "$2"
[ ${#__ae_a1[*]} -eq ${#__ae_a2[*]} ] || return 1
local __ae_v __ae_i=0
for __ae_v in "${__ae_a1[@]}"; do
[ "$__ae_v" == "${__ae_a2[$__ae_i]}" ] || return 1
__ae_i=$(($__ae_i + 1))
done
return 0
}
function array_contains() {
local __ac_v
eval 'for __ac_v in "${'"$1"'[@]}"; do
@ -599,14 +665,14 @@ function array_extend_lasts() {
eval "$1=(\"\${$1[@]}\" \"\${$2[@]:1}\")"
}
function array_xsplit() {
eval "$1=($(<<<"$2" stripnl | awkrun RS="${3:-:}" '
eval "$1=($(recho_ "$2" | awkrun RS="${3:-:}" '
{
gsub(/'\''/, "'\'\\\\\'\''")
print "'\''" $0 "'\''"
}'))" #"
}
function array_split() {
eval "$1=($(<<<"$2" stripnl | awkrun RS="${3:-:}" '
eval "$1=($(recho_ "$2" | awkrun RS="${3:-:}" '
/^$/ { next }
{
gsub(/'\''/, "'\'\\\\\'\''")
@ -617,14 +683,14 @@ function array_from_path() {
array_split "$1" "$2" ":"
}
function array_from_xlines() {
eval "$1=($(<<<"$2" _nl2lf | awk '
eval "$1=($(recho_ "$2" | _nl2lf | awk '
{
gsub(/'\''/, "'\'\\\\\'\''")
print "'\''" $0 "'\''"
}'))" #"
}
function array_from_lines() {
eval "$1=($(<<<"$2" _nl2lf | awk '
eval "$1=($(recho_ "$2" | _nl2lf | awk '
/^$/ { next }
{
gsub(/'\''/, "'\'\\\\\'\''")
@ -678,7 +744,7 @@ function array_fix_paths() {
array_copy __afp_vs "$__afp_an"
array_new "$__afp_an"
for __afp_v in "${__afp_vs[@]}"; do
array_split __afp_v "$__afp_v"
array_split __afp_v "$__afp_v" "$__afp_s"
array_extend "$__afp_an" __afp_v
done
}
@ -711,12 +777,9 @@ function parse_date() {
}')"
esac
case "$type" in
d|date)
awk '{ print strftime("%d/%m/%Y", $0 + 0) }' <<<"$value"
;;
l|ldap)
awk '{ print strftime("%Y%m%d%H%M%S+0400", $0 + 0) }' <<<"$value"
;;
d|date) awk '{ print strftime("%d/%m/%Y", $0 + 0) }' <<<"$value";;
l|ldap) awk '{ print strftime("%Y%m%d%H%M%S+0400", $0 + 0) }' <<<"$value";;
m|mysql) awk '{ print strftime("%Y-%m-%d", $0 + 0) }' <<<"$value";;
*)
rawecho "$value"
;;
@ -986,6 +1049,13 @@ function testsame() {
function testdiff() {
! quietdiff "$@"
}
function testupdated() {
if [ -f "$2" ]; then
testdiff "$1" "$2"
else
return 0
fi
}
function testnewer() {
test ! -e "$2" -o "$1" -nt "$2"
}
@ -1076,15 +1146,16 @@ function rm_maybe() {
done
[ -n "$rm" ] && /bin/rm "$@"
}
__CPDIR_RSYNC_ARGS=()
__CPDIR_RSYNC_SLOW=1 # synchro potentiellement plus lente, mais plus fidèle (option -c)
__CPDIR_RSYNC_ARGS=(-q)
function cpdir() {
if progexists rsync; then
[ -d "$2" ] || mkdir -p "$2" || return 1
if [ -d "$1" ]; then
rsync -qa "${__CPDIR_RSYNC_ARGS[@]}" "$1/" "$2/"
rsync -a ${__CPDIR_RSYNC_SLOW:+-c} "${__CPDIR_RSYNC_ARGS[@]}" "$1/" "$2/"
else
rsync -qa "${__CPDIR_RSYNC_ARGS[@]}" "$1" "$2/"
rsync -a ${__CPDIR_RSYNC_SLOW:+-c} "${__CPDIR_RSYNC_ARGS[@]}" "$1" "$2/"
fi
else
__cpdir "$@"
@ -1120,17 +1191,17 @@ function __cpdir() {
fi
fi
}
CPNOVCS_OPTS=() # deprecated
__CPNOVCS_RSYNC_ARGS=()
__CPNOVCS_RSYNC_SLOW=1 # synchro potentiellement plus lente, mais plus fidèle (option -c)
__CPNOVCS_RSYNC_ARGS=(-q)
function cpnovcs() {
local src="$1" destdir="$2"
[ -d "$destdir" ] || mkdir -p "$destdir" || return 1
if progexists rsync; then
local gitexclude=/.git/
if [ "${src%/}" != "$src" ]; then
if [ "${src%/}" == "$src" ]; then
gitexclude="/$(basename -- "$src")$gitexclude"
fi
rsync -qa --exclude CVS --exclude .svn --exclude "$gitexclude" "${CPNOVCS_OPTS[@]}" "${__CPNOVCS_RSYNC_ARGS[@]}" "$src" "$destdir/"
rsync -a ${__CPNOVCS_RSYNC_SLOW:+-c} --exclude CVS/ --exclude .svn/ --exclude "$gitexclude" "${__CPNOVCS_RSYNC_ARGS[@]}" "$src" "$destdir/"
elif [ "${src%/}" != "$src" ]; then
__cpdir "$src" "$destdir"
else
@ -1358,11 +1429,25 @@ function get_archive_appname() {
print substr($0, 1, RSTART - 1)
} else if (match($0, /([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/)) {
print substr($0, 1, RSTART - 1)
} else if (match($0, /([0-9]+[a-z][a-z][a-z0-9]?)$/, vs)) {
print substr($0, 1, RSTART - 1)
} else {
print $0
}
}'
}
function get_archive_versionsuffix() {
local basename="$(get_archive_basename "$1")"
echo "$basename" | awk '{
if (match($0, /([-_.][0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) {
print vs["1"]
} else if (match($0, /([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) {
print vs["1"]
} else if (match($0, /([0-9]+[a-z][a-z][a-z0-9]?)$/, vs)) {
print vs["1"]
}
}'
}
function get_archive_version() {
local basename="$(get_archive_basename "$1")"
echo "$basename" | awk '{
@ -1370,7 +1455,7 @@ function get_archive_version() {
print vs["1"]
} else if (match($0, /([0-9]+([-_.][0-9]+)*([a-zA-Z][0-9]*|[-_.][0-9]+[a-zA-Z][0-9]*)?)$/, vs)) {
print vs["1"]
} else if (match($0, /([0-9]+[a-z][a-z][a-z]?)$/, vs)) {
} else if (match($0, /([0-9]+[a-z][a-z][a-z0-9]?)$/, vs)) {
print vs["1"]
}
}'
@ -1591,6 +1676,13 @@ function quote_sql(s) {'"
gsub(/'/, \"''\", s)
return \"'\" s \"'\"
"'}
function unquote_mysqlcsv(s) {
gsub(/\\n/, "\n", s)
gsub(/\\t/, "\t", s)
gsub(/\\0/, "\0", s)
gsub(/\\\\/, "\\", s)
return s
}
function array_new(dest) {
dest[0] = 0 # forcer awk à considérer dest comme un tableau
delete dest
@ -1894,7 +1986,7 @@ function array_formatcsv2(fields, colsep, mvsep, qchar, echar, count, indic
if (echar != "") gsub(qchar, quote_subrepl(echar) "&", value);
else gsub(qchar, "&&", value);
}
if (qchar != "" && (index(value, mvsep) != 0 || index(value, colsep) != 0 || __csv_should_quote(value))) {
if (qchar != "" && (index(value, mvsep) != 0 || index(value, colsep) != 0 || index(value, qchar) != 0 || __csv_should_quote(value))) {
line = line qchar value qchar
} else {
line = line value
@ -2068,12 +2160,12 @@ function awkdef() {
}
function lawkrun() {
local -a __ar_defs __ar_args
while [ -n "$1" -a "$1" != "--" ]; do
while [ $# -gt 0 -a "$1" != "--" ]; do
__ar_defs=("${__ar_defs[@]}" "$1")
shift
done
shift
while [ -n "$1" ]; do
while [ $# -gt 0 ]; do
__ar_args=("${__ar_args[@]}" "$1")
shift
done
@ -2428,6 +2520,13 @@ function pidfile_check() {
fi
return 1
}
function page_maybe() {
if isatty; then
less -XF
else
cat
fi
}
function utools_local() {
@ -2725,6 +2824,29 @@ function eecho_() {
function edebug() {
show_debug || return; eflush; __edebug "$*" 1>&2
}
function trace() {
local r cmd="$(quoted_args "$@")"
show_info && { eflush; __eecho "\$ $cmd" 1>&2; }
"$@"; r=$?
if [ $r -ne 0 ]; then
if show_info; then
eflush; __eecho "^ [EC #$r]" 1>&2
elif show_error; then
eflush; __eecho "^ $cmd [EC #$r]" 1>&2;
fi
fi
return $r
}
function trace_error() {
local r
"$@"; r=$?
if [ $r -ne 0 ]; then
local cmd="$(quoted_args "$@")"
show_error && { eflush; __eecho "^ $cmd [EC #$r]" 1>&2; }
fi
return $r
}
function etitle() {
local __t_deferred=
__t_etitle "$@"
@ -4185,8 +4307,8 @@ BEGIN {
match_indented = 0
}
/^(export[ \t]+)?[a-zA-Z_][a-zA-Z0-9_]*[-+%#]=/ {
match($0, /^(export[ \t]+)?([a-zA-Z_][a-zA-Z0-9_]*)([-+%#])=(.*)$/, parts)
/^(export[ \t]+)?[a-zA-Z_][a-zA-Z0-9_]*[-+%#?]=/ {
match($0, /^(export[ \t]+)?([a-zA-Z_][a-zA-Z0-9_]*)([-+%#?])=(.*)$/, parts)
name = parts[2]
type = parts[3]
value = parts[4]
@ -4196,6 +4318,8 @@ BEGIN {
print "uinspath " value " " name
} else if (type == "-") {
print "udelpath " value " " name
} else if (type == "?") {
print "[ -n \"$" name "\" ] || " name "=" value
}
print "export " name
next

6
udir
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS udir
function display_help() {
uecho "$scriptname: gérer les variables de répertoire
@ -116,10 +118,6 @@ root_scripts
destination."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS udir ||
exit 1
action=auto
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \

5
udist
View File

@ -145,9 +145,8 @@ if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
exit 0
fi
source $(dirname "$0")/ulib/ulib &&
urequire DEFAULTS conf install ||
exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS conf install
INSTALL_VERBOSE=
INSTALL_USES_PPATH=1

6
uenv
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS uenv uenv_update
function display_help() {
uecho "$scriptname: Mettre à jour la configuration de l'environnement
@ -27,10 +29,6 @@ OPTIONS
nutools."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS uenv uenv_update ||
exit 1
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
-u update \

View File

@ -1,6 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1; urequire DEFAULTS
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Enlever ou transformer certaines classes de caractères d'un flux encodé en UTF-8

View File

@ -1,6 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1; urequire DEFAULTS password
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS password
function display_help() {
uecho "$scriptname: générer un mot de passe au hasard

6
uinc
View File

@ -1,9 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" &&
urequire uinc ||
exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire uinc
export UINCPATH="$ULIBDIR${UINCPATH:+:$UINCPATH}"
uinc "$@"

View File

@ -1,12 +1,9 @@
#!/bin/sh
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
# Version de uinc qui fonctionne avec /bin/sh. Le contrôle est transmis à
# bash, qui est recherché dans une liste de répertoires standards
. `dirname "$0"`/ulib/ulibsh &&
urequire DEFAULTS uinc ||
exit 1
. `dirname "$0"`/lib/ulib/ulibsh || exit 1
urequire DEFAULTS uinc
export UINCPATH="$ULIBDIR${UINCPATH:+:$UINCPATH}"
uinc "$@"

6
uinst
View File

@ -1,8 +1,6 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS uinst ||
exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS uinst
uinst_nolocal "$@"

View File

@ -1,11 +1,8 @@
#!/bin/sh
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
# Version de uinst qui fonctionne avec /bin/sh. Le contrôle est transmis à
# bash, qui est recherché dans une liste de répertoires standards
. `dirname "$0"`/ulib/ulibsh &&
urequire DEFAULTS uinst ||
exit 1
. `dirname "$0"`/lib/ulib/ulibsh || exit 1
urequire DEFAULTS uinst
uinst_nolocal "$@"

6
ujava
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS java
function display_help() {
uecho "$scriptname: Lancer un script après avoir sélectionné une version de java
@ -24,10 +26,6 @@ Si args n'est pas spécifié, un shell est lancé dans lequel les variables
JAVA_HOME, JAVA, JAVAC et PATH sont mis à jour."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS java ||
exit 1
bits=
exact=
parse_opts + "${PRETTYOPTS[@]}" \

6
uldap
View File

@ -1,9 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ldif prefixes ldap ||
exit 255
source "$(dirname "$0")/lib/ulib/ulib" || exit 255
urequire DEFAULTS ldif prefixes ldap
################################################################################
# Fonctions utilitaire

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Lancer un shell après avoir chargé des modules de ulib
@ -18,10 +20,6 @@ est modifié pour que $scriptdir soit ajouté en premier.
Les arguments sont passés inchangés au shell."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
parse_opts + "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
-r: modules \

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Copier les librairies ulib et/ou pyulib
@ -14,10 +16,6 @@ OPTIONS
Copier pyulib"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \
-u,--ulib ulib \

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Gestion de la version de ulib
@ -18,10 +20,6 @@ OPTIONS
juste tester la version et ne pas afficher le message d'information."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
action=show
system=
min_version=

6
umatch
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Afficher le résultat d'une recherche par regexp et compter
@ -49,10 +51,6 @@ OPTIONS
une ligne '--'"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
function match() {
local regexp="$1" sep="$2"
awkrun ${sep:+FS="$sep"} '{

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: faire un miroir d'un site web
@ -12,10 +14,6 @@ OPTIONS
Convertir les liens pour consultation locale"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
local=
parse_opts + "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \

View File

@ -69,4 +69,5 @@ if [ -n "$clonerepo" ]; then
cd ..
rm -rf "$NAME"
fi
# IMPORTANT: la ligne suivante ne doit pas se terminer par un retour à la ligne:
rm "$0"; exit 0

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS PREFIXES-DEFAULTS
function display_help() {
uecho "$scriptname: Afficher les préfixes valides pour uinst
@ -16,10 +18,6 @@ OPTIONS
Afficher la valeur du préfixe spécifié"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS PREFIXES-DEFAULTS ||
exit 1
action=expand
parse_opts "${PRETTYOPTS[@]}" \
--help '$exit_with display_help' \

View File

@ -138,9 +138,8 @@ if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
exit 0
fi
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS modeline vcs ||
exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS modeline vcs
# Traduire le nom du script
for script_alias in "${SCRIPT_ALIASES[@]}"; do

View File

@ -1,6 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1; urequire DEFAULTS crontab
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS crontab
function display_help() {
uecho "$scriptname: lancer une suite de commande en respectant une planification de type cron

2
ussh
View File

@ -1,6 +1,6 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Afficher les informations sur le système
@ -13,10 +15,6 @@ requête. Voir la doc de check_sysinfos() pour le format de la requête.
Sinon, afficher les informations sur le système courant."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
[ $# -eq 1 -a "$1" == "--help" ] && exit_with display_help
if [ -n "$*" ]; then

6
utempl
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Créer un nouveau fichier à partir d'un modèle
@ -22,10 +24,6 @@ utilisé pour créer le nouveau fichier. Utiliser l'option --help pour
avoir une description des options disponibles."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
template=
edit=auto
overwrite=

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire base pretty
function display_help() {
uecho "$scriptname: lancer une commande en différé
@ -47,10 +49,6 @@ OPTIONS
train de tourner, cette option n'a aucun effet."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire base pretty ||
exit 1
RUNDELAY=5
function acquire_lock() {

View File

@ -1,6 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" || exit 1; urequire DEFAULTS semver
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS semver
function display_help() {
uecho "$scriptname: gérer des numéros de version selon les règles du versionnage sémantique v2.0.0 (http://semver.org/)

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: afficher des informations sur une machine virtuelle OpenVZ
@ -19,10 +21,6 @@ OPTIONS
beancounters"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
default=1
bc=
show_failed=

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: créer une archive de la distribution WebObjects en cours
@ -15,10 +17,6 @@ OPTIONS
\$NAME.files"
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
name=
files=
parse_opts "${PRETTYOPTS[@]}" \

View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
function display_help() {
uecho "$scriptname: Changer la version de WebObjects pour le système en cours
@ -27,10 +29,6 @@ Ensuite, les répertoires Applications et Configuration sont restaurés. Il faud
restaurer Extensions manuellement."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
nocheck=
from=
to=

5
woctl
View File

@ -89,9 +89,8 @@ if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then
exit 0
fi
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS ||
exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS
# Traduire le nom du script
for script_alias in "${SCRIPT_ALIASES[@]}"; do

6
woinst
View File

@ -1,8 +1,6 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS woinst ||
exit 1
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS woinst
woinst "$@"

6
wosign
View File

@ -1,5 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
urequire DEFAULTS prefixes apache webobjects java wosign
function display_help() {
uecho "$scriptname: signer les jars d'un bundle
@ -18,10 +20,6 @@ OPTIONS
accessible en écriture, relancer le script en root."
}
source "$(dirname "$0")/ulib/ulib" &&
urequire DEFAULTS prefixes apache webobjects java wosign ||
exit 1
sign=
unsign=
resign=