stage/autorun.sh
changeset 5 7d3b7009399d
parent 4 c6c431cf0a89
equal deleted inserted replaced
4:c6c431cf0a89 5:7d3b7009399d
    27 ## SCRIPT
    27 ## SCRIPT
    28 
    28 
    29 cd `dirname $0`
    29 cd `dirname $0`
    30 
    30 
    31 echo "Welcome to the Enano CMS BitNami module installer."
    31 echo "Welcome to the Enano CMS BitNami module installer."
       
    32 if [ ! -d ./enano-* ]; then
       
    33 	HG_BASE=${HG_BASE:-http://hg.enanocms.org/repos}
       
    34 	cat <<EOF
       
    35 This is the Mercurial-based installer. It doesn't include the Enano source
       
    36 tree - instead it's created based on the latest Mercurial sources. To use this
       
    37 installer, you must have Mercurial on your system.
       
    38 
       
    39 The current repository path is ${HG_BASE}.
       
    40 To override it, set HG_BASE.
       
    41 
       
    42 You can safely Control-C out of this installer at any time and temporary files
       
    43 will be cleaned up.
       
    44 
       
    45 EOF
       
    46 fi
       
    47 
    32 autobitnami=""
    48 autobitnami=""
    33 if test -n "$HOME"; then
    49 if test -n "$HOME"; then
    34   autobitnami=$(echo $HOME/lampstack-*)
    50   autobitnami=`echo $HOME/lampstack-*`
    35   if test ! -d "$autobitnami"; then
    51   if test ! -d "$autobitnami"; then
    36     autobitnami=""
    52     autobitnami=""
    37   fi
    53   fi
       
    54 fi
       
    55 if test -d /Applications/; then
       
    56 	autobitnami=`echo /Applications/mampstack-*`
       
    57 	if test ! -d "$autobitnami"; then
       
    58 		autobitnami=""
       
    59 	fi
    38 fi
    60 fi
    39 while true; do
    61 while true; do
    40   if test -n "$autobitnami"; then
    62   if test -n "$autobitnami"; then
    41     read -p "Path to BitNami directory [$autobitnami]: " bitnami
    63     read -p "Path to BitNami directory [$autobitnami]: " bitnami
    42     test -z "$bitnami" && bitnami="$autobitnami"
    64     test -z "$bitnami" && bitnami="$autobitnami"
    60   out=`$mysqladmin -u root --password="$mysqlpass" ping 2>&1`
    82   out=`$mysqladmin -u root --password="$mysqlpass" ping 2>&1`
    61   test "$out" = "mysqld is alive" && break
    83   test "$out" = "mysqld is alive" && break
    62   echo $out
    84   echo $out
    63 done
    85 done
    64 
    86 
       
    87 my_tr()
       
    88 {
       
    89 	# this is needed under OS X, its terminal emulator tends to mess up tr
       
    90 	LC_ALL=C tr $@
       
    91 	return $?
       
    92 }
       
    93 
    65 echo "Creating database."
    94 echo "Creating database."
    66 
    95 
    67 bitnami_db="bn_enanocms"
    96 bitnami_db="bn_enanocms"
    68 bitnami_user="bn_enanocms"
    97 bitnami_user="bn_enanocms"
    69 bitnami_pass=`dd if=/dev/urandom bs=256 count=1 2>/dev/null | tr -cd '\41-\46\50-\176' | cut -c 1-12`
    98 bitnami_pass=`dd if=/dev/urandom bs=256 count=1 2>/dev/null | my_tr -cd '\41-\46\50-\176' | cut -c 1-12`
    70 
    99 
    71 query='CREATE DATABASE IF NOT EXISTS `'$bitnami_db'`; GRANT ALL PRIVILEGES ON '$bitnami_db'.* TO '"$bitnami_user"'@localhost IDENTIFIED BY '"'$bitnami_pass'"'; FLUSH PRIVILEGES;'
   100 query='CREATE DATABASE IF NOT EXISTS `'$bitnami_db'`; GRANT ALL PRIVILEGES ON '$bitnami_db'.* TO '"$bitnami_user"'@localhost IDENTIFIED BY '"'$bitnami_pass'"'; FLUSH PRIVILEGES;'
    72 echo "$query" | $mysql -u root --password="$mysqlpass" || exit 1
   101 echo "$query" | $mysql -u root --password="$mysqlpass" || exit 1
    73 
   102 
    74 echo "Installing files."
   103 echo "Installing files."
    75 mkdir -p $bitnami/apps/enanocms/{conf,licenses} || exit 1
   104 mkdir -p $bitnami/apps/enanocms/{conf,licenses} || exit 1
    76 cp -r ./enano-* $bitnami/apps/enanocms/htdocs || exit 1
   105 if [ -d ./enano-* ]; then
       
   106 	cp -r ./enano-* $bitnami/apps/enanocms/htdocs || exit 1
       
   107 else
       
   108 	# There's no Enano source tree in this installer. Pull the latest from Mercurial.
       
   109 	oldpwd=`pwd`
       
   110 	cd $bitnami/apps/enanocms || exit 1
       
   111 	curl -q -o mkenanodev.sh http://hg.enanocms.org/mkenanodev.sh || exit 1
       
   112 	chmod u+x mkenanodev.sh || exit 1
       
   113 	./mkenanodev.sh 1.1 $HG_BASE || exit 1
       
   114 	rm -f mkenanodev.sh
       
   115 	mv enano-1.1 htdocs || exit 1
       
   116 	
       
   117 	cd $oldpwd
       
   118 fi
    77 cp ./COPYING $bitnami/apps/enanocms/licenses/ || exit 1
   119 cp ./COPYING $bitnami/apps/enanocms/licenses/ || exit 1
    78 cat <<EOF > $bitnami/apps/enanocms/conf/enanocms.conf
   120 cat <<EOF > $bitnami/apps/enanocms/conf/enanocms.conf
    79 Alias /enanocms "$bitnami/apps/enanocms/htdocs"
   121 Alias /enanocms "$bitnami/apps/enanocms/htdocs"
    80 
   122 
    81 <Directory "$bitnami/apps/enanocms/htdocs">
   123 <Directory "$bitnami/apps/enanocms/htdocs">