From 7bcddf4e7baa92ea05d55e25fdabc0ac563056da Mon Sep 17 00:00:00 2001
From: TonyFord <tonyford@strategy-investor.de>
Date: Sun, 19 Jul 2020 16:33:33 +0200
Subject: [PATCH] add manual control

---
 README.md              | 17 +++++++++++++++++
 control.sh             | 34 ++++++++++++++++++++++++++++++++++
 docker-compose.yml     |  2 +-
 env/FAIRCOIN_CONF      |  1 +
 env/FAIRCOIN_PORT      |  1 +
 env_file/FAIRCOIN_CONF |  5 +++++
 6 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 control.sh
 create mode 100644 env/FAIRCOIN_CONF
 create mode 100644 env/FAIRCOIN_PORT
 create mode 100644 env_file/FAIRCOIN_CONF

diff --git a/README.md b/README.md
index e5bab41..737159d 100644
--- a/README.md
+++ b/README.md
@@ -30,3 +30,20 @@ Go Gitlab **Settings** -> **CI/CD** -> **Variables**
 FAIRCOIN_CONF        # faircoin.conf file
 FAIRCOIN_PORT        # faircoind -port
 ~~~
+
+## Development <small>( manual usage )</small>
+
+If you want create an instance manual then follow the  instructions.
+
+1. clone this project
+2. change configuration in ./env
+3. run services by ./control.sh
+
+~~~
+chmod +x ./control.sh
+./control.sh build
+./control.sh start
+./control.sh stop
+./control.sh uninstall
+./control.sh remove
+~~~
diff --git a/control.sh b/control.sh
new file mode 100644
index 0000000..1efba97
--- /dev/null
+++ b/control.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+export RUNNER_UID=`id -u`
+export RUNNER_GID=`id -g`
+export `cat ./env/*`
+
+case $1 in
+  "build")
+      mkdir -p ~/.faircoin2
+      chmod +x ./script/blocknotify.sh
+      docker-compose stop
+      docker-compose down
+      docker-compose build
+    ;;
+  "start")
+      chmod +x ./script/blocknotify.sh
+      docker-compose stop
+      docker-compose down
+      source ${FAIRCOIN_CONF}
+      if [ ! -f "~/.faircoin2/faircoin.conf" ]; then echo -e "rpcconnect=${rpcconnect}\nrpcport=${rpcport}\nrpcuser=${rpcuser}\nrpcpassword=${rpcpassword}\ntxindex=1" > ~/.faircoin2/faircoin.conf; fi
+      docker-compose up -d
+    ;;
+  "stop")
+      docker-compose stop
+    ;;
+  "uninstall")
+      docker-compose stop
+      docker-compose down
+    ;;
+  "remove")
+      docker-compose stop
+      docker-compose down
+#      rm -R ~/.faircoin2  #### dont use this command if you have some wallet.dat in your ~/.faircoin2 folder !!! In this case remove the block databases manually.
+    ;;
+esac
diff --git a/docker-compose.yml b/docker-compose.yml
index 8f77371..bacf926 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -11,7 +11,7 @@ services:
         RUNNER_GID: "${RUNNER_GID}"
         FAIRCOIN_PORT: ${FAIRCOIN_PORT}
     env_file:
-      - ../faircoind.tmp/FAIRCOIN_CONF
+      - ${FAIRCOIN_CONF}
     container_name: FairCoin.Co-faircoind
     restart: always
     command: '-disablewallet -port=${FAIRCOIN_PORT} -blocknotify=/home/faircoin/script/blocknotify.sh'
diff --git a/env/FAIRCOIN_CONF b/env/FAIRCOIN_CONF
new file mode 100644
index 0000000..6d9dea6
--- /dev/null
+++ b/env/FAIRCOIN_CONF
@@ -0,0 +1 @@
+FAIRCOIN_CONF=./env_file/FAIRCOIN_CONF
diff --git a/env/FAIRCOIN_PORT b/env/FAIRCOIN_PORT
new file mode 100644
index 0000000..6f8e1a6
--- /dev/null
+++ b/env/FAIRCOIN_PORT
@@ -0,0 +1 @@
+FAIRCOIN_PORT=40404
diff --git a/env_file/FAIRCOIN_CONF b/env_file/FAIRCOIN_CONF
new file mode 100644
index 0000000..2a64685
--- /dev/null
+++ b/env_file/FAIRCOIN_CONF
@@ -0,0 +1,5 @@
+rpcconnect=0.0.0.0
+rpcport=8332
+rpcuser=faircoin
+rpcpassword=password
+txindex=1
-- 
GitLab