about summary refs log tree commit diff stats
path: root/tools/scripts
diff options
context:
space:
mode:
authorSilvino Silva <silvino@bk.ru>2016-10-15 01:31:34 +0100
committerSilvino Silva <silvino@bk.ru>2016-10-15 01:57:43 +0100
commit3d29ecb8767d923f79b82566fd57b08db76b8fc5 (patch)
treeac92517562ecf2025320b3487c76e2ed02eed6ee /tools/scripts
parentda52c4b286dc1d3def59f20dbe25f033793c92cc (diff)
downloaddoc-3d29ecb8767d923f79b82566fd57b08db76b8fc5.tar.gz
tools revision
Diffstat (limited to 'tools/scripts')
-rw-r--r--tools/scripts/config-install.sh4
-rw-r--r--tools/scripts/install-postgres.sh16
-rw-r--r--tools/scripts/setup-gitolite.sh43
-rw-r--r--tools/scripts/setup-nginx.sh (renamed from tools/scripts/install-nginx.sh)0
-rw-r--r--tools/scripts/setup-openssh.sh43
-rw-r--r--tools/scripts/setup-php.sh (renamed from tools/scripts/install-php.sh)0
-rw-r--r--tools/scripts/setup-postgresql.sh87
-rw-r--r--tools/scripts/system-iptables.sh6
-rw-r--r--tools/scripts/system-qemu.sh65
9 files changed, 230 insertions, 34 deletions
diff --git a/tools/scripts/config-install.sh b/tools/scripts/config-install.sh
deleted file mode 100644
index 061081f..0000000
--- a/tools/scripts/config-install.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-CONF_DIR="$(dirname `dirname $0`)/conf"
-echo "CONF_DIR=$CONF_DIR\n"
diff --git a/tools/scripts/install-postgres.sh b/tools/scripts/install-postgres.sh
deleted file mode 100644
index 06666e0..0000000
--- a/tools/scripts/install-postgres.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-. `dirname $0`/config-install.sh
-
-prt-get depinst postgresql
-
-cp -R $CONF_DIR/etc/rc.d/postgresql /etc/rc.d/
-
-mkdir /srv/pgsql/
-touch /var/log/postgresql
-chown postgres:postgres /srv/pgsql /var/log/postgresql
-
-sudo -u postgres initdb -D /srv/pgsql/data
-
-cp $CONF_DIR/srv/pgsql/data/pg_hba.conf /srv/pgsql/data/
-chown postgres:postgres /srv/pgsql/data/pg_hba.conf
diff --git a/tools/scripts/setup-gitolite.sh b/tools/scripts/setup-gitolite.sh
new file mode 100644
index 0000000..c42db14
--- /dev/null
+++ b/tools/scripts/setup-gitolite.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# First we define the function
+ConfirmOrExit ()
+{
+    while true
+    do
+        echo -n "Please confirm (y or n) :"
+        read CONFIRM
+        case $CONFIRM in
+            y|Y|YES|yes|Yes) break ;;
+            n|N|no|NO|No)
+                echo "Aborting - you entered $CONFIRM"
+                exit
+                ;;
+            *) echo "Please enter only y or n"
+        esac
+    done
+    echo "You entered $CONFIRM. Continuing ..."
+}
+
+
+# Absolute path to this script, e.g. /home/user/bin/foo.sh
+SCRIPT=$(readlink -f "$0")
+# Absolute path this script is in, thus /home/user/bin
+SCRIPTPATH=$(dirname "$SCRIPT")
+
+DIR=$(dirname "$SCRIPTPATH");
+DIR_CONF=$DIR"/conf"
+
+echo "SCRIPT=$SCRIPT";
+echo "SCRIPTPATH=$SCRIPTPATH";
+echo "DIR=$DIR";
+echo "DIR_CONF=$DIR_CONF";
+ConfirmOrExit
+
+    prt-get depinst gitolite
+
+    mkdir -p /srv/gitolite
+    useradd -U -d /srv/gitolite gitolite
+    chown gitolite:gitolite /srv/gitolite
+
+exit 0;
diff --git a/tools/scripts/install-nginx.sh b/tools/scripts/setup-nginx.sh
index decacc1..decacc1 100644
--- a/tools/scripts/install-nginx.sh
+++ b/tools/scripts/setup-nginx.sh
diff --git a/tools/scripts/setup-openssh.sh b/tools/scripts/setup-openssh.sh
new file mode 100644
index 0000000..14afe8b
--- /dev/null
+++ b/tools/scripts/setup-openssh.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# First we define the function
+ConfirmOrExit ()
+{
+    while true
+    do
+        echo -n "Please confirm (y or n) :"
+        read CONFIRM
+        case $CONFIRM in
+            y|Y|YES|yes|Yes) break ;;
+            n|N|no|NO|No)
+                echo "Aborting - you entered $CONFIRM"
+                exit
+                ;;
+            *) echo "Please enter only y or n"
+        esac
+    done
+    echo "You entered $CONFIRM. Continuing ..."
+}
+
+
+# Absolute path to this script, e.g. /home/user/bin/foo.sh
+SCRIPT=$(readlink -f "$0")
+# Absolute path this script is in, thus /home/user/bin
+SCRIPTPATH=$(dirname "$SCRIPT")
+
+DIR=$(dirname "$SCRIPTPATH");
+DIR_CONF=$DIR"/conf"
+
+echo "SCRIPT=$SCRIPT";
+echo "SCRIPTPATH=$SCRIPTPATH";
+echo "DIR=$DIR";
+echo "DIR_CONF=$DIR_CONF";
+ConfirmOrExit
+
+
+    #installer overwrite system init script
+    cp -R $DIR_CONF/etc/ssh/sshd_config /etc/ssh/sshd_config
+
+    sh /etc/rc.d/sshd start
+
+exit 0;
diff --git a/tools/scripts/install-php.sh b/tools/scripts/setup-php.sh
index 4c28173..4c28173 100644
--- a/tools/scripts/install-php.sh
+++ b/tools/scripts/setup-php.sh
diff --git a/tools/scripts/setup-postgresql.sh b/tools/scripts/setup-postgresql.sh
new file mode 100644
index 0000000..4e1ee3a
--- /dev/null
+++ b/tools/scripts/setup-postgresql.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+# First we define the function
+ConfirmOrExit ()
+{
+    while true
+    do
+        echo -n "Please confirm (y or n) :"
+        read CONFIRM
+        case $CONFIRM in
+            y|Y|YES|yes|Yes) break ;;
+            n|N|no|NO|No)
+                echo "Aborting - you entered $CONFIRM"
+                exit
+                ;;
+            *) echo "Please enter only y or n"
+        esac
+    done
+    echo "You entered $CONFIRM. Continuing ..."
+}
+
+
+# Absolute path to this script, e.g. /home/user/bin/foo.sh
+SCRIPT=$(readlink -f "$0")
+# Absolute path this script is in, thus /home/user/bin
+SCRIPTPATH=$(dirname "$SCRIPT")
+
+DIR=$(dirname "$SCRIPTPATH");
+DIR_CONF=$DIR"/conf"
+
+echo "SCRIPT=$SCRIPT";
+echo "SCRIPTPATH=$SCRIPTPATH";
+echo "DIR=$DIR";
+echo "DIR_CONF=$DIR_CONF";
+ConfirmOrExit
+
+IS_INSTALL=$(prt-get isinst postgresql);
+echo $IS_INSTALL;
+if [ "$IS_INSTALL" = "package postgresql is installed" ]
+then
+    echo "updating postgresql"
+    OLD_VERSION=$(prt-get current postgresql);
+    echo $OLD_VERSION;
+
+    sudo -u postgres pg_dumpall > /srv/pgsql/dump-$OLD_VERSION.sql
+
+    sh /etc/rc.d/postgresql stop
+
+    #extra backup, in case ...
+    tar --xattrs -zcpf /srv/pgsql/data-$OLD_VERSION.tar.gz \
+                    --directory=/srv/pgsql/data .
+
+    rm -R /srv/pgsql/data
+
+    prt-get update postgresql
+
+    NEW_VERSION=$(prt-get current postgresql);
+    echo $NEW_VERSION;
+
+    sudo -u postgres initdb -D /srv/pgsql/data
+
+    rejmerge
+    #installer overwrite system init script
+    cp -R $DIR_CONF/etc/rc.d/postgresql /etc/rc.d/
+
+    sh /etc/rc.d/postgresql start
+    sleep 5
+
+    sudo -u postgres psql -d postgres -f /srv/pgsql/dump-$OLD_VERSION.sql
+
+else
+    echo "install postgresql and dependencies"
+    prt-get depinst postgresql
+
+    cp -R $DIR_CONF/etc/rc.d/postgresql /etc/rc.d/
+
+    mkdir /srv/pgsql/
+    touch /var/log/postgresql
+    chown postgres:postgres /srv/pgsql /var/log/postgresql
+
+    sudo -u postgres initdb -D /srv/pgsql/data
+
+    cp $DIR_CONF/srv/pgsql/data/pg_hba.conf /srv/pgsql/data/
+    chown postgres:postgres /srv/pgsql/data/pg_hba.conf
+fi
+
+exit 0;
diff --git a/tools/scripts/system-iptables.sh b/tools/scripts/system-iptables.sh
index 4ec3b79..429efde 100644
--- a/tools/scripts/system-iptables.sh
+++ b/tools/scripts/system-iptables.sh
@@ -339,9 +339,9 @@ $IPT -A OUTPUT -o ${PUB_IF} -p tcp --sport 1024:65535 --dport 1024:  -m state --
 # $IPT -A OUTPUT -o ${PUB_IF} -p tcp --dport 2100 -j ACCEPT
 # $IPT -A OUTPUT -o ${PUB_IF} -p tcp --dport 9990 -j ACCEPT
 #
-# echo "Allow wesnoth"
-# $IPT -A OUTPUT -o ${PUB_IF} -p tcp --dport 15000 -m state --state NEW -j ACCEPT
-# $IPT -A OUTPUT -o ${PUB_IF} -p tcp --dport 14998 -m state --state NEW -j ACCEPT
+ echo "Allow wesnoth"
+ $IPT -A OUTPUT -o ${PUB_IF} -p tcp --dport 15000 -m state --state NEW -j ACCEPT
+ $IPT -A OUTPUT -o ${PUB_IF} -p tcp --dport 14998 -m state --state NEW -j ACCEPT
 
 ##### END your rules ############
 # Less log of known traffic
diff --git a/tools/scripts/system-qemu.sh b/tools/scripts/system-qemu.sh
index 8c68e70..489af5e 100644
--- a/tools/scripts/system-qemu.sh
+++ b/tools/scripts/system-qemu.sh
@@ -1,15 +1,58 @@
 #!/bin/sh
-ISO=~/crux-3.2.iso
-IMG=~/crux-img.qcow2
 
-TAP=$1
+# First we define the function
+ConfirmOrExit ()
+{
+    while true
+    do
+        echo -n "Please confirm (y or n) :"
+        read CONFIRM
+        case $CONFIRM in
+            y|Y|YES|yes|Yes) break ;;
+            n|N|no|NO|No)
+                echo "Aborting - you entered $CONFIRM"
+                exit
+                ;;
+            *) echo "Please enter only y or n"
+        esac
+    done
+    echo "You entered $CONFIRM. Continuing ..."
+}
 
-echo "TAP: $TAP"
+SCRIPT=$(readlink -f "$0")
+# Absolute path this script is in, thus /home/user/bin
+SCRIPTPATH=$(dirname "$SCRIPT")
 
-qemu-system-x86_64 \
-    -enable-kvm \
-    -m 1024 \
-    -boot d \
-    -cdrom ${ISO} \
-    -hda ${IMG} \
-    -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
+DIR=$(dirname "$SCRIPTPATH");
+DIR_LOCAL="$(dirname $(dirname ${DIR}))/local";
+
+MEM=$1
+TAP=$2
+ISO_FILE="${DIR_LOCAL}/$3"
+IMG="${DIR_LOCAL}/$4"
+
+echo "MEM (512): $MEM"
+echo "TAP (tap1): $TAP"
+echo "ISO_FILE (crux-3.2.iso): $ISO_FILE"
+echo "IMG (crux-img.qcow2): $IMG"
+ConfirmOrExit
+
+if [ "$ISO_FILE" = "$DIR_LOCAL/" ]
+then
+    qemu-system-x86_64 \
+        -enable-kvm \
+        -m $MEM \
+        -boot c \
+        -hda ${IMG} \
+        -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
+else
+    qemu-system-x86_64 \
+        -enable-kvm \
+        -m $MEM \
+        -boot d \
+        -cdrom ${ISO_FILE} \
+        -hda ${IMG} \
+        -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
+fi
+
+exit 0;