From: Matteo Nastasi (mop) Date: Wed, 7 Dec 2011 18:34:07 +0000 (+0100) Subject: installer added X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=xynt.git;a=commitdiff_plain;h=0760f567c11c11aea0ec872c9e9031cdd4853eb7 installer added --- diff --git a/INSTALL.sh b/INSTALL.sh new file mode 100755 index 0000000..987f82e --- /dev/null +++ b/INSTALL.sh @@ -0,0 +1,147 @@ +#!/bin/bash +# set -x +# +# Defaults +# +CONFIG_FILE="$HOME/.xynt_install" + +web_path="/home/nastasi/web/brosk" + +if [ "$1" = "pkg" ]; then + if [ "$2" != "" ]; then + tag="$2" + else + tag="$(git describe)" + fi + nam1="xynt_${tag}.tgz" + echo "Build packages ${nam1}." + read -p "Proceed [y/n]: " a + if [ "$a" != "y" -a "$a" != "Y" ]; then + exit 1 + fi + git archive --format=tar --prefix=xynt-${tag}/ $tag | gzip > ../$nam1 + exit 0 +fi + +if [ -f "$CONFIG_FILE" ]; then + source "$CONFIG_FILE" +fi + +function usage () { + echo + echo "$1 -h" + echo "$1 pkg - build xynt package." + echo "$1 [-p outfile] [-f conffile] [-w web_dir]" + echo " -h this help" + echo " -f use this config file" + echo " -p save preferences in the file" + echo " -w dir where place the web tree - def. \"$web_path\"" + + echo +} + +function get_param () { + echo "X$2" | grep -q "^X$1\$" + if [ $? -eq 0 ]; then + # echo "DECHE" >&2 + echo "$3" + return 2 + else + # echo "DELA" >&2 + echo "$2" | cut -c 3- + return 1 + fi + return 0 +} + +function searchetc() { + local dstart dname pp + dstart="$1" + dname="$2" + + pp="$dstart" + while [ "$pp" != "/" ]; do + if [ -d "$pp/$dname" ]; then + echo "$pp/$dname" + return 0 + fi + pp="$(dirname "$pp")" + done + + return 1 +} + +# +# MAIN +# +while [ $# -gt 0 ]; do + # echo aa $1 xx $2 bb + conffile="" + case $1 in + -f*) conffile="$(get_param "-f" "$1" "$2")"; sh=$?;; + -p*) outconf="$(get_param "-p" "$1" "$2")"; sh=$?;; + -w*) web_path="$(get_param "-w" "$1" "$2")"; sh=$?;; + -h) usage $0; exit 0;; + *) usage $0; exit 1;; + esac + if [ ! -z "$conffile" ]; then + if [ ! -f "$conffile" ]; then + echo "config file [$conffile] not found" + exit 1 + fi + . "$conffile" + fi + shift $sh +done + +# +# Show parameters +# +echo " outconf: \"$outconf\"" +echo " web_path: \"$web_path\"" + +if [ ! -z "$outconf" ]; then + ( + echo "#" + echo "# Produced automatically by xynt::INSTALL.sh" + echo "#" + echo "web_path=\"$web_path\"" + ) > "$outconf" +fi + +max_players=$((40 + players_n * tables_n)) +# +# Pre-check +# +# check for etc path existence +# dsta="$(dirname "$web_path")" +# etc_path="$(searchetc "$dsta" Etc)" +# if [ $? -ne 0 ]; then +# echo "Etc directory not found" +# exit 1 +# fi + +# +# Installation +# +if [ -d ${web_path}.old ]; then + rm -rf ${web_path}.old +fi + +if [ -d ${web_path} ]; then + mv ${web_path} ${web_path}.old +fi + +for i in $(find web -type d | sed 's/^....//g'); do + install -d ${web_path}/$i +done + +for i in $(find web -name '*.html' -o -name '*.php' -o -name '*.phh' -o -name '*.pho' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' -o -name '.htaccess' | sed 's/^....//g'); do + install -m 644 "web/$i" "${web_path}/$i" +done + + +# .js substitutions +sed -i '/^[\t \/]*console.log.*;[\t ]*$/d' $(find ${web_path} -type f -name '*.js' -exec grep -l '^[\t /]*console.log.*;[\t ]*$' {} \;) + +exit 0