Commit ec45b020 authored by TonyFord's avatar TonyFord
Browse files

deployment improvements

parent 7a330221
#!/bin/bash
### configuration files will created or overwritten if exists
cat ${FAIRCHAINS_CONF} > services/electrumfairchainsx/scripts/fairchains.conf
cat ${FAIRCHAINS_CONF} | sed -e s/netname/\#\ netname/g > services/electrumfairchainsx/scripts/faircoin.conf
export `cat env_file/FAIRCHAINS_CONF`
cat ${FAIRCHAINS_JSON} > services/electrumfairchainsx/scripts/${netname}.json
cat ${FAIRCHAINS_ELECTRUMX_JSON} > services/electrumfairchainsx/scripts/${netname}.electrumx.json
cat ${ELECTRUMFAIR_CONFIG} > services/electrumfairchainsx/scripts/config
docker-compose stop --timeout 30
export AUTOSTART=0
docker-compose up -d faircoin
docker-compose exec -T faircoin mv -f scripts/fairchains.conf .faircoin2/
docker-compose exec -T faircoin mv -f scripts/faircoin.conf .faircoin2/
docker-compose exec -T faircoin mv -f scripts/${netname}.json .faircoin2/
docker-compose exec -T faircoin mv -f scripts/${netname}.electrumx.json .faircoin2/
docker-compose exec -T faircoin mv -f scripts/config .electrumfair/
docker-compose stop faircoin
export AUTOSTART=1
docker-compose up -d faircoin
docker-compose up -d electrumfairchainsx
docker-compose up -d php-server
#!/bin/bash
docker-compose stop --timeout 30
#!/bin/bash
docker-compose stop --timeout 30
docker-compose down
......@@ -5,47 +5,53 @@ services:
php-server:
restart: always
container_name: faircoin-php
image: php:7
#image: php:7
build:
context: ./services/php-server
command: php -S 0.0.0.0:4000 -t /var/www/html
environment:
PASSWORD: ${PASSWORD:-password}
ports:
- ${LH_PORT_jsonrpc}:4000
- ${LH_PORT_jsonrpc:-4000}:4000
volumes:
- ./html:/var/www/html
faircoin:
restart: always
build:
context: ./services/faircoin
args:
RUNNER_UID: ${RUNNER_UID:-1000}
RUNNER_GID: ${RUNNER_GID:-1000}
environment:
AUTOSTART: ${AUTOSTART:-1}
container_name: faircoin-faircoind-electrumfair
restart: always
command: sleep inf
user: "${RUNNER_UID:-1000}:${RUNNER_GID:-1000}"
volumes:
- ./services/_init/.faircoin2:/home/faircoin/_init/.faircoin2
- ./services/_init/.electrumfair:/home/faircoin/_init/.electrumfair
- faircoin2:/home/faircoin/.faircoin2
- fairchains:/home/faircoin/.faircoin2
- electrumfair:/home/faircoin/.electrumfair
- ./services/electrumfairchainsx/scripts:/home/faircoin/scripts
electrumfairchainsx:
restart: always
build:
context: ./services/electrumfairchainsx
args:
RUNNER_UID: "${RUNNER_UID}"
RUNNER_GID: "${RUNNER_GID}"
RUNNER_UID: "${RUNNER_UID:-1000}"
RUNNER_GID: "${RUNNER_GID:-1000}"
depends_on:
- faircoin
container_name: faircoin-electrumfairchainsx
restart: always
command: ./efcx_server
#ports:
# - 51811:51811
# - 51812:51812
user: "${RUNNER_UID:-1000}:${RUNNER_GID:-1000}"
volumes:
- ./services/_init/.faircoin2:/home/faircoin/_init/.faircoin2
- faircoin2:/home/faircoin/.faircoin2
- fairchains:/home/faircoin/.fairchains
- ./services/electrumfairchainsx/scripts:/home/faircoin/scripts
- ${SSL_CONF}:/home/faircoin/scripts/ssl.conf
volumes:
faircoin2:
fairchains:
electrumfair:
ELECTRUMFAIR_CONFIG=./env_file/ELECTRUMFAIR_CONFIG
FAIRCHAINS_CONF=./env_file/FAIRCHAINS_CONF
FAIRCHAINS_ELECTRUMX_JSON=./env_file/FAIRCHAINS_ELECTRUMX_JSON
FAIRCHAINS_JSON=./env_file/FAIRCHAINS_JSON
LH_PORT_jsonrpc=4003
SSL_CONF=./env_file/SSL_CONF
rpcconnect=faircoin
rpcallowip=0.0.0.0/0
rpcport=8332
rpcuser=user
rpcconnect=faircoin
rpcport=8399
rpcuser=faircoin
rpcpassword=password
txindex=1
......
......@@ -10,27 +10,21 @@
"pruning": "-",
"s": "51812",
"t": "51811",
"version": "1.4"
"version": "1.1"
},
"electrumfair.punto0.org": {
"pruning": "-",
"s": "51812",
"t": "51811",
"version": "1.4.2"
},
"electrum.faircoin.co": {
"pruning": "-",
"s": "51812",
"t": "51811",
"version": "1.4"
"version": "1.1"
}
},
"SERVICES" : [
"rpc://0.0.0.0:8002",
"tcp://0.0.0.0:51811"
"rpc://127.0.0.1:8000",
"ssl://:51812"
],
"REPORT_SERVICES" :
[
"ssl://electrum.faircoin.co:51812"
"ssl://electrum.faircoin.world:51812"
]
}
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
C = DE
ST = Saxony
L = Dresden
O = faircoin.co
OU = faircoin.co
CN = electrum.faircoin.co
[v3_req]
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = electrum.faircoin.co
DNS.2 = 0.0.0.0
......@@ -201,9 +201,9 @@ class electrumfair
return json_decode( $this->electrumfair(), true )['result'];
}
*/
function signmessage($address, $message){
function signmessage($address, $message, $password=false){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array( 'address' => $address, 'message' => $message, 'password' => getenv('PASSWORD') );
$this->param['params']=Array( 'address' => $address, 'message' => $message, 'password' => ( !$password ? getenv('PASSWORD') : $password ) );
return json_decode( $this->electrumfair(), true )['result'];
}
function verifymessage($address, $message, $signature){
......@@ -359,7 +359,7 @@ class electrumfair
function history(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
return json_decode( json_decode( $this->electrumfair(), true )['result'], true );
}
function getmpk(){
......@@ -373,20 +373,20 @@ class electrumfair
return json_decode( $this->electrumfair(), true )['result'];
}
function payto($address, $amount){
function payto($address, $amount, $password=false ){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('destination' => $address, 'amount' => $amount );
return json_decode( $this->electrumfair(), true )['result'];
$this->param['params']=Array('destination' => $address, 'amount' => $amount, 'password' => ( !$password ? getenv('PASSWORD') : $password ), 'unsigned' => true );
return json_decode( $this->electrumfair(), true );
}
function paytomany($Payment){
function paytomany($Payment, $password=false ){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array($Payment);
return json_decode( $this->electrumfair(), true )['result'];
$this->param['params']=Array('outputs' => $Payment, 'password' => ( !$password ? getenv('PASSWORD') : $password ) );
return json_decode( $this->electrumfair(), true );
}
function signtransaction($serialized_tx){
function signtransaction($serialized_tx, $password=false ){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('tx' => $serialized_tx);
return json_decode( $this->electrumfair(), true )['result'];
$this->param['params']=Array('tx' => $serialized_tx, 'password' => ( !$password ? getenv('PASSWORD') : $password ) );
return json_decode( $this->electrumfair(), true );
}
function broadcast($serialized_tx){
$this->param['method']=__FUNCTION__;
......
......@@ -62,7 +62,7 @@ echo json_encode(Array('address' => $address, 'pubkey' => $pubkey, 'message' =>
?><textarea class="hidden"><?=json_encode($F->electrumfair->version())?></textarea><?
?><hr><h2>Message</h2><?
?><h4 onclick="$(this).next().toggleClass('hidden')">Faircoin->electrumfair-><b>signmessage($address,$message)</b></h4><?
?><h4 onclick="$(this).next().toggleClass('hidden')">Faircoin->electrumfair-><b>signmessage($address,$message[,$password])</b></h4><?
?><textarea class="hidden"><?=json_encode($F->electrumfair->signmessage($address,$message))?></textarea><?
?><h4 onclick="$(this).next().toggleClass('hidden')">Faircoin->electrumfair-><b>verifymessage($address,$message,$signature)</b></h4><?
......
rpcallowip=0.0.0.0/0
rpcport=8332
rpcuser=user
rpcpassword=password
txindex=1
# Pull base image.
FROM ubuntu:18.04@sha256:5f4bdc3467537cbbe563e80db2c3ec95d548a9145d64453b06939c4592d67b6d
FROM ubuntu:18.04
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8
......@@ -10,7 +10,8 @@ RUN apt-get update -q && \
net-tools \
git \
python3-pyqt5 \
openssl
openssl \
coreutils
#####################################################################################root##
### install nano commandline editor [optional] ( to edit faircoin.conf later if necessary )
......@@ -18,8 +19,9 @@ RUN apt-get install -qy nano
#####################################################################################root##
### install python packages
RUN apt-get install -qy python3-pip
RUN apt-get install -qy libleveldb-dev
RUN apt-get install -qy \
python3-pip \
libleveldb-dev
RUN python3 -m pip install \
aiorpcx \
......@@ -39,15 +41,15 @@ RUN rm -rf /var/lib/apt/lists/* && \
ARG RUNNER_GID
ARG RUNNER_UID
ENV USER=faircoin
ENV FAIRCHAINS_PATH=/home/faircoin/.faircoin2/
ENV FAIRCHAINS_PATH=/home/faircoin/.fairchains/
RUN groupadd -g $RUNNER_GID faircoin
RUN useradd --create-home --shell /bin/bash faircoin --uid $RUNNER_UID --gid $RUNNER_GID
RUN mkdir -p $FAIRCHAINS_PATH
RUN chown -R faircoin:faircoin $FAIRCHAINS_PATH
RUN mkdir -p /home/faircoin/_init/.faircoin2
RUN chown -R faircoin:faircoin /home/faircoin/_init/.faircoin2
RUN mkdir -p /home/faircoin/scripts
RUN chown -R faircoin:faircoin /home/faircoin/scripts
USER faircoin
#################################################################################faircoin##
......@@ -57,10 +59,3 @@ RUN git clone https://github.com/fairchainsx/electrumfairchainsx.git
WORKDIR /home/faircoin/electrumfairchainsx
RUN python3 setup.py build
WORKDIR $FAIRCHAINS_PATH
RUN openssl genrsa -out electrumx.key 2048
RUN openssl req -new -key electrumx.key -out electrumx.csr -subj "/C=GB/ST=London/L=London/O=electrumfairchainsx/OU=electrumfairchainsx/CN=faircoin.co"
RUN openssl x509 -req -days 1825 -in electrumx.csr -signkey electrumx.key -out electrumx.crt
WORKDIR /home/faircoin/electrumfairchainsx
#!/bin/bash
#### create key and cert
openssl genrsa -out ~/.fairchains/electrumx.key 2048
openssl req -new -key ~/.fairchains/electrumx.key -out ~/.fairchains/electrumx.csr -config ~/scripts/ssl.conf
#### verify cert
openssl req -noout -text -in ~/.fairchains/electrumx.csr
#### sign cert
openssl x509 -req -days 1825 -in ~/.fairchains/electrumx.csr -signkey ~/.fairchains/electrumx.key -out ~/.fairchains/electrumx.crt
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment