Didier Denoual
3 months ago
9 changed files with 228 additions and 7 deletions
@ -0,0 +1,117 @@ |
|||
#!/bin/bash |
|||
# Script de manipulation d'un wordpress' |
|||
# init /versions / restart ... |
|||
# |
|||
|
|||
KAZ_ROOT=$(cd "$(dirname $0)"/..; pwd) |
|||
. $KAZ_ROOT/bin/.commonFunctions.sh |
|||
setKazVars |
|||
. $DOCKERS_ENV |
|||
. $KAZ_ROOT/secret/SetAllPass.sh |
|||
|
|||
#GLOBAL VARS |
|||
PRG=$(basename $0) |
|||
|
|||
availableOrga=($(getList "${KAZ_CONF_DIR}/container-orga.list")) |
|||
AVAILABLE_ORGAS=${availableOrga[*]//-orga/} |
|||
|
|||
QUIET="1" |
|||
ONNAS= |
|||
|
|||
|
|||
CASTOPOD_COMMUN="OUI_PAR_DEFAUT" |
|||
DockerServName=${castopodServName} |
|||
|
|||
declare -A Posts |
|||
|
|||
usage() { |
|||
echo "${PRG} [OPTION] [COMMANDES] [ORGA] |
|||
Manipulation d'un castopod |
|||
|
|||
OPTIONS |
|||
-h|--help Cette aide :-) |
|||
-n|--simu SIMULATION |
|||
-q|--quiet On ne parle pas (utile avec le -n pour avoir que les commandes) |
|||
--nas L'orga se trouve sur le NAS ! |
|||
|
|||
COMMANDES (on peut en mettre plusieurs dans l'ordre souhaité) |
|||
-I|--install L'initialisation du castopod |
|||
-v|--version Donne la version du castopod et signale les MàJ |
|||
|
|||
ORGA parmi : ${AVAILABLE_ORGAS} |
|||
ou vide si castopod commun |
|||
" |
|||
} |
|||
|
|||
|
|||
|
|||
Init(){ |
|||
|
|||
POD_URL="${httpProto}://${ORGA}-${castopodHost}.${domain}" |
|||
[ -n "${CASTOPOD_COMMUN}" ] && POD_URL="${httpProto}://${castopodHost}.${domain}" |
|||
|
|||
if ! [[ "$(docker ps -f name=${DockerServName} | grep -w ${DockerServName})" ]]; then |
|||
printKazError "Castopod not running... abort" |
|||
exit |
|||
fi |
|||
|
|||
echo "\n *** Premier lancement de Castopod" >& $QUIET |
|||
|
|||
${SIMU} waitUrl "${POD_URL}" |
|||
CI_SESSION=$(echo ${headers} | grep "ci_session" | sed "s/.*ci_session=//") |
|||
|
|||
cookies=$(curl -c - ${POD_URL}) |
|||
CSRF_TOKEN=$(curl --cookie <(echo "$cookies") ${POD_URL}/cp-install | grep "csrf_test_name" | sed "s/.*value=.//" | sed "s/.>//") |
|||
|
|||
#echo ${CSRF_TOKEN} |
|||
${SIMU} curl --cookie <(echo "$cookies") -X POST \ |
|||
-d "username=${castopod_ADMIN_USER}" \ |
|||
-d "password=${castopod_ADMIN_PASSWORD}" \ |
|||
-d "email=${castopod_ADMIN_MAIL}" \ |
|||
-d "csrf_test_name=${CSRF_TOKEN}" \ |
|||
"${POD_URL}/cp-install/create-superadmin" |
|||
|
|||
} |
|||
|
|||
Version(){ |
|||
VERSION="TODO" |
|||
echo "Version $DockerServName : ${GREEN}${VERSION}${NC}" |
|||
} |
|||
|
|||
|
|||
|
|||
########## Main ################# |
|||
for ARG in "$@"; do |
|||
case "${ARG}" in |
|||
'-h' | '--help' ) |
|||
usage && exit ;; |
|||
'-n' | '--simu') |
|||
SIMU="echo" ;; |
|||
'-q' ) |
|||
QUIET="/dev/null" ;; |
|||
'--nas' | '-nas' ) |
|||
ONNAS="SURNAS" ;; |
|||
'-v' | '--version') |
|||
COMMANDS="$(echo "${COMMANDS} VERSION" | sed "s/\s/\n/g" | sort | uniq)" ;; |
|||
'-I' | '--install' ) |
|||
COMMANDS="$(echo "${COMMANDS} INIT" | sed "s/\s/\n/g" | sort | uniq)" ;; # le sed sort uniq, c'est pour pas l'avoir en double |
|||
'-*' ) # ignore |
|||
;; |
|||
*) |
|||
ORGA="${ARG%-orga}" |
|||
DockerServName="${ORGA}-$castopodServName}" |
|||
WPCOMMUN= |
|||
;; |
|||
esac |
|||
done |
|||
|
|||
if [ -z "${COMMANDS}" ]; then usage && exit ; fi |
|||
|
|||
for COMMAND in ${COMMANDS}; do |
|||
case "${COMMAND}" in |
|||
'VERSION' ) |
|||
Version && exit ;; |
|||
'INIT' ) |
|||
Init ;; |
|||
esac |
|||
done |
@ -0,0 +1 @@ |
|||
../../config/dockers.env |
@ -0,0 +1,57 @@ |
|||
services: |
|||
app: |
|||
image: castopod/castopod:latest |
|||
container_name: ${castopodServName} |
|||
volumes: |
|||
- castopod-media:/var/www/castopod/public/media |
|||
environment: |
|||
CP_BASEURL: "https://${castopodHost}.${domain}" |
|||
CP_ANALYTICS_SALT: qldsgfliuzrbhgmkjbdbmkvb |
|||
VIRTUAL_PORT: 8000 |
|||
CP_CACHE_HANDLER: redis |
|||
CP_REDIS_HOST: redis |
|||
env_file: |
|||
- ../../secret/env-${castopodServName} |
|||
- ../../secret/env-${castopodDBName} |
|||
networks: |
|||
- castopodNet |
|||
expose: |
|||
- 8000 |
|||
restart: unless-stopped |
|||
labels: |
|||
- "traefik.enable=true" |
|||
- "traefik.http.routers.${castopodServName}.rule=Host(`${castopodHost}.${domain}`)" |
|||
- "traefik.docker.network=castopodNet" |
|||
|
|||
mariadb: |
|||
image: mariadb:10.5 |
|||
container_name: ${castopodDBName} |
|||
networks: |
|||
- castopodNet |
|||
volumes: |
|||
- castopod-db:/var/lib/mysql |
|||
env_file: |
|||
- ../../secret/env-${castopodDBName} |
|||
restart: unless-stopped |
|||
|
|||
redis: |
|||
image: redis:7.0-alpine |
|||
container_name: castopodCache |
|||
volumes: |
|||
- castopod-cache:/data |
|||
networks: |
|||
- castopodNet |
|||
env_file: |
|||
- ../../secret/env-${castopodServName} |
|||
command: --requirepass ${castopodRedisPassword} |
|||
|
|||
volumes: |
|||
castopod-media: |
|||
castopod-db: |
|||
castopod-cache: |
|||
|
|||
networks: |
|||
castopodNet: |
|||
external: true |
|||
name: castopodNet |
|||
|
@ -0,0 +1,13 @@ |
|||
#!/bin/bash |
|||
|
|||
KAZ_ROOT=$(cd $(dirname $0)/../..; pwd) |
|||
. "${KAZ_ROOT}/bin/.commonFunctions.sh" |
|||
setKazVars |
|||
|
|||
cd $(dirname $0) |
|||
. "${DOCKERS_ENV}" |
|||
. "${KAZ_KEY_DIR}/SetAllPass.sh" |
|||
|
|||
"${KAZ_BIN_DIR}/gestContainers.sh" --install -M -castopod |
|||
|
|||
|
@ -0,0 +1,4 @@ |
|||
MYSQL_ROOT_PASSWORD= |
|||
MYSQL_DATABASE= |
|||
MYSQL_USER= |
|||
MYSQL_PASSWORD= |
@ -0,0 +1,7 @@ |
|||
CP_EMAIL_SMTP_HOST= |
|||
CP_EMAIL_FROM= |
|||
CP_EMAIL_SMTP_USERNAME= |
|||
CP_EMAIL_SMTP_PASSWORD= |
|||
CP_EMAIL_SMTP_PORT= |
|||
CP_EMAIL_SMTP_CRYPTO= |
|||
CP_REDIS_PASSWORD= |
Loading…
Reference in new issue