Up.sh

From PKC
Revision as of 05:58, 26 March 2021 by Admin (talk | contribs) (Created page with "This script is the only script you need to run to launch the Docker Services that gives you MediaWiki functionalities on your own machine. <SyntaxHighlight> docker exec docke...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This script is the only script you need to run to launch the Docker Services that gives you MediaWiki functionalities on your own machine.

docker exec dockerizedwiki_mediawiki_1 /var/www/html/extensions/BackupAndRestore/backup.sh
  1. ! /bin/bash
  1. Check if docker is installed or not

if $(which docker) && $(docker --version) ; then

 echo "$OSTYPE has $(docker --version) installed"
 else
   echo "You need to Install docker"
   # command
   case "$OSTYPE" in
     darwin*)  echo "$OSTYPE should install Docker Desktop by following this link https://docs.docker.com/docker-for-mac/install/" ;; 
     msys*)    echo "$OSTYPE should install Docker Desktop by following this link https://docs.docker.com/docker-for-windows/install/" ;;
     cygwin*)  echo "$OSTYPE should install Docker Desktop by following this link https://docs.docker.com/docker-for-windows/install/" ;;
     linux*)
       echo "Some $OSTYPE distributions could install Docker, we will try to install Docker for you..." 
       ./scripts/installDockerForUbuntu.sh   
       echo "Installation complete, setting up the sudo su command, you will need the root access to this linux machine."
       sudo su ;;
     *)        echo "Sorry, this $OSTYPE might not have Docker implementation" ;;
   esac

fi


  1. If docker is running already, first run a data dump before shutting down docker processes
  2. One can use the following instruction to find the current directory name withou the full path
  3. CURRENTDIR=${PWD##*/}
  4. In Bash v4.0 or later, lower case can be obtained by a simple ResultString="${OriginalString,,}"
  5. See https://stackoverflow.com/questions/2264428/how-to-convert-a-string-to-lower-case-in-bash
  6. However, it will not work in Mac OS X, since it is still using Bash v 3.2

LOWERCASE_CURRENTDIR="$(tr [A-Z] [a-z] <<< "${PWD##*/}")" MW_CONTAINER=$LOWERCASE_CURRENTDIR"_mediawiki_1"

  1. This variable should have the same value as the variable $wgResourceBasePath in LocalSettings.php

ResourceBasePath="/var/www/html"

BACKUPSCRIPTFULLPATH=$ResourceBasePath"/extensions/BackupAndRestore/backup.sh" RESOTRESCRIPTFULLPATH=$ResourceBasePath"/extensions/BackupAndRestore/restore.sh"

echo "Executing: " docker exec $MW_CONTAINER $BACKUPSCRIPTFULLPATH docker exec $MW_CONTAINER $BACKUPSCRIPTFULLPATH

  1. stop all docker processes

docker-compose down --volumes

  1. If the mountPoint directory doesn't exist,
  2. Decompress the InitialDataPackage to ./mountPoint

if [ ! -e ./mountPoint/ ]; then tar -xzvf ./InitialDataPackage.tar.gz -C . fi

  1. Start the docker processes

docker-compose up -d

  1. After docker processes are ready, reload the data from earlier dump

echo "Loading data from earlier backups..." echo "Executing: " docker exec $MW_CONTAINER $RESOTRESCRIPTFULLPATH docker exec $MW_CONTAINER $RESOTRESCRIPTFULLPATH </SyntaxHighlight>