Intégration de la branche release-9.1.0
This commit is contained in:
commit
c66e3351c8
13
CHANGES.md
13
CHANGES.md
|
@ -1,3 +1,16 @@
|
|||
## Version 9.1.0 du 22/11/2018-15:40
|
||||
|
||||
* `ba29496` dk: génération d'un service systemd
|
||||
* `f72dd86` option -n pour pcrone le clone pas le dépôt nouvellement créé
|
||||
* `01325d0` sqlmig: support chemin config/sqlmig et bug avec csv_null
|
||||
* `45da726` dk: ajout de l'option --fake pour afficher les commandes
|
||||
* `dcb637e` dk: support de --no-cache pour docker-compose build
|
||||
* `9c6f606` Intégration de la branche update-pcrone
|
||||
* `764dd53` maj prefixe et meilleur affichage des erreurs
|
||||
* `307fa48` dk: option -j pour désactiver le cache
|
||||
* `45c6422` profils pour docker-machine
|
||||
* `a9004fa` dk: PROFILE est exporté
|
||||
|
||||
## Version 9.0.0 du 15/11/2018-09:40
|
||||
|
||||
* `af969e4` maj de l'url source de nutools
|
||||
|
|
|
@ -1 +1 @@
|
|||
9.0.0
|
||||
9.1.0
|
||||
|
|
261
dk
261
dk
|
@ -11,7 +11,9 @@ USAGE
|
|||
COMMANDES
|
||||
build
|
||||
push
|
||||
run
|
||||
start, run
|
||||
service
|
||||
stop
|
||||
up
|
||||
logs
|
||||
down
|
||||
|
@ -19,7 +21,16 @@ COMMANDES
|
|||
ps
|
||||
ls
|
||||
rm
|
||||
prune"
|
||||
prune
|
||||
|
||||
OPTIONS
|
||||
-d, --chdir PROJDIR
|
||||
-p, --profile PROFILE
|
||||
-P, --prod
|
||||
-T, --test
|
||||
-n, --fake
|
||||
-j, --no-cache
|
||||
-h, --host HOST"
|
||||
}
|
||||
|
||||
function get_version() {
|
||||
|
@ -57,12 +68,12 @@ function docker_parse_build_args() {
|
|||
function docker_parse_env_args() {
|
||||
[ -f .build.env ] && eval "$(docker_parse_build_args .build.env)"
|
||||
[ -f build.env ] && eval "$(docker_parse_build_args build.env)"
|
||||
[ -n "$profile" -a -f ".build.$profile.env" ] && eval "$(docker_parse_build_args ".build.$profile.env")"
|
||||
[ -n "$PROFILE" -a -f ".build.$PROFILE.env" ] && eval "$(docker_parse_build_args ".build.$PROFILE.env")"
|
||||
}
|
||||
function docker_set_env_args() {
|
||||
[ -f .build.env ] && source ./.build.env
|
||||
[ -f build.env ] && source ./build.env
|
||||
[ -n "$profile" -a -f ".build.$profile.env" ] && source "./.build.$profile.env"
|
||||
[ -n "$PROFILE" -a -f ".build.$PROFILE.env" ] && source "./.build.$PROFILE.env"
|
||||
}
|
||||
function docker_set_run_args() {
|
||||
replace_run_args+=(--env-file "$1")
|
||||
|
@ -70,8 +81,10 @@ function docker_set_run_args() {
|
|||
}
|
||||
function docker_check_name() {
|
||||
[ -n "$NAME" ] || die "Vous devez définir NAME dans .build.env"
|
||||
if [ "$1" == set_name ]; then
|
||||
name="${NAME//[^a-zA-Z0-9_.-]/_}"
|
||||
if [ "$1" == set_container_name ]; then
|
||||
project_name="$NAME"
|
||||
container_name="${project_name//[^a-zA-Z0-9_-]/}"
|
||||
[ -n "$PROFILE" ] && container_name="${container_name}_$PROFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -82,18 +95,74 @@ function compose_set_env_args() {
|
|||
fi
|
||||
local PROJECT_NAME=--none--
|
||||
[ -f .compose.env ] && source ./.compose.env
|
||||
if [ -n "$profile" ]; then
|
||||
if [ -f "docker-compose.$profile.yml" ]; then
|
||||
replace_env_args+=(-f "docker-compose.$profile.yml")
|
||||
if [ -n "$PROFILE" ]; then
|
||||
if [ -f "docker-compose.$PROFILE.yml" ]; then
|
||||
replace_env_args+=(-f "docker-compose.$PROFILE.yml")
|
||||
fi
|
||||
if [ "$PROJECT_NAME" != --none-- ]; then
|
||||
if [ -z "$COMPOSE_PROJECT_NAME" ]; then
|
||||
[ -n "$PROJECT_NAME" ] || PROJECT_NAME="$(basename -- "$(pwd)")"
|
||||
COMPOSE_PROJECT_NAME="${PROJECT_NAME}_${profile}"
|
||||
COMPOSE_PROJECT_NAME="${PROJECT_NAME}_${PROFILE}"
|
||||
fi
|
||||
export COMPOSE_PROJECT_NAME
|
||||
fi
|
||||
fi
|
||||
if [ "$1" == set_container_name ]; then
|
||||
if [ "$PROJECT_NAME" == --none-- ]; then
|
||||
project_name="$(basename -- "$(pwd)")"
|
||||
else
|
||||
project_name="$PROJECT_NAME"
|
||||
fi
|
||||
container_name="${project_name//[^a-zA-Z0-9_-]/}"
|
||||
[ -n "$PROFILE" ] && container_name="${container_name}_$PROFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
function host_run() {
|
||||
# lancer le script $2..@ sur l'hôte $1
|
||||
# si $1 n'est pas défini ou est le nom l'hôte local, lancer le script en
|
||||
# local avec les droits root
|
||||
# sinon, si docker-machine existe, l'hôte doit correspondre à la machine active
|
||||
# sinon, lancer inconditionnellement le script sur l'hôte distant
|
||||
local host="$1" script="$2"; shift; shift
|
||||
if [ -n "$host" ]; then
|
||||
if check_hostname "$host"; then
|
||||
estep "Lancement de $script localement"
|
||||
runscript_as_root "$script" "$@"
|
||||
elif progexists docker-machine; then
|
||||
local dm; setx dm=docker-machine active 2>/dev/null
|
||||
if [ "${host%%.*}" == "$dm" ]; then
|
||||
estep "Copie du script vers root@$host"
|
||||
scp "$script" "root@$host:/tmp/tmp-dk-service-script" || die
|
||||
estep "Lancement du script à distance"
|
||||
local -a args; args=(/tmp/tmp-dk-service-script "$@")
|
||||
ssh -qt "root@$host" "$(qvals "${args[@]}"); rm -f /tmp/tmp-dk-service-script"
|
||||
else
|
||||
ewarn "La machine active ($dm) n'est pas la destination ($host)"
|
||||
fi
|
||||
else
|
||||
estep "Copie du script vers root@$host"
|
||||
scp "$script" "root@$host:/tmp/tmp-dk-service-script" || die
|
||||
estep "Lancement du script à distance"
|
||||
local -a args; args=(/tmp/tmp-dk-service-script "$@")
|
||||
ssh -qt "root@$host" "$(qvals "${args[@]}"); rm -f /tmp/tmp-dk-service-script"
|
||||
fi
|
||||
else
|
||||
estep "Lancement de $script localement"
|
||||
runscript_as_root "$script" "$@"
|
||||
fi
|
||||
}
|
||||
function local_run() {
|
||||
# lancer le script $2..@ sur l'hôte $1 uniquement si c'est l'hôte courant
|
||||
local host="$1" script="$2"; shift; shift
|
||||
if [ -n "$host" ]; then
|
||||
if ! check_hostname "$host"; then
|
||||
eerror "Cette commande doit obligatoirement être lancée depuis l'hôte $host"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
estep "Lancement de $script localement"
|
||||
runscript_as_root "$script" "$@"
|
||||
}
|
||||
|
||||
function initialize_build_env() {
|
||||
|
@ -109,9 +178,11 @@ function default_update_build_env() {
|
|||
function update_build_env() { default_update_build_env; }
|
||||
|
||||
function default_compose_build() {
|
||||
docker-compose \
|
||||
${FAKE:+qvals} docker-compose \
|
||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||
build "${replace_build_args[@]}" "${build_args[@]}" \
|
||||
build \
|
||||
${NO_CACHE:+--no-cache} \
|
||||
"${replace_build_args[@]}" "${build_args[@]}" \
|
||||
"$@"
|
||||
}
|
||||
function default_docker_build() {
|
||||
|
@ -119,7 +190,8 @@ function default_docker_build() {
|
|||
for tag in "${TAGS[@]}"; do
|
||||
replace_build_args+=(-t "$NAME:$tag")
|
||||
done
|
||||
docker build \
|
||||
${FAKE:+qvals} docker build \
|
||||
${NO_CACHE:+--no-cache} \
|
||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||
"${replace_build_args[@]}" "${build_args[@]}" \
|
||||
"$@" "$CTXDIR"
|
||||
|
@ -157,18 +229,18 @@ function auto_push() {
|
|||
update_build_env
|
||||
fi
|
||||
for tag in "${TAGS[@]}"; do
|
||||
docker push "$NAME:$tag"
|
||||
${FAKE:+qvals} docker push "$NAME:$tag"
|
||||
done
|
||||
}
|
||||
|
||||
function default_compose_up() {
|
||||
docker-compose \
|
||||
${FAKE:+qvals} docker-compose \
|
||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||
up "${replace_run_args[@]}" "${run_args[@]}" \
|
||||
"${replace_user_args[@]}" "${user_args[@]}" "$@"
|
||||
}
|
||||
function default_docker_up() {
|
||||
docker run \
|
||||
${FAKE:+qvals} docker run \
|
||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||
"${replace_run_args[@]}" "${run_args[@]}" \
|
||||
"$NAME" \
|
||||
|
@ -180,87 +252,163 @@ function auto_up() {
|
|||
local -a replace_env_args env_args
|
||||
local -a replace_run_args run_args
|
||||
local -a replace_user_args user_args
|
||||
local project_name container_name
|
||||
if [ -f docker-compose.yml ]; then
|
||||
compose_set_env_args
|
||||
replace_run_args=(-d)
|
||||
compose_up "$@"
|
||||
else
|
||||
docker_set_env_args
|
||||
docker_check_name set_name
|
||||
replace_run_args=(-d --name "$name")
|
||||
docker_check_name set_container_name
|
||||
replace_run_args=(-d --name "$container_name")
|
||||
docker_up "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function default_compose_service() {
|
||||
local docker_compose="$(which docker-compose)"
|
||||
setx startcmd=qvals "$docker_compose" \
|
||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||
up "${replace_run_args[@]}" "${run_args[@]}" \
|
||||
"${replace_user_args[@]}" "${user_args[@]}" "$@"
|
||||
setx stopcmd=qvals "$docker_compose" down
|
||||
}
|
||||
function default_docker_service() {
|
||||
local docker="$(which docker)"
|
||||
setx startcmd=qvals "$docker" run \
|
||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||
"${replace_run_args[@]}" "${run_args[@]}" \
|
||||
"$NAME" \
|
||||
"${replace_user_args[@]}" "${user_args[@]}" "$@"
|
||||
setx stopcmd=qvals "$docker" stop "$container_name"
|
||||
}
|
||||
function compose_service() { default_compose_service "$@"; }
|
||||
function docker_service() { default_docker_service "$@"; }
|
||||
function auto_service() {
|
||||
local -a replace_env_args env_args
|
||||
local -a replace_run_args run_args
|
||||
local -a replace_user_args user_args
|
||||
local project_name container_name startcmd stopcmd
|
||||
local tmpscript; ac_set_tmpfile tmpscript
|
||||
|
||||
estep "Génération du service"
|
||||
export COMPOSE_PROJECT_NAME=
|
||||
if [ -f docker-compose.yml ]; then
|
||||
compose_set_env_args set_container_name
|
||||
replace_run_args=(-d --no-color)
|
||||
compose_service "$@"
|
||||
if [ -z "$HOST" -a -f .env ]; then
|
||||
source ./.env
|
||||
if [ -n "$PROFILE" ]; then
|
||||
HOST="${PROFILE^^}_HOST"; HOST="${!HOST}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
docker_set_env_args
|
||||
docker_check_name set_container_name
|
||||
replace_run_args=(-d --name "$container_name")
|
||||
docker_service "$@"
|
||||
fi
|
||||
[ -n "$COMPOSE_PROJECT_NAME" ] || COMPOSE_PROJECT_NAME="$project_name"
|
||||
chmod 755 "$tmpscript"
|
||||
cat >"$tmpscript" <<EOF
|
||||
#!/bin/bash
|
||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||
cat >/etc/systemd/system/$container_name.service <<EOD
|
||||
[Unit]
|
||||
Description=$project_name stack ($PROFILE)
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=$(pwd)
|
||||
Environment=$(qval "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME")
|
||||
ExecStart=$startcmd
|
||||
ExecStop=$stopcmd
|
||||
TimeoutStopSec=300
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOD
|
||||
systemctl daemon-reload
|
||||
systemctl enable $container_name.service
|
||||
EOF
|
||||
|
||||
estep "Installation du service"
|
||||
local_run "$HOST" "$tmpscript"
|
||||
}
|
||||
|
||||
function default_compose_stop() {
|
||||
docker-compose \
|
||||
${FAKE:+qvals} docker-compose \
|
||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||
stop "${replace_stop_args[@]}" "${stop_args[@]}" \
|
||||
"$@"
|
||||
}
|
||||
function default_docker_stop() {
|
||||
docker container stop \
|
||||
${FAKE:+qvals} docker container stop \
|
||||
"${replace_stop_args[@]}" "${stop_args[@]}" \
|
||||
"$name" "$@"
|
||||
"$container_name" "$@"
|
||||
}
|
||||
function compose_stop() { default_compose_stop "$@"; }
|
||||
function docker_stop() { default_docker_stop "$@"; }
|
||||
function auto_stop() {
|
||||
local -a replace_env_args env_args
|
||||
local -a replace_stop_args stop_args
|
||||
local project_name container_name
|
||||
if [ -f docker-compose.yml ]; then
|
||||
compose_set_env_args
|
||||
compose_stop "$@"
|
||||
else
|
||||
docker_set_env_args
|
||||
docker_check_name set_name
|
||||
docker_check_name set_container_name
|
||||
docker_stop "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function default_compose_logs() {
|
||||
docker-compose \
|
||||
${FAKE:+qvals} docker-compose \
|
||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||
logs "${replace_logs_args[@]}" "${logs_args[@]}" \
|
||||
"$@"
|
||||
}
|
||||
function default_docker_logs() {
|
||||
docker logs \
|
||||
${FAKE:+qvals} docker logs \
|
||||
"${replace_logs_args[@]}" "${logs_args[@]}" \
|
||||
"$name" "$@"
|
||||
"$container_name" "$@"
|
||||
}
|
||||
function compose_logs() { default_compose_logs "$@"; }
|
||||
function docker_logs() { default_docker_logs "$@"; }
|
||||
function auto_logs() {
|
||||
local -a replace_env_args env_args
|
||||
local -a replace_logs_args logs_args
|
||||
local project_name container_name
|
||||
if [ -f docker-compose.yml ]; then
|
||||
compose_set_env_args
|
||||
replace_logs_args=(-f)
|
||||
compose_logs "$@"
|
||||
else
|
||||
docker_set_env_args
|
||||
docker_check_name set_name
|
||||
docker_check_name set_container_name
|
||||
replace_logs_args=(-f)
|
||||
docker_logs "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function default_compose_down() {
|
||||
docker-compose \
|
||||
${FAKE:+qvals} docker-compose \
|
||||
"${replace_env_args[@]}" "${env_args[@]}" \
|
||||
down "${replace_down_args[@]}" "${down_args[@]}" \
|
||||
"$@"
|
||||
}
|
||||
function default_docker_down() {
|
||||
estep "stop"
|
||||
docker container stop \
|
||||
${FAKE:+qvals} docker container stop \
|
||||
"${replace_down_args[@]}" "${down_args[@]}" \
|
||||
"$name" "$@"
|
||||
"$container_name" "$@"
|
||||
estep "rm"
|
||||
docker container rm \
|
||||
${FAKE:+qvals} docker container rm \
|
||||
"${replace_rm_args[@]}" "${rm_args[@]}" \
|
||||
"$name"
|
||||
"$container_name"
|
||||
}
|
||||
function compose_down() { default_compose_down "$@"; }
|
||||
function docker_down() { default_docker_down "$@"; }
|
||||
|
@ -268,34 +416,53 @@ function auto_down() {
|
|||
local -a replace_env_args env_args
|
||||
local -a replace_down_args down_args
|
||||
local -a replace_rm_args rm_args
|
||||
local project_name container_name
|
||||
if [ -f docker-compose.yml ]; then
|
||||
compose_set_env_args
|
||||
compose_down "$@"
|
||||
else
|
||||
docker_set_env_args
|
||||
docker_check_name set_name
|
||||
docker_check_name set_container_name
|
||||
docker_down "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
DEFAULT_PROFILE=devel
|
||||
PROFILE=
|
||||
DM_PROFILES=()
|
||||
set_defaults dk
|
||||
export PROFILE
|
||||
|
||||
if progexists docker-machine; then
|
||||
setx active_dm=docker-machine active 2>/dev/null
|
||||
for dm_profile in "${DM_PROFILES[@]}"; do
|
||||
splitpair "$dm_profile" dm profile
|
||||
if [ "$dm" == "$active_dm" ]; then
|
||||
DEFAULT_PROFILE="$profile"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
chdir=
|
||||
profile="$PROFILE"
|
||||
FAKE=
|
||||
NO_CACHE=
|
||||
HOST=
|
||||
args=(
|
||||
--help '$exit_with display_help'
|
||||
-d:,--chdir: chdir=
|
||||
-p:,--profile: profile=
|
||||
-P,--prod profile=prod
|
||||
-T,--test profile=test
|
||||
-p:,--profile: PROFILE=
|
||||
-P,--prod PROFILE=prod
|
||||
-T,--test PROFILE=test
|
||||
-n,--fake FAKE=1
|
||||
-j,--no-cache NO_CACHE=1
|
||||
-h:,--host: HOST=
|
||||
)
|
||||
parse_args "$@"; set -- "${args[@]}"
|
||||
|
||||
# construire par défaut
|
||||
[ $# -eq 0 ] && set -- build
|
||||
[ -n "$profile" ] || profile="$DEFAULT_PROFILE"
|
||||
[ -n "$PROFILE" ] || PROFILE="$DEFAULT_PROFILE"
|
||||
|
||||
[ -n "$chdir" ] && { cd "$chdir" || die; }
|
||||
|
||||
|
@ -310,7 +477,7 @@ while [ $# -gt 0 ]; do
|
|||
while [ $# -gt 0 -a "$1" != -- ]; do
|
||||
args+=("$1"); shift
|
||||
done
|
||||
enote "Profil $profile"
|
||||
enote "Profil $PROFILE"
|
||||
auto_build "${args[@]}" || die
|
||||
;;
|
||||
push)
|
||||
|
@ -320,7 +487,7 @@ while [ $# -gt 0 ]; do
|
|||
while [ $# -gt 0 -a "$1" != -- ]; do
|
||||
args+=("$1"); shift
|
||||
done
|
||||
enote "Profil $profile"
|
||||
enote "Profil $PROFILE"
|
||||
auto_push "${args[@]}" || die
|
||||
;;
|
||||
s|run|start)
|
||||
|
@ -328,11 +495,19 @@ while [ $# -gt 0 ]; do
|
|||
while [ $# -gt 0 -a "$1" != -- ]; do
|
||||
args+=("$1"); shift
|
||||
done
|
||||
enote "Profil $profile"
|
||||
enote "Profil $PROFILE"
|
||||
auto_up "${args[@]}" || die
|
||||
;;
|
||||
service)
|
||||
args=()
|
||||
while [ $# -gt 0 -a "$1" != -- ]; do
|
||||
args+=("$1"); shift
|
||||
done
|
||||
enote "Profil $PROFILE"
|
||||
auto_service "${args[@]}" || die
|
||||
;;
|
||||
k|stop)
|
||||
enote "Profil $profile"
|
||||
enote "Profil $PROFILE"
|
||||
auto_stop || die
|
||||
;;
|
||||
1|up)
|
||||
|
@ -340,7 +515,7 @@ while [ $# -gt 0 ]; do
|
|||
while [ $# -gt 0 -a "$1" != -- ]; do
|
||||
args+=("$1"); shift
|
||||
done
|
||||
enote "Profil $profile"
|
||||
enote "Profil $PROFILE"
|
||||
auto_up "${args[@]}" && auto_logs || die
|
||||
;;
|
||||
l|logs) auto_logs || die;;
|
||||
|
@ -358,7 +533,7 @@ while [ $# -gt 0 ]; do
|
|||
while [ $# -gt 0 -a "$1" != -- ]; do
|
||||
args+=("$1"); shift
|
||||
done
|
||||
enote "Profil $profile"
|
||||
enote "Profil $PROFILE"
|
||||
if auto_build; then
|
||||
auto_up "${args[@]}" && auto_logs || die
|
||||
else
|
||||
|
|
|
@ -2,3 +2,6 @@
|
|||
|
||||
# Profil par défaut
|
||||
#PROFILE=prod
|
||||
|
||||
# Profiles pour docker-machine
|
||||
#DM_PROFILES=(name:profile...)
|
||||
|
|
|
@ -1,15 +1,31 @@
|
|||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||
|
||||
# Liste de préfixes permettant de taper le nom d'un dépôt plus rapidement e.g
|
||||
# pcrone g/ssi-php/myproj
|
||||
# pcrone v:modules/myproj
|
||||
# sont équivalents à
|
||||
# pcrone https://git.univ-reunion.fr/ssi-php/myproj
|
||||
# pcrone git@vcs.univ.run:modules/myproj
|
||||
# Ces définitions fonctionnent aussi pour pclone
|
||||
# Le format est ALIAS=ACTUAL
|
||||
REPO_PREFIXES=(
|
||||
s:=git@git.univ-reunion.fr:
|
||||
g/=https://git.univ-reunion.fr/
|
||||
v:=git@vcs.univ.run: av/=https://vcs.univ-reunion.fr/anongit/
|
||||
p:=pgit@vcs.univ.run: ap/=https://pvcs.univ-reunion.fr/anongit/
|
||||
)
|
||||
|
||||
# Définitions des types de dépôt. Le format est NAME:TYPE:PREFIX
|
||||
# * NAME est utilisé pour définir des configurations supplémentaires
|
||||
# * TYPE peut valoir gitolite ou gogs. Le type par défaut est 'gitolite'
|
||||
# * TYPE peut valoir gitolite ou gogs (ou gitea qui est un alias de gogs). Le
|
||||
# type par défaut est 'gitolite'
|
||||
REPO_TYPES=(
|
||||
ur:gogs:https://gogs.univ-reunion.fr/
|
||||
ur:gitea:https://git.univ-reunion.fr/
|
||||
)
|
||||
|
||||
# Configuration de l'accès à l'API gogs
|
||||
# un nom de dépôt est de la forme user/repo. Si user != $GOGS_USER alors on crée
|
||||
# dans une organisation
|
||||
#ur_GOGS_URL=https://gogs.univ-reunion.fr
|
||||
#ur_GOGS_URL=https://git.univ-reunion.fr
|
||||
#ur_GOGS_USER="$USER"
|
||||
#ur_GOGS_KEY=
|
||||
|
|
18
sqlmig
18
sqlmig
|
@ -980,6 +980,8 @@ if [ -z "$dbdir" -a -z "$updatedir" ]; then
|
|||
setx parentdir=dirname -- "$cwd"
|
||||
if __check_devel_dir src/main/resources/database; then
|
||||
enote "Autosélection src/main/resources/database/"
|
||||
elif __check_devel_dir config/sqlmig; then
|
||||
enote "Autosélection config/sqlmig/"
|
||||
elif __check_devel_dir support/database; then
|
||||
enote "Autosélection support/database/"
|
||||
elif __check_devel_dir database; then
|
||||
|
@ -1086,7 +1088,8 @@ grant resource to $dbname;"
|
|||
echo >"$dbdir/ora.conf" "\
|
||||
# Paramètres de connexion par défaut
|
||||
ORACLE_SID=orcl
|
||||
NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
||||
NLS_LANG=FRENCH_FRANCE.AL32UTF8
|
||||
#NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
||||
# paramètres de connexion pour les mises à jour administratives
|
||||
# si aucune valeur n'est spécifiée, la valeur effective est '/ as sysdba' mais
|
||||
# cela requière que la mise à jour soit faite avec une connexion locale.
|
||||
|
@ -1334,9 +1337,14 @@ for dbdir in "${dbdirs[@]}"; do
|
|||
ensure_dbtype "$dbdir" "$type"
|
||||
ensure_dbmode "$dbtype" "$mode"
|
||||
|
||||
if [ -n "$data_csv" ]; then
|
||||
# Conversion csv --> sql
|
||||
array_lsfiles csvs "$dbdir" "*.csv"
|
||||
if [ "$dbtype" == mysql -a -n "$data_csv" ]; then
|
||||
if [ "$dbtype" == mysql ]; then
|
||||
setx defaults=mysql_get_defaults "$dbdir"
|
||||
set_csv_null=1
|
||||
mysql__mconf_get "$defaults"
|
||||
|
||||
etitled "Conversion"
|
||||
for csv in "${csvs[@]}"; do
|
||||
setx csvname=basename -- "$csv"
|
||||
|
@ -1346,7 +1354,7 @@ for dbdir in "${dbdirs[@]}"; do
|
|||
fi
|
||||
|
||||
estep "$csvname --> ${csvname%.csv}.sql"
|
||||
eval "$(awk '{
|
||||
script='{
|
||||
truncate = ($0 ~ /-data_truncate(.devel)?.csv$/)? "1": ""
|
||||
sub(/^.*\//, "")
|
||||
sub(/^[A-Z0-9.]*[0-9]-?/, "")
|
||||
|
@ -1356,11 +1364,13 @@ for dbdir in "${dbdirs[@]}"; do
|
|||
print "truncate=" truncate
|
||||
gsub(/'\''/, "'\'\\\\\'\''")
|
||||
print "table='\''" $0 "'\''"
|
||||
}' <<<"$csvname")" #"
|
||||
}'
|
||||
eval "$(awk "$script" <<<"$csvname")"
|
||||
"$scriptdir/mysqlloadcsv" >"$sql" ${truncate:+-T} -Z "$csv_null" -nIf "$csv" "$table" --prefix "-- -*- coding: utf-8 mode: sql -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8"
|
||||
done
|
||||
eend; eclearp
|
||||
fi
|
||||
fi
|
||||
|
||||
# lister les mises à jour disponibles
|
||||
drops=()
|
||||
|
|
146
uproject
146
uproject
|
@ -241,6 +241,78 @@ done
|
|||
################################################################################
|
||||
# Traiter les commandes
|
||||
|
||||
function cxone_init() {
|
||||
repourl="${1%.git}"
|
||||
[ -n "$repourl" ] || return
|
||||
rname=
|
||||
rtype=gitolite
|
||||
rprefix=
|
||||
|
||||
REPO_PREFIXES=()
|
||||
REPO_TYPES=()
|
||||
set_defaults pcrone
|
||||
|
||||
# Traduire les aliases éventuels
|
||||
local asrcdest asrc adest
|
||||
for asrcdest in "${REPO_PREFIXES[@]}"; do
|
||||
splitfsep "$asrcdest" = asrc adest
|
||||
if [ "${repourl#$asrc}" != "$repourl" ]; then
|
||||
newurl="$adest${repourl#$asrc}"
|
||||
if [ "$newurl" != "$repourl" ]; then
|
||||
enote "$repourl --> $newurl"
|
||||
repourl="$newurl"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
local rnametypeprefix tmp found
|
||||
for rnametypeprefix in "${REPO_TYPES[@]}"; do
|
||||
splitfsep "$rnametypeprefix" : rname tmp
|
||||
splitfsep "$tmp" : rtype rprefix
|
||||
if [ "${repourl#$rprefix}" != "$repourl" ]; then
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$found" ]; then
|
||||
rname=
|
||||
rtype=gitolite
|
||||
rprefix=
|
||||
fi
|
||||
}
|
||||
function curlto() {
|
||||
local url="$1"; shift
|
||||
local payload="$1"; shift
|
||||
local outfile="$1"; shift
|
||||
local tmpfile
|
||||
if [ -z "$outfile" ]; then
|
||||
ac_set_tmpfile tmpfile
|
||||
outfile="$tmpfile"
|
||||
fi
|
||||
|
||||
local -a args
|
||||
local r http_code
|
||||
args=(-s -w '%{http_code}' -o "$outfile")
|
||||
[ -n "$payload" ] && args+=(-d "$payload")
|
||||
args+=("$@" "$url")
|
||||
setx http_code=curl "${args[@]}"
|
||||
|
||||
case "$http_code" in
|
||||
2*) r=0;;
|
||||
4*) r=1;;
|
||||
5*) r=3;;
|
||||
*) r=11;;
|
||||
esac
|
||||
if [ -n "$tmpfile" ]; then
|
||||
cat "$tmpfile"
|
||||
ac_clean "$tmpfile"
|
||||
fi
|
||||
|
||||
upvar http_code "$http_code"
|
||||
return "$r"
|
||||
}
|
||||
|
||||
if [ "$CMD" == "grep" ]; then
|
||||
## grep
|
||||
if [ $# -eq 1 -a "$1" == "--help" ]; then
|
||||
|
@ -339,9 +411,14 @@ NR <= 2 { next }
|
|||
-r,--recursive recursive=1 \
|
||||
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
||||
|
||||
cxone_init "$@"
|
||||
[ -n "$repourl" ] && set -- "$repourl" "${@:2}"
|
||||
|
||||
if [ -n "$recursive" ]; then
|
||||
repobase="$1"
|
||||
[ -n "$repobase" ] || die "Vous devez spécifier l'url de base des dépôts à cloner"
|
||||
[ "$rtype" == gitolite ] || die "Le clonage récursif n'est supporté que pour les dépôts de type gitolite"
|
||||
|
||||
if [ "${repobase#http://}" != "$repobase" -o "${repobase#https://}" != "$repobase" ]; then
|
||||
# accès par http
|
||||
mode=http
|
||||
|
@ -417,27 +494,15 @@ NR <= 2 { next }
|
|||
fi
|
||||
|
||||
elif [ "$CMD" == crone ]; then
|
||||
REPO_TYPES=()
|
||||
set_defaults pcrone
|
||||
no_clone=
|
||||
parse_opts "${PRETTYOPTS[@]}" \
|
||||
-n,--no-clone no_clone=1 \
|
||||
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
||||
|
||||
repourl="${1%.git}"
|
||||
cxone_init "$@"
|
||||
[ -n "$repourl" ] || die "Vous devez spécifier l'url du dépôt git"
|
||||
|
||||
found=
|
||||
for repo_ntp in "${REPO_TYPES[@]}"; do
|
||||
splitfsep "$repo_ntp" : name tmp
|
||||
splitfsep "$tmp" : type prefix
|
||||
if [ "${repourl#$prefix}" != "$repourl" ]; then
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$found" ]; then
|
||||
name=
|
||||
type=gitolite
|
||||
prefix=
|
||||
fi
|
||||
if [ "$type" == "gitolite" ]; then
|
||||
if [ "$rtype" == "gitolite" ]; then
|
||||
if [ "${repourl#http://}" != "$repourl" -o "${repourl#https://}" != "$repourl" ]; then
|
||||
# accès par http
|
||||
mode=gitolite_http
|
||||
|
@ -455,15 +520,15 @@ elif [ "$CMD" == crone ]; then
|
|||
[ -n "$host" ] || die "Vous devez spécifier l'hôte"
|
||||
userhost="$user@$host"
|
||||
fi
|
||||
elif [ "$type" == "gogs" ]; then
|
||||
elif [ "$rtype" == gogs -o "$rtype" == gitea ]; then
|
||||
mode=gogs_http
|
||||
gogs_url="${name}_GOGS_URL"; gogs_url="${!gogs_url}"
|
||||
gogs_user="${name}_GOGS_USER"; gogs_user="${!gogs_user}"
|
||||
gogs_key="${name}_GOGS_KEY"; gogs_key="${!gogs_key}"
|
||||
userpath="${repourl#$prefix}"
|
||||
gogs_url="${rname}_GOGS_URL"; gogs_url="${!gogs_url}"
|
||||
gogs_user="${rname}_GOGS_USER"; gogs_user="${!gogs_user}"
|
||||
gogs_key="${rname}_GOGS_KEY"; gogs_key="${!gogs_key}"
|
||||
userpath="${repourl#$rprefix}"
|
||||
splitfsep "$userpath" / user path
|
||||
else
|
||||
die "$type: type de dépôt non supporté"
|
||||
die "$rtype: type de dépôt non supporté"
|
||||
fi
|
||||
[ -n "$path" ] || die "Vous devez spécifier le chemin du dépôt git"
|
||||
|
||||
|
@ -473,7 +538,7 @@ elif [ "$CMD" == crone ]; then
|
|||
destdir="${destdir%.git}"
|
||||
fi
|
||||
tmpdestdir=
|
||||
if [ -d "$destdir" ]; then
|
||||
if [ -d "$destdir" -a -z "$no_clone" ]; then
|
||||
[ -d "$destdir/.git" ] && die "$(ppath2 "$destdir"): un dépôt existe déjà"
|
||||
ac_set_tmpdir tmpdestdir
|
||||
fi
|
||||
|
@ -482,6 +547,8 @@ elif [ "$CMD" == crone ]; then
|
|||
setx result=curl -fs "$hostuser/create?$path" || die
|
||||
echo "$result"
|
||||
[[ "$result" == FATAL:* ]] && die
|
||||
[ -n "$no_clone" ] && exit 0
|
||||
|
||||
if [ -n "$tmpdestdir" ]; then
|
||||
setxx destname=abspath "$destdir" // basename
|
||||
git clone "$hostuser/$path" "$tmpdestdir/$destname" || die
|
||||
|
@ -490,9 +557,12 @@ elif [ "$CMD" == crone ]; then
|
|||
else
|
||||
git clone "$hostuser/$path" "$destdir" || die
|
||||
fi
|
||||
|
||||
elif [ "$mode" == gitolite_ssh ]; then
|
||||
git_annex_use_ssh_wrapper
|
||||
ssh "$userhost" create "$path" || die
|
||||
[ -n "$no_clone" ] && exit 0
|
||||
|
||||
if [ -n "$tmpdestdir" ]; then
|
||||
setxx destname=abspath "$destdir" // basename
|
||||
git clone "$userhost:$path" "$tmpdestdir/$destname" || die
|
||||
|
@ -501,6 +571,7 @@ elif [ "$CMD" == crone ]; then
|
|||
else
|
||||
git clone "$userhost:$path" "$destdir" || die
|
||||
fi
|
||||
|
||||
elif [ "$mode" == gogs_http ]; then
|
||||
payload='{"private":true,"name":"'"$path"'"}'
|
||||
if [ "$gogs_user" != "$user" ]; then
|
||||
|
@ -508,12 +579,16 @@ elif [ "$CMD" == crone ]; then
|
|||
else
|
||||
url="$gogs_url/api/v1/user/repos"
|
||||
fi
|
||||
setx result=curl -fs \
|
||||
setx result=curlto "$url" "$payload" "" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H "Authorization: token $gogs_key" \
|
||||
-d "$payload" \
|
||||
"$url" || die "Une erreur s'est produite lors de la tentative de création du dépôt"
|
||||
-H "Authorization: token $gogs_key" || \
|
||||
die "Une erreur s'est produite lors de la tentative de création du dépôt
|
||||
url: $url
|
||||
payload: $payload
|
||||
result: $result"
|
||||
echo "$result"
|
||||
[ -n "$no_clone" ] && exit 0
|
||||
|
||||
if [ -n "$tmpdestdir" ]; then
|
||||
setxx destname=abspath "$destdir" // basename
|
||||
git clone "$repourl" "$tmpdestdir/$destname" || die
|
||||
|
@ -525,18 +600,17 @@ elif [ "$CMD" == crone ]; then
|
|||
else
|
||||
die "bug: mode non prévu"
|
||||
fi
|
||||
if [ ! -f "$destdir/.gitignore" -o ! -f "$destdir/.gitattributes" ]; then
|
||||
if ask_yesno "Voulez-vous créer les fichiers initiaux .gitignore et/ou .gitattributes?" O; then
|
||||
|
||||
if [ -f "$destdir/.gitignore" ]; then
|
||||
einfo "Refus d'écraser le fichier .gitignore existant"
|
||||
else
|
||||
:
|
||||
elif ask_yesno "Voulez-vous créer le fichier initial .gitignore?" O; then
|
||||
echo >"$destdir/.gitignore" "\
|
||||
.~lock*#
|
||||
.*.swp"
|
||||
fi
|
||||
if [ -f "$destdir/.gitattributes" ]; then
|
||||
einfo "Refus d'écraser le fichier .gitattributes existant"
|
||||
else
|
||||
:
|
||||
elif ask_yesno "Voulez-vous créer le fichier initial .gitattributes?" N; then
|
||||
echo >"$destdir/.gitattributes" "\
|
||||
*.zip -delta
|
||||
*.gz -delta
|
||||
|
@ -544,8 +618,6 @@ elif [ "$CMD" == crone ]; then
|
|||
*.whl -delta
|
||||
*.exe -delta"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [ "$CMD" == xconfig-export ]; then
|
||||
unset GIT_DIR; unset GIT_WORK_TREE
|
||||
|
|
Loading…
Reference in New Issue