-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from SophiaTX/rc_1_1_0
Rc 1 1 0
- Loading branch information
Showing
131 changed files
with
8,343 additions
and
37,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
.idea | ||
libraries/manifest/sophiatx_manifest/__pycache__/ | ||
ciscripts/deploy/ansible/playbooks/deploy-node.retry | ||
cmake-build-debug | ||
CMakeCache.txt | ||
CMakeFiles | ||
*.user | ||
cmake-build-release/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
--- | ||
- hosts: "{{ host }}" | ||
remote_user: "{{ user }}" | ||
become: yes | ||
become_user: "{{ user }}" | ||
vars: | ||
source_dir: ~/sophiatx-binaries/ | ||
bc_data_dir: ~/sophiatx-binaries/bc-data/ | ||
config_file_name: testnet_config.ini | ||
|
||
tasks: | ||
- block: | ||
- name: "Checking folders \"{{source_dir}}\", \"{{bc_data_dir}}\" if they exist" | ||
stat: | ||
path: "{{item}}" | ||
register: folder_stats | ||
with_items: ["{{source_dir}}", "{{bc_data_dir}}"] | ||
- name: "Creating non-existing folders" | ||
file: | ||
path: "{{item.item}}" | ||
state: directory | ||
mode: 0755 | ||
group: "{{ user }}" | ||
owner: "{{ user }}" | ||
when: item.stat.exists == false | ||
with_items: "{{folder_stats.results}}" | ||
|
||
|
||
- name: Finding all existing *.old files | ||
find: | ||
paths: "{{ source_dir }}" | ||
patterns: "*.old" | ||
register: files_to_delete | ||
- name: Deleting existing *.old files | ||
file: | ||
path: "{{ item.path }}" | ||
state: absent | ||
with_items: "{{ files_to_delete.files }}" | ||
|
||
|
||
- block: | ||
- name: Finding all existing *.gz files | ||
find: | ||
paths: "{{ source_dir }}" | ||
patterns: "*.gz" | ||
register: gz_files_to_rename | ||
- name: Renaming files to *.gz.old files | ||
command: mv "{{ item.path }}" "{{ item.path }}".old | ||
with_items: "{{ gz_files_to_rename.files }}" | ||
|
||
- name: Checking {{config_file_name}} file | ||
stat: | ||
path: "{{ source_dir }}{{config_file_name}}" | ||
register: config_file_result | ||
- name: Renaming {{config_file_name}} file to *.old | ||
command: mv "{{ source_dir }}{{config_file_name}}" "{{ source_dir }}{{config_file_name}}".old | ||
when: config_file_result.stat.exists == True | ||
|
||
|
||
|
||
- name: Downloading source {{ sourceUrl }} | ||
get_url: | ||
url: "{{ sourceUrl }}" | ||
dest: "{{ source_dir }}" | ||
mode: 0440 | ||
|
||
|
||
|
||
- block: | ||
- name: Installing unzip if not already installed | ||
apt: | ||
name: unzip | ||
state: latest | ||
- name: Unarchiving archive.zip | ||
unarchive: | ||
src: "{{ source_dir }}archive.zip" | ||
dest: "{{ source_dir }}" | ||
remote_src: yes | ||
- name: Finding concrete unarchived sophiatx_#<...>.tar.gz file | ||
find: | ||
paths: "{{ source_dir }}/archive" | ||
patterns: "sophiatx_*.tar.gz" | ||
register: sophia_tar_file | ||
- name: Moving found unarchived sophiatx_#<...>.tar.gz to the parent folder | ||
command: mv "{{ item.path }}" "{{ source_dir }}" | ||
with_items: "{{ sophia_tar_file.files }}" | ||
- name: Deleting archive.zip and archive folder, which are not needed anymore | ||
file: | ||
state: absent | ||
path: "{{item}}" | ||
with_items: ["{{ source_dir }}archive.zip", "{{ source_dir }}archive"] | ||
when: sourceUrl is match('.*\/archive\.zip$') | ||
|
||
|
||
- find: | ||
paths: "{{ source_dir }}" | ||
patterns: "sophiatx_*.tar.gz" | ||
register: sophia_tar_file | ||
- name: Unarchiving sophiatx_#<NUM>.tar.gz | ||
unarchive: | ||
src: "{{ item.path }}" | ||
dest: "{{ source_dir }}" | ||
remote_src: yes | ||
with_items: "{{ sophia_tar_file.files }}" | ||
|
||
|
||
- name: Copying {{config_file_name}} to {{bc_data_dir}} | ||
command: cp "{{ source_dir }}{{config_file_name}}" "{{bc_data_dir}}"config.ini | ||
|
||
|
||
- name: Killing all screen sessions that are actually running | ||
command: killall screen | ||
ignore_errors: yes # ignore error when there are no running sessions | ||
|
||
|
||
- name: Starting sophia demon with --replay-blockchain flag | ||
command: screen -dmS sophia bash -c '{{ source_dir }}sophiatxd -d {{ source_dir }}bc-data/ --replay-blockchain; exec $SHELL' | ||
when: replayBlockchain == "true" | ||
|
||
- name: Starting sophia demon | ||
command: screen -dmS sophia bash -c '{{ source_dir }}sophiatxd -d {{ source_dir }}bc-data/; exec $SHELL' | ||
when: replayBlockchain == "false" | ||
|
||
|
||
- name: Waiting 5 seconds for sophia demon to fully initialize and start. | ||
pause: | ||
seconds: 5 | ||
|
||
|
||
- name: Starting alexandria demon | ||
command: screen -dmS alexandria bash -c '{{ source_dir }}alexandria_deamon -H0.0.0.0:9195 -C*; exec $SHELL' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
while getopts "h:u:s:r" opt; do | ||
case $opt in | ||
h) | ||
host="$OPTARG" | ||
;; | ||
u) | ||
user="$OPTARG" | ||
;; | ||
s) | ||
sourceUrl="$OPTARG" | ||
;; | ||
r) | ||
replayBlockchain=true | ||
;; | ||
*) | ||
esac | ||
done | ||
|
||
|
||
# check required variables | ||
usageMessage="$0 -h host -u user [-s sourceUrl] [-r]" | ||
[[ $# -eq 0 || -z $host ]] && { echo "-h host parameter is required ! Usage: \"$usageMessage\""; exit 1; } | ||
[[ $# -eq 0 || -z $user ]] && { echo "-u user parameter is required ! Usage: \"$usageMessage\""; exit 1; } | ||
|
||
# set default values for unset optional pars | ||
if [[ -z $sourceUrl ]] | ||
then | ||
sourceUrl="https://jenkins.sophiatx.com/job/SophiaTX-develop/lastSuccessfulBuild/artifact/*zip*/archive.zip" | ||
fi | ||
|
||
if [[ -z $replayBlockchain ]] | ||
then | ||
replayBlockchain=false | ||
fi | ||
|
||
ansible-playbook ansible/playbooks/deploy-node.yml --extra-vars "host=$host user=$user sourceUrl=$sourceUrl replayBlockchain=$replayBlockchain" -i $host, | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "ERROR while updating node on \"${host}\". Error code: $?" | ||
exit 2 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Automatic node deploy | ||
|
||
Script connects to the server and automatically deploys node binaries and stores previous version | ||
|
||
Created file structure on server: | ||
|
||
~ # home of specified user | ||
├── ... | ||
├── sophiatx-binaries # Binaries folder | ||
│ ├── sophiatx_#<NUM>.tar.gz # SophiaTX archived binaries | ||
│ ├── sophiatx_#<NUM>.tar.gz.old # Previous version of SophiaTX archived binaries | ||
│ ├── testnet_config.ini # SophiaTX demon config file | ||
│ ├── testnet_config.ini.old # Previous version of SophiaTX demon config file | ||
│ ├── sophiatxd # SophiaTX demon | ||
│ ├── alexandria_deamon # Alexandria demon | ||
│ └── bc-data # Blokchain data folder | ||
│ ├── config.ini # Copied testnet_config.ini | ||
│ └── ... | ||
└── ... | ||
|
||
|
||
## Usage | ||
|
||
./deploy-node.sh -h host -u user [-s sourceUrl] [-r] | ||
|
||
####Arguments description: | ||
|
||
-h host : host(server), where node binaries should be deployed into | ||
|
||
-u user : user to be used to connect to the host. This user has to have id_rsa.pub imported on host | ||
|
||
[-s sourceUrl] : sourceUrl from which are the the binaries downloaded. optional. In case it is not specified, latest binaries are downloaded. | ||
|
||
[-r] : replay-blockain flag. It is used when starting sophiatxd. optional | ||
|
||
|
||
## Requirements | ||
|
||
For using automatic deploy script, you have to install Ansible on your machine: | ||
|
||
$ sudo apt-get update | ||
$ sudo apt-get install software-properties-common | ||
$ sudo apt-add-repository ppa:ansible/ansible | ||
$ sudo apt-get update | ||
$ sudo apt-get install ansible |
Oops, something went wrong.