Commit d0448d84 authored by thomas craipeau's avatar thomas craipeau
Browse files
parents 62101f5f 176b9fcb
......@@ -5,7 +5,8 @@ asciiart
## Options:
## -h, --help aide
## --install install
## --import-list-cities importe ou reimporte base data list et cities
## --update update
## --update-data importe ou reimporte base data
## --add-cron Ajout de la tache cron pour l'envoi des mails
## --emailvalid=VALUE valide compte user avec le mail
......@@ -16,9 +17,10 @@ BASE_DIR="/code"
BASE_DIR_PH="${BASE_DIR}/pixelhumain/ph"
MODULE_DIR="/code/modules"
ph_dir="${BASE_DIR}/pixelhumain"
cmnctr_dir="co2"
co2_dir="co2"
[[ -n "$install" ]] && /usr/bin/install
[[ -n "$update" ]] && /usr/bin/update
[[ -n "$emailvalid" ]] && echo "Option specified: --emailvalid is $emailvalid"
if [ -n "$emailvalid" ]
......@@ -27,31 +29,31 @@ EVAL="db.citoyens.update({\"email\":\"$emailvalid\"},{\"\$unset\" :{\"roles.tobe
echo $EVAL | mongo mongo/pixelhumain --quiet
fi
if [ -n "$import_list_cities" ]
if [ -n "$update_data" ]
then
echo "Import data"
echo "Import lists data..."
if [ -f "${MODULE_DIR}/${cmnctr_dir}/data/lists.json" ]
if [ -f "${MODULE_DIR}/${co2_dir}/data/lists.json" ];
then
mongo mongo/pixelhumain <<EOF
db.lists.dropIndexes();
db.lists.remove({});
EOF
mongoimport --host mongo --db pixelhumain --collection lists "${MODULE_DIR}/${cmnctr_dir}/data/lists.json" --jsonArray
mongoimport --host mongo --db pixelhumain -u pixelhumain -p pixelhumain --collection lists "${MODULE_DIR}/${co2_dir}/data/lists.json" --jsonArray
fi
#Test cities.json
if [ -f "${MODULE_DIR}/${cmnctr_dir}/data/cities.json" ];then
rm "${MODULE_DIR}/${cmnctr_dir}/data/cities.json"
if [ -e "${MODULE_DIR}/${co2_dir}/data/cities.json" ];
then
rm "${MODULE_DIR}/${co2_dir}/data/cities.json"
fi
if [ -f "${MODULE_DIR}/${cmnctr_dir}/data/cities.json.zip" ];then
if [ -f "${MODULE_DIR}/${co2_dir}/data/cities.json.zip" ];
then
unzip "${MODULE_DIR}/${cmnctr_dir}/data/cities.json.zip" -d "${MODULE_DIR}/${cmnctr_dir}/data/"
unzip "${MODULE_DIR}/${co2_dir}/data/cities.json.zip" -d "${MODULE_DIR}/${co2_dir}/data/"
#delete cities and delete all index cities
mongo mongo/pixelhumain <<EOF
......@@ -61,14 +63,59 @@ EOF
echo "Import cities data..."
#import cities
mongoimport --host mongo --db pixelhumain --collection cities "${MODULE_DIR}/${cmnctr_dir}/data/cities.json" --jsonArray
mongoimport --host mongo --db pixelhumain -u pixelhumain -p pixelhumain --collection cities "${MODULE_DIR}/${co2_dir}/data/cities.json"
fi
#Test zones.json
if [ -f "${MODULE_DIR}/${co2_dir}/data/zones.json" ];
then
rm "${MODULE_DIR}/${co2_dir}/data/zones.json"
fi
if [ -f "${MODULE_DIR}/${co2_dir}/data/zones.json.zip" ];
then
unzip "${MODULE_DIR}/${co2_dir}/data/zones.json.zip" -d "${MODULE_DIR}/${co2_dir}/data/"
#delete cities and delete all index cities
mongo mongo/pixelhumain <<EOF
db.zones.dropIndexes();
db.zones.remove({});
EOF
echo "Import zones data..."
#import zones
mongoimport --host mongo --db pixelhumain -u pixelhumain -p pixelhumain --collection zones "${MODULE_DIR}/${co2_dir}/data/zones.json"
fi
#Test translate.json
if [ -f "${MODULE_DIR}/${co2_dir}/data/translate.json" ];
then
rm "${MODULE_DIR}/${co2_dir}/data/translate.json"
fi
if [ -f "${MODULE_DIR}/${co2_dir}/data/translate.json.zip" ];
then
unzip "${MODULE_DIR}/${co2_dir}/data/translate.json.zip" -d "${MODULE_DIR}/${co2_dir}/data/"
#delete cities and delete all index cities
mongo mongo/pixelhumain <<EOF
db.translate.dropIndexes();
db.translate.remove({});
EOF
echo "Import translate data..."
#import cities
mongoimport --host mongo --db pixelhumain -u pixelhumain -p pixelhumain --collection translate "${MODULE_DIR}/${co2_dir}/data/translate.json"
fi
#create index mongo bash script
if [ -f "${MODULE_DIR}/${cmnctr_dir}/data/createIndexMongoDocker.sh" ];then
if [ -f "${MODULE_DIR}/${co2_dir}/data/createIndexMongoDocker.sh" ];
then
echo "Create index mongo...";
chmod +x "${MODULE_DIR}/${cmnctr_dir}/data/createIndexMongoDocker.sh"
"${MODULE_DIR}/${cmnctr_dir}/data/createIndexMongoDocker.sh"
chmod +x "${MODULE_DIR}/${co2_dir}/data/createIndexMongoDocker.sh"
"${MODULE_DIR}/${co2_dir}/data/createIndexMongoDocker.sh"
fi
fi
......
......@@ -5,76 +5,14 @@ asciiart
BASE_DIR="/code"
BASE_DIR_PH="${BASE_DIR}/pixelhumain/ph"
MODULE_DIR="/code/modules"
ph_uri="https://gitlab.adullact.net/pixelhumain/pixelhumain.git"
ph_dir="${BASE_DIR}/pixelhumain"
cmnctr_uri="https://gitlab.adullact.net/pixelhumain/communecter.git"
cmnctr_dir="communecter"
co2_uri="https://gitlab.adullact.net/pixelhumain/co2.git"
co2_dir="co2"
api_uri="https://gitlab.adullact.net/pixelhumain/api.git"
api_dir="api"
#network_uri="https://gitlab.adullact.net/pixelhumain/network.git"
#network_dir="network"
ctzntkt_uri="https://gitlab.adullact.net/pixelhumain/citizenToolkit.git"
ctzntkt_dir="citizenToolKit"
dda_uri="https://gitlab.adullact.net/pixelhumain/dda.git"
dda_dir="dda"
news_uri="https://gitlab.adullact.net/pixelhumain/news.git"
news_dir="news"
graph_uri="https://gitlab.adullact.net/pixelhumain/graph.git"
graph_dir="graph"
interop_uri="https://gitlab.adullact.net/pixelhumain/interop.git"
interop_dir="interop"
eco_uri="https://gitlab.adullact.net/pixelhumain/eco.git"
eco_dir="eco"
chat_uri="https://gitlab.adullact.net/pixelhumain/chat.git"
chat_dir="chat"
survey_uri="https://gitlab.adullact.net/pixelhumain/survey.git"
survey_dir="survey"
map_uri="https://gitlab.adullact.net/pixelhumain/map.git"
map_dir="map"
onepage_uri="https://gitlab.adullact.net/pixelhumain/onepage.git"
onepage_dir="onepage"
places_uri="https://gitlab.adullact.net/pixelhumain/places.git"
places_dir="places"
learn_uri="https://gitlab.adullact.net/pixelhumain/learn.git"
learn_dir="learn"
cotools_uri="https://gitlab.adullact.net/pixelhumain/cotools.git"
cotools_dir="cotools"
#git clone https://gitlab.adullact.net/pixelhumain/classifieds.git
#git clone https://gitlab.adullact.net/pixelhumain/ressources.git
modules="cmnctr ctzntkt co2 api dda news interop graph eco chat survey map onepage places learn cotools"
# Install pixelhumain
if [ -d "${ph_dir}" ]
then
echo "Déja cloner"
else
git clone "$ph_uri" "$ph_dir"
fi
# Install repo and modules
git clone --recurse-submodules https://gitlab.adullact.net/pixelhumain/co-meta.git code
# Setup directories
mkdir -vp /code/{modules,pixelhumain/ph/{assets,upload,protected/runtime}}
# Install missing modules
for mod in $modules
do
mod_uri=$(eval "echo \$${mod}_uri")
mod_dir=$(eval "echo \$${mod}_dir")
if [ -d "${MODULE_DIR}/$mod_dir" ]; then
continue
fi
echo "Installing ${mod_dir}"
git clone "$mod_uri" "${MODULE_DIR}/$mod_dir" || exit 1
done
#lien
ln -s "${MODULE_DIR}/co2" "${MODULE_DIR}/network"
......@@ -230,7 +168,11 @@ echo "Communecte est maintenant disponible depuis http://localhost:5080"
echo "pour valider un user sans regler l'envoie d'email vous pouvez le valider avec : docker-compose -f docker-compose.yml -f docker-compose.install.yml run ph cotools --emailvalid=email@example.com "
echo "vous pouvez ajouter le cron pour les email avec : docker-compose -f docker-compose.yml -f docker-compose.install.yml run ph cotools --add-cron "
echo "pour update les repos : docker-compose -f docker-compose.yml -f docker-compose.install.yml run ph cotools --update "
echo "pour update les datas : docker-compose -f docker-compose.yml -f docker-compose.install.yml run ph cotools --update-data "
echo "pour pouvoir editer le code sur votre machine ou serveur :"
echo "sudo chown -R \${USER:=\$(/usr/bin/id -run)}:\$USER code/"
echo "sudo chown -R \${USER:=\$(/usr/bin/id -run)}:\$USER code/pixelhumain/"
echo "sudo chown -R \${USER:=\$(/usr/bin/id -run)}:\$USER code/modules/"
echo "sudo chown -R \${USER:=\$(/usr/bin/id -run)}:\$USER code/log/"
......
......@@ -2,144 +2,46 @@
BASE_DIR="/code"
BASE_DIR_PH="${BASE_DIR}/pixelhumain/ph"
MODULE_DIR="/code/modules"
ph_uri="https://gitlab.adullact.net/pixelhumain/pixelhumain.git"
ph_dir="${BASE_DIR}/pixelhumain"
cmnctr_uri="https://gitlab.adullact.net/pixelhumain/communecter.git"
cmnctr_dir="communecter"
co2_uri="https://gitlab.adullact.net/pixelhumain/co2.git"
co2_dir="co2"
api_uri="https://gitlab.adullact.net/pixelhumain/api.git"
api_dir="api"
network_uri="https://gitlab.adullact.net/pixelhumain/network.git"
network_dir="network"
ctzntkt_uri="https://gitlab.adullact.net/pixelhumain/citizenToolkit.git"
ctzntkt_dir="citizenToolKit"
dda_uri="https://gitlab.adullact.net/pixelhumain/dda.git"
dda_dir="dda"
news_uri="https://gitlab.adullact.net/pixelhumain/news.git"
news_dir="news"
graph_uri="https://gitlab.adullact.net/pixelhumain/graph.git"
graph_dir="graph"
interop_uri="https://gitlab.adullact.net/pixelhumain/interop.git"
interop_dir="interop"
eco_uri="https://gitlab.adullact.net/pixelhumain/eco.git"
eco_dir="eco"
chat_uri="https://gitlab.adullact.net/pixelhumain/chat.git"
chat_dir="chat"
survey_uri="https://gitlab.adullact.net/pixelhumain/survey.git"
survey_dir="survey"
map_uri="https://gitlab.adullact.net/pixelhumain/map.git"
map_dir="map"
onepage_uri="https://gitlab.adullact.net/pixelhumain/onepage.git"
onepage_dir="onepage"
modules="cmnctr ctzntkt co2 network api dda news interop graph eco chat survey map onepage"
# Update pixelhumain
echo "Update modules..."
if [ -d "${ph_dir}" ]; then
cd "${ph_dir}"
echo "Update repo modules..."
cd "${BASE_DIR}"
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$BRANCH" != "master" ]]; then
echo 'Aborting script branch not master';
exit 1;
fi
git fetch origin
git pull origin master
cd ../..
fi
# Update modules
for mod in $modules
do
mod_uri=$(eval "echo \$${mod}_uri")
mod_dir=$(eval "echo \$${mod}_dir")
if [ -d "${MODULE_DIR}/$mod_dir" ]; then
echo "Update ${mod_dir}"
cd "${MODULE_DIR}/$mod_dir"
git fetch origin
git pull origin master
cd ../../..
fi
done
echo "Import data"
echo "Import lists data..."
if [ -f "${MODULE_DIR}/${cmnctr_dir}/data/lists.json" ];then
mongo mongo/pixelhumain <<EOF
db.lists.dropIndexes();
db.lists.remove({});
EOF
mongoimport --host mongo --db pixelhumain --collection lists "${MODULE_DIR}/${cmnctr_dir}/data/lists.json" --jsonArray
fi
git pull --recurse-submodules
git submodule update --recursive --remote
#Test cities.json
if [ -f "${MODULE_DIR}/${cmnctr_dir}/data/cities.json" ];then
rm "${MODULE_DIR}/${cmnctr_dir}/data/cities.json"
fi
if [ -f "${MODULE_DIR}/${cmnctr_dir}/data/cities.json.zip" ];then
unzip "${MODULE_DIR}/${cmnctr_dir}/data/cities.json.zip" -d "${MODULE_DIR}/${cmnctr_dir}/data/"
#delete cities and delete all index cities
mongo mongo/pixelhumain <<EOF
db.cities.dropIndexes();
db.cities.remove({});
EOF
# Install Composer
echo "Import cities data..."
#import cities
mongoimport --host mongo --db pixelhumain --collection cities "${MODULE_DIR}/${cmnctr_dir}/data/cities.json" --jsonArray
if [ -f "/tmp/composer.phar" ];then
rm "/tmp/composer.phar"
fi
#Test zones.json
if [ -f "${MODULE_DIR}/${co2_dir}/data/zones.json" ];then
rm "${MODULE_DIR}/${co2_dir}/data/zones.json"
fi
if [ -f "${MODULE_DIR}/${co2_dir}/data/zones.json.zip" ];then
unzip "${MODULE_DIR}/${co2_dir}/data/zones.json.zip" -d "${MODULE_DIR}/${co2_dir}/data/"
echo "Installing composer" # No package manager available...
#delete cities and delete all index cities
mongo mongo/pixelhumain <<EOF
db.zones.dropIndexes();
db.zones.remove({});
EOF
EXPECTED_SIGNATURE=$(wget https://composer.github.io/installer.sig -O - -q)
cd /tmp
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
echo "Import zones data..."
#import zones
mongoimport --host mongo --db pixelhumain --collection zones "${MODULE_DIR}/${co2_dir}/data/zones.json" --jsonArray
if [ "$EXPECTED_SIGNATURE" = "$ACTUAL_SIGNATURE" ]
then
php composer-setup.php --quiet
rm composer-setup.php
else
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
#Test translate.json
if [ -f "${MODULE_DIR}/${co2_dir}/data/translate.json" ];then
rm "${MODULE_DIR}/${co2_dir}/data/translate.json"
fi
if [ -f "${MODULE_DIR}/${co2_dir}/data/translate.json.zip" ];then
unzip "${MODULE_DIR}/${co2_dir}/data/translate.json.zip" -d "${MODULE_DIR}/${co2_dir}/data/"
#delete cities and delete all index cities
mongo mongo/pixelhumain <<EOF
db.translate.dropIndexes();
db.translate.remove({});
EOF
echo "Setting up with Composer"
echo "Import translate data..."
#import cities
mongoimport --host mongo --db pixelhumain --collection translate "${MODULE_DIR}/${co2_dir}/data/translate.json" --jsonArray
fi
#create index mongo bash script
if [ -f "${MODULE_DIR}/${cmnctr_dir}/data/createIndexMongoDocker.sh" ];then
echo "Create index mongo...";
chmod +x "${MODULE_DIR}/${cmnctr_dir}/data/createIndexMongoDocker.sh"
"${MODULE_DIR}/${cmnctr_dir}/data/createIndexMongoDocker.sh"
fi
cd "${BASE_DIR_PH}"
/tmp/composer.phar config -g "secure-http" false
/tmp/composer.phar update
/tmp/composer.phar install
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment