8 |
9 | The repo of spacex-script used to automate processes to configure and run Mannheim testnet **RUBIK**, the script is a list of commands that are executed by spacex program.
10 |
11 | # 🚀Getting Started
12 | Official Guardian/Miner Node service for running Mannheim protocol.
13 |
14 | ## 🧰Preparation work
15 |
16 | | Requirements | |
17 | | --------------------- | ------------------------------------------------------------ |
18 | | ⚙️Hardware | CPU must contain **SGX module**, and make sure the SGX function is turned on in the bios |
19 | | ⚙️Operating system | Ubuntu 16.04/18.04/20.04 |
20 | | ⚙️Other configurations | **Secure Boot** in BIOS needs to be turned off |
21 |
22 |
23 |
24 | ## 🛠️Install dependencies
25 |
26 | ### Install Rubik service
27 | ```shell
28 | sudo ./install.sh # Use 'sudo ./install.sh --registry cn' to accelerate installation in some areas
29 | ```
30 |
31 | ### Modify config.yaml
32 | ```shell
33 | sudo spacex config set
34 | ```
35 |
36 | ### Run service
37 |
38 | - Please make sure the following ports are not occupied before starting:
39 | - 30888 19933 19944 (for chain )
40 | - 56666 (for rubik API)
41 | - 12222 (for rubik storage)
42 | - 5001 4001 37773 (for IPFS)
43 |
44 | ```shell
45 | sudo spacex help
46 | sudo spacex start
47 | sudo spacex status
48 | ```
49 |
50 | ### Stop service
51 |
52 | ```shell
53 | sudo spacex stop
54 | ```
55 |
56 | ### 🛡️How to become a guardian?
57 |
58 | The Guardian node is the initiator of and in charge of the Group, participating in block generation. Effective storage of the miner can be clustered on the Guardian to participate in the block generation competition. Meantime, the organizers of the Guardians are accountable for the Group's strategy of receiving meaningful files to improve the Group's overall competitiveness. Since the Guardian node itself does not store files, support for SGX is not necessary.
59 |
60 | For details, please refer to [this page](docs/guardian.md).
61 |
62 | ### 💎How to become a miner?
63 |
64 | The Miner node acts as the storage provider in Group. There can be multiple Miner nodes in a Group, and their effective storage can be clustered on Owner to participate in block generation competition. Since Miner nodes store files and perform trusted quantification, support for SGX is necessary. The Miner node is connected to its account through configuring backup files.
65 |
66 | For details, please refer to [this page](docs/miner.md).
67 |
68 | ## License
69 |
70 | [GPL v3](LICENSE)
71 |
--------------------------------------------------------------------------------
/generator/config-gen/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * config generators
3 | */
4 | const path = require('path')
5 | const { createDir, writeConfig, } = require('../utils')
6 | const { genApiConfig, genApiComposeConfig } = require('./api-config.gen')
7 | const { genSdatamanagerConfig, genSdatamanagerComposeConfig } = require('./sdatamanager-config.gen')
8 | const { genIpfsConfig, genIpfsComposeConfig } = require('./ipfs-config.gen')
9 | const { genChainConfig, genChainComposeConfig } = require('./chain-config.gen')
10 | const { genStorageConfig, genStorageComposeConfig } = require('./storage-config.gen')
11 | const { logger } = require('../logger')
12 |
13 | /**
14 | * configuration of generators to use
15 | * name: the generator name
16 | *
17 | * async configFun(config, outputOptions) => {file, paths}
18 | * file: the result filename
19 | * paths: an array of files/directories should be verified later
20 | * required: boolean whether this file is a mandontary requirement
21 | * path: the file path
22 | *
23 | * composeName: the compose service name of this generator
24 | * async composeFunc(config) => composeConfig
25 | * return the service definition for this generator
26 | */
27 | const configGenerators = [{
28 | name: 'chain',
29 | configFunc: genChainConfig,
30 | to: path.join('chain', 'chain_config.json'),
31 | composeName: 'spacex',
32 | composeFunc: genChainComposeConfig,
33 | }, {
34 | name: 'api',
35 | configFunc: genApiConfig,
36 | to: path.join('api', 'api_config.json'),
37 | composeName: 'spacex-api',
38 | composeFunc: genApiComposeConfig,
39 | }, {
40 | name: 'storage',
41 | configFunc: genStorageConfig,
42 | to: path.join('storage', 'storage_config.json'),
43 | composeName: 'spacex-storage-a',
44 | composeFunc: genStorageComposeConfig,
45 | }, {
46 | name: 'storage',
47 | configFunc: genStorageConfig,
48 | to: path.join('storage', 'storage_config.json'),
49 | composeName: 'spacex-storage-b',
50 | composeFunc: genStorageComposeConfig,
51 | }, {
52 | name: 'sdatamanager',
53 | configFunc: genSdatamanagerConfig,
54 | to: path.join('sdatamanager', 'sdatamanager_config.json'),
55 | composeName: 'spacex-sdatamanager',
56 | composeFunc: genSdatamanagerComposeConfig,
57 | }, {
58 | name: 'ipfs',
59 | configFunc: genIpfsConfig,
60 | to: path.join('ipfs', 'ipfs_config.json'),
61 | composeName: 'ipfs',
62 | composeFunc: genIpfsComposeConfig,
63 | }]
64 |
65 | async function genConfig(config, outputOpts) {
66 | //
67 | // application config generation
68 | let outputs = []
69 | const { baseDir } = outputOpts
70 | for (const cg of configGenerators) {
71 | if (!config[cg.name]) {
72 | continue
73 | }
74 | const ret = await cg.configFunc(config, outputOpts)
75 | await writeConfig(path.join(baseDir, cg.to), ret.config)
76 | outputs.push({
77 | generator: cg.name,
78 | ...ret,
79 | })
80 | }
81 |
82 | logger.info('Generating configurations done')
83 | return outputs
84 | }
85 |
86 | async function genComposeConfig(config) {
87 | //
88 | // docker compose config generation
89 | let output = {
90 | version: '3.0',
91 | services: {},
92 | }
93 |
94 | for (const cg of configGenerators) {
95 | if (!config[cg.name]) {
96 | continue
97 | }
98 | const cfg = await cg.composeFunc(config)
99 | cfg["container_name"] = cg.composeName
100 | output = {
101 | ...output,
102 | services: {
103 | ...output.services,
104 | [cg.composeName]: cfg,
105 | }
106 | }
107 | }
108 |
109 | logger.info('Generating docker compose file done')
110 |
111 | return output
112 | }
113 |
114 | module.exports = {
115 | genConfig,
116 | genComposeConfig,
117 | }
118 |
--------------------------------------------------------------------------------
/tools/test-sgx.c:
--------------------------------------------------------------------------------
1 | #include
2 | #if defined(_MSC_VER)
3 | #include
4 | #endif
5 |
6 | static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
7 | unsigned int *ecx, unsigned int *edx)
8 | {
9 | /* ecx is often an input as well as an output. */
10 |
11 | #if !defined(_MSC_VER)
12 |
13 | asm volatile("cpuid"
14 | : "=a"(*eax),
15 | "=b"(*ebx),
16 | "=c"(*ecx),
17 | "=d"(*edx)
18 | : "0"(*eax), "2"(*ecx));
19 |
20 | #else
21 | int registers[4] = {0, 0, 0, 0};
22 |
23 | __cpuidex(registers, *eax, *ecx);
24 | *eax = registers[0];
25 | *ebx = registers[1];
26 | *ecx = registers[2];
27 | *edx = registers[3];
28 |
29 | #endif
30 | }
31 |
32 | int main(int argc, char **argv)
33 | {
34 | /* This programm prints some CPUID information and tests the SGX support of the CPU */
35 | unsigned eax, ebx, ecx, edx;
36 | int is_sgx_available = 0;
37 | int is_sgx_enable = 0;
38 | eax = 1; /* processor info and feature bits */
39 |
40 | native_cpuid(&eax, &ebx, &ecx, &edx);
41 | printf("eax: %x ebx: %x ecx: %x edx: %x\n", eax, ebx, ecx, edx);
42 |
43 | printf("stepping %d\n", eax & 0xF); // Bit 3-0
44 | printf("model %d\n", (eax >> 4) & 0xF); // Bit 7-4
45 | printf("family %d\n", (eax >> 8) & 0xF); // Bit 11-8
46 | printf("processor type %d\n", (eax >> 12) & 0x3); // Bit 13-12
47 | printf("extended model %d\n", (eax >> 16) & 0xF); // Bit 19-16
48 | printf("extended family %d\n", (eax >> 20) & 0xFF); // Bit 27-20
49 |
50 | // if smx set - SGX global enable is supported
51 | printf("smx: %d\n", (ecx >> 6) & 1); // CPUID.1:ECX.[bit6]
52 |
53 | /* Extended feature bits (EAX=07H, ECX=0H)*/
54 | printf("\nExtended feature bits (EAX=07H, ECX=0H)\n");
55 | eax = 7;
56 | ecx = 0;
57 | native_cpuid(&eax, &ebx, &ecx, &edx);
58 | printf("eax: %x ebx: %x ecx: %x edx: %x\n", eax, ebx, ecx, edx);
59 |
60 | //CPUID.(EAX=07H, ECX=0H):EBX.SGX = 1,
61 | is_sgx_available = (ebx >> 2) & 0x1;
62 | printf("sgx available: %d\n", is_sgx_available);
63 |
64 | //CPUID.(EAX=07H, ECX=0H):ECX.SGX_LC = 1
65 | printf("sgx launch control: %d\n", (ecx >> 30) & 0x01);
66 |
67 | /* SGX has to be enabled in MSR.IA32_Feature_Control.SGX_Enable
68 | check with msr-tools: rdmsr -ax 0x3a
69 | SGX_Enable is Bit 18
70 | if SGX_Enable = 0 no leaf information will appear.
71 | for more information check Intel Docs Architectures-software-developer-system-programming-manual - 35.1 Architectural MSRS
72 | */
73 |
74 | /* CPUID Leaf 12H, Sub-Leaf 0 Enumeration of Intel SGX Capabilities (EAX=12H,ECX=0) */
75 | printf("\nCPUID Leaf 12H, Sub-Leaf 0 of Intel SGX Capabilities (EAX=12H,ECX=0)\n");
76 | eax = 0x12;
77 | ecx = 0;
78 | native_cpuid(&eax, &ebx, &ecx, &edx);
79 | printf("eax: %x ebx: %x ecx: %x edx: %x\n", eax, ebx, ecx, edx);
80 |
81 | printf("sgx 1 supported: %d\n", eax & 0x1);
82 | printf("sgx 2 supported: %d\n", (eax >> 1) & 0x1);
83 | is_sgx_enable = (eax & 0x1) || ((eax >> 1) & 0x1);
84 |
85 | printf("MaxEnclaveSize_Not64: %x\n", edx & 0xFF);
86 | printf("MaxEnclaveSize_64: %x\n", (edx >> 8) & 0xFF);
87 |
88 | /* CPUID Leaf 12H, Sub-Leaf 1 Enumeration of Intel SGX Capabilities (EAX=12H,ECX=1) */
89 | printf("\nCPUID Leaf 12H, Sub-Leaf 1 of Intel SGX Capabilities (EAX=12H,ECX=1)\n");
90 | eax = 0x12;
91 | ecx = 1;
92 | native_cpuid(&eax, &ebx, &ecx, &edx);
93 | printf("eax: %x ebx: %x ecx: %x edx: %x\n", eax, ebx, ecx, edx);
94 |
95 | int i;
96 | for (i = 2; i < 10; i++)
97 | {
98 | /* CPUID Leaf 12H, Sub-Leaf i Enumeration of Intel SGX Capabilities (EAX=12H,ECX=i) */
99 | printf("\nCPUID Leaf 12H, Sub-Leaf %d of Intel SGX Capabilities (EAX=12H,ECX=%d)\n", i, i);
100 | eax = 0x12;
101 | ecx = i;
102 | native_cpuid(&eax, &ebx, &ecx, &edx);
103 | printf("eax: %x ebx: %x ecx: %x edx: %x\n", eax, ebx, ecx, edx);
104 | }
105 |
106 | if (is_sgx_available != 1)
107 | {
108 | printf("\033[31m\nCPU SGX functions are deactivated or SGX is not supported!\033[0m\n");
109 | return 1;
110 | }
111 | else if (is_sgx_enable != 1)
112 | {
113 | printf("\033[31m\nSGX is available for your CPU but not enabled in BIOS!\033[0m\n");
114 | return 2;
115 | }
116 |
117 | printf("\033[32m\nSGX is available for your CPU and enabled in BIOS!\033[0m\n");
118 | return 0;
119 | }
120 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | localbasedir=$(cd `dirname $0`;pwd)
4 | localscriptdir=$localbasedir/scripts
5 | installdir=/opt/mannheimworld/spacex-script
6 | disksdir=/opt/mannheimworld/disks
7 | datadir=/opt/mannheimworld/data
8 | source $localscriptdir/utils.sh
9 |
10 | help()
11 | {
12 | cat << EOF
13 | Usage:
14 | help show help information
15 | --update update spacex script
16 | --registry {cn|en} use registry to accelerate docker pull
17 | EOF
18 | exit 0
19 | }
20 |
21 | install_depenencies()
22 | {
23 | if [ x"$update" == x"true" ]; then
24 | return 0
25 | fi
26 |
27 | log_info "------------Apt update--------------"
28 | apt-get update
29 | if [ $? -ne 0 ]; then
30 | log_err "Apt update failed"
31 | exit 1
32 | fi
33 |
34 | log_info "------------Install depenencies--------------"
35 | apt install -y git jq curl wget build-essential kmod linux-headers-`uname -r` vim
36 |
37 | if [ $? -ne 0 ]; then
38 | log_err "Install libs failed"
39 | exit 1
40 | fi
41 |
42 | docker -v
43 | if [ $? -ne 0 ]; then
44 | curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
45 | if [ $? -ne 0 ]; then
46 | log_err "Install docker failed"
47 | exit 1
48 | fi
49 | fi
50 |
51 | docker-compose -v
52 | if [ $? -ne 0 ]; then
53 | apt install -y docker-compose
54 | if [ $? -ne 0 ]; then
55 | log_err "Install docker compose failed"
56 | exit 1
57 | fi
58 | fi
59 |
60 | sysctl -w net.core.rmem_max=2500000
61 | }
62 |
63 | download_docker_images()
64 | {
65 | if [ x"$update" == x"true" ]; then
66 | return 0
67 | fi
68 |
69 | log_info "-------Download spacex docker images----------"
70 |
71 | local docker_org="mannheimworld"
72 |
73 |
74 | local res=0
75 | docker pull $docker_org/config-generator:$node_type
76 | res=$(($?|$res))
77 | docker tag $docker_org/config-generator:$node_type mannheimworld/config-generator
78 |
79 | docker pull $docker_org/spacex:$node_type
80 | res=$(($?|$res))
81 | docker tag $docker_org/spacex:$node_type mannheimworld/spacex
82 |
83 | docker pull $docker_org/spacex-api:$node_type
84 | res=$(($?|$res))
85 | docker tag $docker_org/spacex-api:$node_type mannheimworld/spacex-api
86 |
87 | docker pull $docker_org/spacex-storage:$node_type
88 | res=$(($?|$res))
89 | docker tag $docker_org/spacex-storage:$node_type mannheimworld/spacex-storage
90 |
91 | docker pull $docker_org/spacex-sdatamanager:$node_type
92 | res=$(($?|$res))
93 | docker tag $docker_org/spacex-sdatamanager:$node_type mannheimworld/spacex-sdatamanager
94 |
95 | docker pull $docker_org/go-ipfs:$node_type
96 | res=$(($?|$res))
97 | docker tag $docker_org/go-ipfs:$node_type mannheimworld/go-ipfs
98 |
99 | if [ $res -ne 0 ]; then
100 | log_err "Install docker failed"
101 | exit 1
102 | fi
103 | }
104 |
105 | create_node_paths()
106 | {
107 | mkdir -p $installdir
108 | mkdir -p $disksdir
109 | chmod 777 $disksdir
110 | mkdir -p $datadir
111 | chmod 777 $datadir
112 | for((i=1;i<=128;i++));
113 | do
114 | mkdir -p $disksdir/$i
115 | chmod 777 $disksdir/$i
116 | done
117 | }
118 |
119 | install_spacex_script()
120 | {
121 | log_info "--------------Install spacex script-------------"
122 | local bin_file=/usr/bin/spacex
123 |
124 | if [ -d "$installdir" ] && [ -f "$bin_file" ] && [ x"$update" == x"true" ]; then
125 | echo "Update spacex script"
126 | rm $bin_file
127 | rm -rf $installdir/scripts
128 | cp -rp $localbasedir/scripts $installdir/
129 | rm $installdir/etc/watch-chain.yaml
130 | cp $localbasedir/etc/watch-chain.yaml $installdir/etc/watch-chain.yaml
131 | else
132 | if [ -f "$installdir/scripts/uninstall.sh" ]; then
133 | echo "Uninstall old spacex script"
134 | $installdir/scripts/uninstall.sh
135 | fi
136 |
137 | echo "Install new spacex script"
138 | create_node_paths
139 | cp -r $localbasedir/etc $installdir/
140 | cp $localbasedir/config.yaml $installdir/
141 | chown root:root $installdir/config.yaml
142 | chmod 0600 $installdir/config.yaml
143 | cp -r $localbasedir/scripts $installdir/
144 |
145 | echo "Change spacex node configurations"
146 | sed -i 's/en/'$region'/g' $installdir/etc/region.conf
147 | fi
148 |
149 | echo "Install spacex command line tool"
150 | cp $localscriptdir/spacex.sh /usr/bin/spacex
151 |
152 | log_success "------------Install success-------------"
153 | }
154 |
155 |
156 | if [ $(id -u) -ne 0 ]; then
157 | log_err "Please run with sudo!"
158 | exit 1
159 | fi
160 |
161 | region="en"
162 | update="false"
163 |
164 | while true ; do
165 | case "$1" in
166 | --registry)
167 | if [ x"$2" == x"" ] || [[ x"$2" != x"cn" && x"$2" != x"en" ]]; then
168 | help
169 | fi
170 | region=$2
171 | shift 2
172 | ;;
173 | --update)
174 | update="true"
175 | shift 1
176 | ;;
177 | "")
178 | shift ;
179 | break ;;
180 | *)
181 | help
182 | break;
183 | ;;
184 | esac
185 | done
186 |
187 | install_depenencies
188 | download_docker_images
189 | install_spacex_script
190 |
191 |
--------------------------------------------------------------------------------
/docs/guardian.md:
--------------------------------------------------------------------------------
1 | ## 1. Overview
2 |
3 | ### 1.1 Guardian Node Responsibility
4 |
5 | The Guardian node is the initiator of and in charge of the Group, participating in block generation. Effective storage of the miner can be clustered on the Guardian to participate in the block generation competition. Meantime, the organizers of the Guardian node are accountable for the Group's strategy of receiving meaningful files to improve the Group's overall competitiveness. Since the Guardian node itself does not store files, support for SGX is not necessary. The Guardian node account is connected to block node through the session key.
6 |
7 | ## 2. Ready to Deploy
8 |
9 | > Note: The account of Mannheim testnet RUBIK starting with the letter 'r'.
10 |
11 | ### 2.1 Create your Accounts
12 |
13 | The Guardian node participates in the block generation competition. It needs to create accounts and be bonded to the Controller&Stash account group.
14 |
15 | Notices:
16 |
17 | * The account should be unique and cannot be any other account for Guardian, Miner or Bridge;
18 | * Be sure to reserve a small number of HEIMs not locked in the Controller&Stash for sending transactions (≈ 1 HEIM).
19 |
20 | ### 2.2 Create and manager group
21 |
22 | #### 2.2.1 Create group
23 |
24 | > The account to create the Group must be a bound Stash account
25 |
26 | Enter RUBIK APPS, select 'Benefit', click on 'Create group',select the Guardian **Stash account**, click on 'Create', enter the password of the stash account and click on 'Sign and Submit' to send the transaction and create Group.
27 |
28 | #### 2.2.2 Lockup HEIM to reduce the fee of the work report
29 |
30 | **The work report on chain requires handling fees.** Under normal circumstances, each Miner will perform 24~32 workload reporting transactions per day, which brings a lot of handling fees. For this reason, the Mannheim network provides a Benefit module that exempts workload reporting fees. Group guardians can reduce or waive miner handling fees by locking HEIMs. **Each miner** needs to lock 18HEIM for fee reduction. However, considering the unstable reporting of workload, it is recommended to lock 24HEIM~30HEIM to ensure that the fee is completely free. For example, suppose your Group is ready to have 10 miners ready to join, then lock 30*10=300HEIM
31 |
32 | Enter [Spacex APPS](http://rubik.mannheim.world/#/explorer), select 'Account', select the 'Benefit' module, find the group created before, and click 'Increase lockup'.
33 |
34 | Enter the number of HEIMs that **need to be added**, and sign the transaction.
35 |
36 | ### 2.3 Download Node Package
37 |
38 | 1. Download
39 |
40 | ```plain
41 | wget https://github.com/mannheim-network/spacex-script/archive/refs/heads/testnet.zip
42 | ```
43 | 2. Unzip
44 |
45 | ```plain
46 | tar -xvf testnet.zip
47 | ```
48 | 3. Go to package directory
49 |
50 | ```plain
51 | cd spacex-script-testnet
52 | ```
53 |
54 | ### 2.4 Install Spacex Service
55 |
56 | Notice:
57 |
58 | * The program will be installed under `/opt/mannheimworld`, please make sure this path is mounted with more than 250G of SSD space;
59 |
60 | * If you have run a previous Mannheim testnet program on this device, you need to close the previous Node and clear the data before this installation.
61 |
62 | * The installation process will involve the download of dependencies and docker images, which is time-consuming. Meantime, it may fail due to network problems. If it happens, please repeat the process until the installation is all complete.
63 |
64 | Installation:
65 |
66 | ```plain
67 | sudo ./install.sh
68 | ```
69 | ## 3. Node Configuration
70 |
71 | ### 3.1 Edit Config File
72 |
73 | Execute the following command to edit the node configuration file:
74 |
75 | ```plain
76 | sudo spacex config set
77 | ```
78 | ### 3.2 Change Node Name
79 |
80 | Follow the prompts to enter the name of your node, and press Enter to end.
81 |
82 | ### 3.3 Choose Mode
83 |
84 | Follow the prompts to enter a node mode 'guardian', and press Enter to end.
85 |
86 | ### 3.4 Review the Configuration (Optional)
87 |
88 | Execute following command to view the configuration file:
89 |
90 | ```plain
91 | sudo spacex config show
92 | ```
93 | ## 4. Start Node
94 |
95 | ### 4.1 Preparation
96 |
97 | To start with, you need to ensure that the following ports are not occupied: 30888, 19944, and 19933.
98 |
99 | Then open the P2P port:
100 |
101 | ```plain
102 | sudo ufw allow 30888
103 | ```
104 | ### 4.2 Start
105 |
106 | ```plain
107 | sudo spacex start
108 | ```
109 | ### 4.3 Check Running Status
110 |
111 | ```plain
112 | sudo spacex logs chain
113 | ```
114 | As detailed below, all is ready for synchronizing blocks.
115 |
116 | ## 5. Blockchain Validate
117 |
118 | ### 5.1 Get session key
119 |
120 | Please wait for the chain to synchronize to the latest block height, and execute the following command:
121 |
122 | ```plain
123 | sudo spacex tools rotate-keys
124 | ```
125 | Copy the session key as shown below:
126 |
127 | ### 5.2 Set session key
128 |
129 | Enter [SPACEX APPs](http://rubik.mannheim.world/#/explorer), click on "Staking" button under "Network" in the navigation bar, and go to "Account action". Click on "Session Key".
130 | Fill in the sessionkey you have copied, and click on “Set session key”.
131 |
132 | ### 5.3 Be a Guardian/Candidate
133 |
134 | > Becoming a Guardian needs to shoulder the responsibility of maintaining the network, a large-scale disconnection will result in a certain degree of punishment (up to 7% of the effective pledge amount)
135 |
136 | Under "Network->Staking->Account action" page, Please click on "guardian" button.
137 |
138 | After one era, you can find your account listed in the "Staking" or "Waiting" list, which means you have completed all the steps.
139 |
140 | ## 6. Restart and Uninstall
141 |
142 | ### 6.1 Restart
143 |
144 | If the device or Guardian node related programs need to be somehow restarted, please refer to the following steps.
145 |
146 | **Please note**: This section only concerns restarting steps of Guardian nodes, not including the basic software and hardware environment settings and inspection related information, such as hard disk mounting, IPFS configurations, etc. Please ensure that the hardware and software configuration is correct, and perform the following steps:
147 |
148 | ```plain
149 | sudo spacex reload
150 | ```
151 | ### 6.2 Uninstall and Data Cleanup
152 |
153 | If you have run a previous version of testnet, or if you want to redeploy your current node, you need to clear data from three sources:
154 |
155 | * Delete basic Spacex files under /opt/mannheimworld/data
156 | * Clean node data under /opt/mannheimworld/spacex-script by executing:
157 |
158 | ```plain
159 | sudo /opt/mannheimworld/spacex-script/scripts/uninstall.sh
160 | ```
161 |
--------------------------------------------------------------------------------
/scripts/config.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | source /opt/mannheimworld/spacex-script/scripts/utils.sh
4 |
5 | config_help()
6 | {
7 | cat << EOF
8 | Spacex config usage:
9 | help show help information
10 | show show configurations
11 | set set and generate new configurations
12 | generate generate new configurations
13 | chain-port {port} set chain port and generate new configuration, default is 30888
14 | conn-chain {ws} set conneted chain ws and generate new configuration, default is ws://127.0.0.1:19944
15 | EOF
16 | }
17 |
18 | config_show()
19 | {
20 | cat $configfile | sed 's#isolation#bridge#g' | sed -e 's#owner#guardian#g' | sed -e 's#member#miner#g'
21 | }
22 |
23 | config_set_all()
24 | {
25 | local chain_name=""
26 | read -p "Enter spacex script name (default:spacex-script): " chain_name
27 | chain_name=`echo "$chain_name"`
28 | if [ x"$chain_name" == x"" ]; then
29 | chain_name="spacex-script"
30 | fi
31 | local tt=$(rand 100000 999999)
32 | chain_name="$chain_name-$tt"
33 | sed -i "22c \\ name: \"$chain_name\"" $configfile &>/dev/null
34 | log_success "Set spacex script name: '$chain_name' successfully"
35 |
36 | local mode=""
37 | while true
38 | do
39 | read -p "Enter spacex script mode from 'bridge/guardian/miner' (default:bridge): " mode
40 | mode=`echo "$mode"`
41 | if [ x"$mode" == x"" ]; then
42 | mode="bridge"
43 | break
44 | elif [ x"$mode" == x"bridge" ] || [ x"$mode" == x"guardian" ] || [ x"$mode" == x"miner" ]; then
45 | break
46 | else
47 | log_err "Input error, please input bridge/guardian/miner"
48 | fi
49 | done
50 |
51 | if [ x"$mode" == x"bridge" ]; then
52 | mode="isolation"
53 | fi
54 |
55 | if [ x"$mode" == x"guardian" ]; then
56 | mode="owner"
57 | fi
58 |
59 | if [ x"$mode" == x"miner" ]; then
60 | mode="member"
61 | fi
62 |
63 |
64 | if [ x"$mode" == x"owner" ]; then
65 | sed -i '4c \\ chain: "authority"' $configfile &>/dev/null
66 | sed -i '6c \\ storage: "disable"' $configfile &>/dev/null
67 | sed -i '8c \\ sdatamanager: "disable"' $configfile &>/dev/null
68 | sed -i '10c \\ ipfs: "disable"' $configfile &>/dev/null
69 | local old_mode=`cat $basedir/etc/mode.conf`
70 | sed -i 's/'$old_mode'/'$mode'/g' $basedir/etc/mode.conf
71 | log_success "Set spacex script mode: guardian successfully"
72 | log_success "Set configurations successfully"
73 | config_generate
74 | return
75 | elif [ x"$mode" == x"isolation" ]; then
76 | sed -i '4c \\ chain: "authority"' $configfile &>/dev/null
77 | sed -i '6c \\ storage: "enable"' $configfile &>/dev/null
78 | sed -i '8c \\ sdatamanager: "'$mode'"' $configfile &>/dev/null
79 | sed -i '10c \\ ipfs: "enable"' $configfile &>/dev/null
80 | log_success "Set spacex script mode: bridge successfully"
81 | else
82 | sed -i '4c \\ chain: "full"' $configfile &>/dev/null
83 | sed -i '6c \\ storage: "enable"' $configfile &>/dev/null
84 | sed -i '8c \\ sdatamanager: "'$mode'"' $configfile &>/dev/null
85 | sed -i '10c \\ ipfs: "enable"' $configfile &>/dev/null
86 | log_success "Set spacex script mode: miner successfully"
87 | fi
88 |
89 | local old_mode=`cat $basedir/etc/mode.conf`
90 | sed -i 's/'$old_mode'/'$mode'/g' $basedir/etc/mode.conf
91 |
92 | local identity_backup=""
93 | while true
94 | do
95 | if [ x"$mode" == x"member" ]; then
96 | read -p "Enter the backup of miner account: " identity_backup
97 | else
98 | read -p "Enter the backup of miner account: " identity_backup
99 | fi
100 |
101 | identity_backup=`echo "$identity_backup"`
102 | if [ x"$identity_backup" != x"" ]; then
103 | break
104 | else
105 | log_err "Input error, backup can't be empty"
106 | fi
107 | done
108 | sed -i "15c \\ backup: '$identity_backup'" $configfile &>/dev/null
109 | log_success "Set backup successfully"
110 |
111 | local identity_password=""
112 | while true
113 | do
114 | if [ x"$mode" == x"member" ]; then
115 | read -p "Enter the password of miner account: " identity_password
116 | else
117 | read -p "Enter the password of miner account: " identity_password
118 | fi
119 |
120 | identity_password=`echo "$identity_password"`
121 | if [ x"$identity_password" != x"" ]; then
122 | break
123 | else
124 | log_err "Input error, password can't be empty"
125 | fi
126 | done
127 | sed -i '17c \\ password: "'$identity_password'"' $configfile &>/dev/null
128 |
129 | log_success "Set password successfully"
130 | log_success "Set configurations successfully"
131 |
132 | # Generate configurations
133 | config_generate
134 | }
135 |
136 | config_conn_chain()
137 | {
138 | if [ x"$1" = x"" ]; then
139 | log_err "Please give conneted chain ws."
140 | config_help
141 | return 1
142 | fi
143 |
144 | sed -i '28c \\ ws: "'$1'"' $configfile &>/dev/null
145 | log_success "Set connected chain ws '$1' successfully"
146 | config_generate
147 | }
148 |
149 | config_chain_port()
150 | {
151 | if [ x"$1" = x"" ]; then
152 | log_err "Please give right chain port."
153 | config_help
154 | return 1
155 | fi
156 | sed -i "24c \\ port: '$1'" $configfile &>/dev/null
157 | log_success "Set chain port '$1' successfully"
158 | config_generate
159 | }
160 |
161 | config_generate()
162 | {
163 | log_info "Start generate configurations and docker compose file"
164 | local cg_image="mannheimworld/config-generator:latest"
165 |
166 | if [ ! -f "$configfile" ]; then
167 | log_err "config.yaml doesn't exists!"
168 | exit 1
169 | fi
170 |
171 | rm -rf $builddir
172 | mkdir -p $builddir
173 |
174 | cp -f $configfile $builddir/
175 | local cidfile=`mktemp`
176 | rm $cidfile
177 | docker run --cidfile $cidfile -i --workdir /opt/output -v $builddir:/opt/output $cg_image node /opt/app/index.js
178 | local res="$?"
179 | local cid=`cat $cidfile`
180 | docker rm $cid
181 |
182 | if [ "$res" -ne "0" ]; then
183 | log_err "Failed to generate application configs, please check your config.yaml"
184 | exit 1
185 | fi
186 |
187 | <<'COMMENT'
188 | invalid_paths=0
189 | while IFS= read -r line || [ -n "$line" ]; do
190 | mark=${line:0:1}
191 | path=${line:2}
192 | if [ ! -e "$path" ]; then
193 | if [ "$mark" == "|" ]; then
194 | log_warn "$path doesn't exist!"
195 | elif [ "$mark" == "+" ]; then
196 | log_err "$path doesn't exist!"
197 | invalid_paths=1
198 | fi
199 | fi
200 | done <$builddir/.tmp/.paths
201 |
202 | if [ $invalid_paths -ne "0" ]; then
203 | log_err "some paths is not valid, please check your config!"
204 | exit 1
205 | fi
206 |
207 | COMMENT
208 |
209 | rm -f $builddir/config.yaml
210 | cp -r $builddir/.tmp/* $builddir/
211 | rm -rf $builddir/.tmp
212 | chown -R root:root $builddir
213 | chmod -R 0600 $builddir
214 | chmod 0600 $configfile
215 |
216 | log_success "Configurations generated at: $builddir"
217 | }
218 |
219 | config()
220 | {
221 | case "$1" in
222 | show)
223 | config_show
224 | ;;
225 | set)
226 | config_set_all
227 | ;;
228 | conn-chain)
229 | shift
230 | config_conn_chain $@
231 | ;;
232 | chain-port)
233 | shift
234 | config_chain_port $@
235 | ;;
236 | generate)
237 | config_generate
238 | ;;
239 | *)
240 | config_help
241 | esac
242 | }
243 |
--------------------------------------------------------------------------------
/docs/miner.md:
--------------------------------------------------------------------------------
1 | ## 1. Overview
2 |
3 | ### 1.1 Node Responsibility
4 |
5 | The Miner node acts as the storage provider in Group. There can be multiple Miner nodes in a Group, and their effective storage can be clustered on Owner to participate in block generation competition. Since Miner nodes store files and perform trusted quantification, support for SGX is necessary. The Miner node is connected to its account through configuring backup files.
6 |
7 | ### 1.2 Hardware Spec
8 |
9 | The Miner node runs chain modules (not participating in block generation), storage modules, IPFS, etc. It needs to be equipped with an SGX environment. Meantime, it stores user files, involving frequent network transmission, so the network bandwidth should also be in high standards.
10 |
11 | ## 2. Ready to Deploy
12 |
13 | > Note: The account of Mannheim testnet RUBIK starting with the letter 'r'.
14 |
15 | ### 2.1 Create your Accounts
16 |
17 | Create a Miner account (a single account). The Miner node account needs to meet the following three requirements:
18 |
19 | * Ensure Miner account has 1000 HEIMs as a deposit for starting node, 10% will destroy and 90% locked (60 days) when miner cancel the node;
20 |
21 | * Ensure Miner account has 0.1-1 HEIMs as a transaction fee (cannot be locked) for sending work reports. It is recommended you check the remaining status of reserves from time to time;
22 | * Cannot be the account of Owner;
23 | * The account should be unique, meaning that it cannot be those same as other Miner accounts, that is, one chain account only for one machine;
24 |
25 | ### 2.2 Setup BIOS
26 |
27 | The SGX (Software Guard Extensions) module of the machine is closed by default. In the BIOS settings of your machine, you can set SGX to 'enable', and turn off Secure Boot (some types of motherboard do not support this setting). If your SGX only supports software enabled, please refer to this link [https://github.com/intel/sgx-software-enable](https://github.com/intel/sgx-software-enable).
28 |
29 | ### 2.3 Download Spacex Node Package
30 |
31 | a. Download
32 |
33 | ```plain
34 | wget https://github.com/mannheim-network/spacex-script/archive/refs/heads/testnet.zip
35 | ```
36 | b. Unzip
37 | ```plain
38 | tar -xvf testnet.zip
39 | ```
40 | c. Go to package directory
41 | ```plain
42 | cd spacex-script-testnet
43 | ```
44 |
45 | ### 2.4 Install Spacex Service
46 |
47 | Notices:
48 |
49 | * The program will be installed under '/opt/mannheimworld', please ensure that the **system disk has more than 2TB** of SSD space. **If you do not want to use the system disk, but use other SSD, please create the '/opt/mannheimworld' directory in advance, and hang the SSD in this directory, pay attention to the read and write permissions of the directory**;
50 |
51 | * If you have run a previous Spacex testnet program on this device, you need to close the previous Spacex Node and clear the data before this installation. For details, please refer to section 6.2;
52 |
53 | * The installation process will involve the download of dependencies and docker images, which is time-consuming. Meantime, it may fail due to network problems. If it happens, please repeat the process until the installation is all complete.
54 |
55 | Installation:
56 |
57 | ```plain
58 | sudo ./install.sh
59 | ```
60 | ## 3. Node Configuration
61 |
62 | ### 3.1 Edit Config File
63 |
64 | Execute the following command to edit the node configuration file:
65 |
66 | ```plain
67 | sudo spacex config set
68 | ```
69 | ### 3.2 Change Node Name
70 |
71 | Follow the prompts to enter the name of your node, and press Enter to end.
72 |
73 | ### 3.3 Choose Mode
74 |
75 | Follow the prompts to enter a node mode 'miner', and press Enter to end.
76 |
77 | ### 3.4 Config Account
78 |
79 | Enter the contents of the Miner's backup file into the terminal, you can follow this: copy the contents of the Miner's backup file generated when the account is created, copy it to the terminal, and enter.
80 |
81 | > Note 1: The account of Mannheim Network Rubik starting with the letter 'r'. For example, the value of "address" in the above picture is `r7H5Wbf...` which is a Mannheim testnet account.
82 |
83 | > Note 2: This backup file and its content is the credential of your account, it is very important, please do not disclose or lose it.
84 |
85 | Enter the password for the backup file as prompted and press Enter to end.
86 |
87 | ### 3.5 Config Hard Disks
88 |
89 | > Disk organization solution is not unitary. If there is a better solution, you can optimize it yourself.
90 |
91 | With Spacex as a decentralized storage network, the configuration of your hard disks becomes quite important. The node storage capacity will be reported to the Mannheim Network as reserved space, and this will determine the stake limit of this node.
92 |
93 | **Base hard disk mounting requirements:**
94 |
95 | * The order files and SRD (Sealed Random Data, the placeholder files) will be written in the /opt/mannheimworld/disks/1 ~ /opt/mannheimworld/disks/128 directory, depending on how you mount the hard disk. Each physical machine can be configured with up to 500TB of reserved space
96 |
97 | * Please pay attention to the read and write permissions of the directory after mounting
98 |
99 | **HDDs organization solution is not unitary. If there is a better solution, you can optimize it yourself**
100 |
101 | * Single HDD: mount it directly to /opt/mannheimworld/disks/1
102 | * Multiple HDDs (multi-directories): Mount the hard disks to the /opt/mannheimworld/disks/1 ~ /opt/mannheimworld/disks/128 directories respectively. For example, if there are three hard disks /dev/sdb, /dev/sdc and /dev/sdd, you can mount them to /opt/mannheimworld/disks/1, /opt/mannheimworld/disks/2, /opt/mannheimworld/disks/3 directories respectively. The efficiency of this method is relatively high, and the method is relatively simple, but the fault tolerance of the hard disk will be reduced
103 | * Multiple HDDs (single directory): For hard disks with poor stability, using RAID/LVM/mergerfs and other means to combine the hard disks and mount them to the /opt/mannheimworld/disks/1 directory is an option. This method can increase the fault tolerance of the hard disk, but it will also bring about a drop in efficiency
104 | * Multiple HDDs (mixed): Combine single directory and multiple directories to mount HDDs
105 |
106 | You can use following command to view the file directory:
107 |
108 | ```plain
109 | sudo spacex tools space-info
110 | ```
111 |
112 | ### 3.6 External chain Configuration (Optional&recommend)
113 |
114 | Enable local storage services to use external chain nodes for information collection, workload reporting, etc.
115 |
116 | Advantage:
117 | - Miner nodes are more lightweight
118 | - One chain node serves multiple miners
119 | - The reporting workload is more stable
120 | - Avoid repeated synchronization of chain nodes
121 |
122 | Disadvantages:
123 | - The single point of failure
124 | - The number of Miner connections is limited (10 or less recommended)
125 | - Additional machine (cloud server recommended)
126 |
127 | Please refer to this [link](build-node.md) for configuration
128 |
129 | ## 4. Start Node
130 |
131 | ### 4.1 Preparation
132 |
133 | To start with, you need to ensure that the following ports are not occupied: 30888 19944 19933 (occupied by spacex chain), 56666 (occupied by spacex API), 12222 (occupied by spacex storage), and 5001 4001 37773 (occupied by IPFS).
134 |
135 | Then open the P2P port:
136 |
137 | ```plain
138 | sudo ufw allow 30888
139 | ```
140 | ### 4.2 Start
141 |
142 | ```plain
143 | sudo spacex start
144 | ```
145 | ### 4.3 Check Running Status
146 |
147 | ```plain
148 | sudo spacex status
149 | ```
150 |
151 | If the following five services are running, it means that Spacex node started successfully.(The chain will not start when the external chain is configured)
152 |
153 | ### 4.4 Set Node Storage Capacity and Run SRD
154 | Please wait about 2 minutes and execute the following commands.
155 |
156 | 1 Assuming that the HDDs have 1000G of space, set it as follows, storage will reserve some space and automatically determine the size of the SRD:
157 |
158 | ```plain
159 | sudo spacex tools change-srd 1000
160 | ```
161 |
162 | 2 These commands may fail to execute. This is because storage has not been fully started. Please wait a few minutes and try again. If it still does not work, please execute the subordinate monitoring commands to troubleshoot the error:
163 |
164 | ```plain
165 | sudo spacex logs storage
166 | ```
167 |
168 | ### 4.5 Monitor
169 |
170 | Run following command to monitor your node, and press 'ctrl-c' to stop monitoring:
171 |
172 | ```plain
173 | sudo spacex logs storage
174 | ```
175 | The monitoring log is as follows:
176 |
177 | * (1) Indicating that the block is being synchronized. The process takes a long time;
178 | * (2) Having successfully registered your on-chain identity;
179 | * (3) Storage capacity statistics calculation in progress, which takes place gradually;
180 | * (4) Indicating that the storage status has been reported successfully. The process takes a long time, about an hour.
181 |
182 | ## 5. Joining Group
183 |
184 | ### 5.1 Add allowlist
185 |
186 | Miner accounts need to be added to the whitelist of the group before they can be added to the group. Enter [Spacex APPS](http://rubik.mannheim.world/#/explorer), select 'Account', select the 'Benefit' module, find the group created before (or contact the group manager for operation), and click 'Add allowed accounts'.
187 |
188 | Select the Miner account that needs to be added to the group, click 'Submit' and send the transaction, and add the account to the whitelist of the Group.
189 |
190 | ### 5.2 Join group
191 |
192 | After the first work report,select 'Benefit', click on 'Join group',select the Miner account and the Stash account, click 'Join group', enter the password of the Miner account, and finally click 'Sign and Submit' to send the transaction.
193 |
194 | ### 5.3 Lockup HEIM to reduce the fee of the work report
195 |
196 | **The work report in mainnet requires handling fees.** Under normal circumstances, each Miner will perform 24 workload reporting transactions per day, which brings a lot of handling fees. For this reason, the Spacex network provides a Benefit module that exempts workload reporting fees. Group owners can reduce or waive miner handling fees by locking HEIMs. **Each Miner** needs to lock 18HEIM for fee reduction. However, considering the unstable reporting of workload, it is recommended to lock 24HEIM~30HEIM to ensure that the fee is completely free.
197 |
198 | Enter [Spacex APPS](http://rubik.mannheim.world/#/explorer), select 'Account', select the 'Benefit' module, find the group created before (or contact the group manager for operation), and click 'Increase lockup'.
199 |
200 | Enter the number of HEIMs that **need to be added**, and sign the transaction, as follows.
201 |
202 | ## 6. Restart and Uninstall
203 |
204 | ### 6.1 Restart
205 |
206 | If the device or Spacex node related programs need to be somehow restarted, please refer to the following steps.
207 |
208 | **Please note**: This section only concerns restarting steps of Spacex nodes, not including the basic software and hardware environment settings and inspection related information, such as hard disk mounting, IPFS configurations, etc. Please ensure that the hardware and software configuration is correct, and perform the following steps:
209 |
210 | ```plain
211 | sudo spacex reload
212 | ```
213 |
214 | ### 6.2 Uninstall and Data Cleanup
215 |
216 | If you have run a previous version of Mannheim testnet, or if you want to redeploy your current node, you need to clear data from three sources:
217 |
218 | * Delete basic Spacex files under /opt/mannheimworld/data and /opt/mannheimworld/disks
219 | * Clean node data under /opt/mannheimworld/spacex-script by executing:
220 |
221 | ```plain
222 | sudo /opt/mannheimworld/spacex-script/scripts/uninstall.sh
223 | ```
--------------------------------------------------------------------------------
/scripts/tools.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | source /opt/mannheimworld/spacex-script/scripts/utils.sh
4 |
5 | tools_help()
6 | {
7 | cat << EOF
8 | Spacex tools usage:
9 | help show help information
10 | space-info show information about data folders
11 | rotate-keys generate session key of chain node
12 | upgrade-image {chain|api|sdatamanager|ipfs|c-gen|sw} upgrade one docker image
13 | storage-ab-upgrade {code} storage AB upgrade
14 | workload show workload information
15 | file-info {all|valid|lost|pending|{cid}} {output-file} show file information
16 | delete-file {cid} delete one file
17 | change-srd {number} change storage's srd capacity(GB), for example: 'change-srd 100', 'change-srd -50'
18 | ipfs {...} ipfs command, for example 'ipfs pin ls', 'ipfs swarm peers'
19 | watch-chain generate watch chain node docker-compose file and show help
20 | set-storage-debug {true|false} set storage debug
21 | EOF
22 | }
23 |
24 | space_info()
25 | {
26 | local data_folder_info=(`df -h /opt/mannheimworld/data | sed -n '2p'`)
27 | cat << EOF
28 | >>>>>> Base data folder <<<<<<
29 | Path: /opt/mannheimworld/data
30 | File system: ${data_folder_info[0]}
31 | Total space: ${data_folder_info[1]}
32 | Used space: ${data_folder_info[2]}
33 | Avail space: ${data_folder_info[3]}
34 | EOF
35 | local has_disks=false
36 | for i in $(seq 1 128); do
37 | local disk_folder_info=(`df -h /opt/mannheimworld/disks/${i} | sed -n '2p'`)
38 | if [ x"${disk_folder_info[0]}" != x"${data_folder_info[0]}" ]; then
39 | printf "\n>>>>>> Storage folder ${i} <<<<<<\n"
40 | printf "Path: /opt/mannheimworld/disks/${i}\n"
41 | printf "File system: ${disk_folder_info[0]}\n"
42 | printf "Total space: ${disk_folder_info[1]}\n"
43 | printf "Used space: ${disk_folder_info[2]}\n"
44 | printf "Avail space: ${disk_folder_info[3]}\n"
45 | has_disks=true
46 | fi
47 | done
48 |
49 | if [ "$has_disks" == false ]; then
50 | log_err "Please mount the hard disk to storage folders, paths is from: /opt/mannheimworld/disks/1 ~ /opt/mannheimworld/disks/128"
51 | return 1
52 | fi
53 |
54 | cat << EOF
55 |
56 | PS:
57 | 1. Base data folder is used to store chain and db, 2TB SSD is recommended, you can mount SSD on /opt/mannheimworld/data
58 | 2. Please mount the hard disk to storage folders, paths is from: /opt/mannheimworld/disks/1 ~ /opt/mannheimworld/disks/128
59 | 3. SRD will not use all the space, it will reserve 50G of space
60 | EOF
61 | }
62 |
63 | rotate_keys()
64 | {
65 | check_docker_status spacex
66 | if [ $? -ne 0 ]; then
67 | log_info "Service chain is not started or exited now"
68 | return 0
69 | fi
70 |
71 | local res=`curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' http://localhost:19933 2>/dev/null`
72 | session_key=`echo $res | jq .result`
73 | if [ x"$session_key" = x"" ]; then
74 | log_err "Generate session key failed"
75 | return 1
76 | fi
77 | echo $session_key
78 | }
79 |
80 | change_srd()
81 | {
82 | if [ x"$1" == x"" ] || [[ ! $1 =~ ^[1-9][0-9]*$|^[-][1-9][0-9]*$|^0$ ]]; then
83 | log_err "The input of srd change must be integer number"
84 | tools_help
85 | return 1
86 | fi
87 |
88 | local a_or_b=`cat $basedir/etc/storage.ab`
89 | check_docker_status spacex-storage-$a_or_b
90 | if [ $? -ne 0 ]; then
91 | log_info "Service spacex storage is not started or exited now"
92 | return 0
93 | fi
94 |
95 | if [ ! -f "$builddir/storage/storage_config.json" ]; then
96 | log_err "No storage configuration file"
97 | return 1
98 | fi
99 |
100 | local base_url=`cat $builddir/storage/storage_config.json | jq .base_url`
101 | base_url=${base_url%?}
102 | base_url=${base_url:1}
103 |
104 | curl -XPOST ''$base_url'/srd/change' -H 'backup: '$backup'' --data-raw '{"change" : '$1'}'
105 | }
106 |
107 | workload()
108 | {
109 | local a_or_b=`cat $basedir/etc/storage.ab`
110 | check_docker_status spacex-storage-$a_or_b
111 | if [ $? -ne 0 ]; then
112 | log_info "Service spacex storage is not started or exited now"
113 | return 0
114 | fi
115 |
116 | local base_url=`cat $builddir/storage/storage_config.json | jq .base_url`
117 | base_url=${base_url%?}
118 | base_url=${base_url:1}
119 |
120 | curl $base_url/workload
121 | }
122 |
123 | file_info()
124 | {
125 | local a_or_b=`cat $basedir/etc/storage.ab`
126 | check_docker_status spacex-storage-$a_or_b
127 | if [ $? -ne 0 ]; then
128 | log_info "Service spacex storage is not started or exited now"
129 | return 0
130 | fi
131 |
132 | local base_url=`cat $builddir/storage/storage_config.json | jq .base_url`
133 | base_url=${base_url%?}
134 | base_url=${base_url:1}
135 |
136 | if [ x"$1" == x"" ]; then
137 | tools_help
138 | return 1
139 | fi
140 |
141 | local output=""
142 |
143 | if [ x"$2" != x"" ]; then
144 | output="--output $2"
145 | fi
146 |
147 | if [ ${#1} -eq 46 ];then
148 | curl -X GET ''$base_url'/file/info?cid='$1'' $output
149 | return $?
150 | fi
151 |
152 | if [ x"$1" != x"all" ] && [ x"$1" != x"valid" ] && [ x"$1" != x"lost" ] && [ x"$1" != x"pending" ]; then
153 | tools_help
154 | return 1
155 | fi
156 |
157 | curl -X GET ''$base_url'/file/info_by_type?type='$1'' $output
158 | return $?
159 | }
160 |
161 | delete_file()
162 | {
163 | local a_or_b=`cat $basedir/etc/storage.ab`
164 | check_docker_status spacex-storage-$a_or_b
165 | if [ $? -ne 0 ]; then
166 | log_info "Service spacex storage is not started or exited now"
167 | return 0
168 | fi
169 |
170 | local base_url=`cat $builddir/storage/storage_config.json | jq .base_url`
171 | base_url=${base_url%?}
172 | base_url=${base_url:1}
173 | curl --request POST ''$base_url'/storage/delete' --header 'Content-Type: application/json' --data-raw '{"cid":"'$1'"}'
174 | }
175 |
176 | set_stoarge_debug()
177 | {
178 | local a_or_b=`cat $basedir/etc/storage.ab`
179 | check_docker_status spacex-storage-$a_or_b
180 | if [ $? -ne 0 ]; then
181 | log_info "Service spacex storage is not started or exited now"
182 | return 0
183 | fi
184 |
185 | if [ x"$1" != x"true" ] && [ x"$1" != x"false" ]; then
186 | tools_help
187 | return 1
188 | fi
189 |
190 | local base_url=`cat $builddir/storage/storage_config.json | jq .base_url`
191 | base_url=${base_url%?}
192 | base_url=${base_url:1}
193 | curl --request POST ''$base_url'/debug' --header 'Content-Type: application/json' --data-raw '{"debug":'$1'}'
194 | }
195 |
196 | upgrade_image()
197 | {
198 | if [ x"$1" == x"chain" ]; then
199 | upgrade_docker_image spacex $2
200 | if [ $? -ne 0 ]; then
201 | return 1
202 | fi
203 | elif [ x"$1" == x"api" ]; then
204 | upgrade_docker_image spacex-api $2
205 | if [ $? -ne 0 ]; then
206 | return 1
207 | fi
208 | elif [ x"$1" == x"sdatamanager" ]; then
209 | upgrade_docker_image spacex-sdatamanager $2
210 | if [ $? -ne 0 ]; then
211 | return 1
212 | fi
213 | elif [ x"$1" == x"ipfs" ]; then
214 | upgrade_docker_image go-ipfs $2
215 | if [ $? -ne 0 ]; then
216 | return 1
217 | fi
218 | elif [ x"$1" == x"c-gen" ]; then
219 | upgrade_docker_image config-generator $2
220 | if [ $? -ne 0 ]; then
221 | return 1
222 | fi
223 | elif [ x"$1" == x"sw" ]; then
224 | upgrade_docker_image spacex-storage $2
225 | if [ $? -ne 0 ]; then
226 | return 1
227 | fi
228 | else
229 | tools_help
230 | fi
231 | }
232 |
233 | ipfs_cmd()
234 | {
235 | check_docker_status ipfs
236 | if [ $? -ne 0 ]; then
237 | log_info "Service ipfs is not started or exited now"
238 | return 0
239 | fi
240 | docker exec -i ipfs ipfs $@
241 | }
242 |
243 | storage_ab_upgrade()
244 | {
245 | # Check input
246 | if [ x"$1" == x"" ]; then
247 | log_err "Please give storage code."
248 | return 1
249 | fi
250 |
251 | if [ ${#1} -ne 64 ];then
252 | log_err "Please give right storage code."
253 | return 1
254 | fi
255 | local code=$1
256 |
257 | # Check storage
258 | local a_or_b=`cat $basedir/etc/storage.ab`
259 | check_docker_status spacex-storage-$a_or_b
260 | if [ $? -ne 0 ]; then
261 | log_err "Service spacex storage is not started or exited now"
262 | return 1
263 | fi
264 |
265 | log_info "Start storage A/B upgragde...."
266 |
267 | # Get configurations
268 | local config_file=$builddir/storage/storage_config.json
269 | if [ x"$config_file" = x"" ]; then
270 | log_err "please give right config file"
271 | return 1
272 | fi
273 |
274 | api_base_url=`cat $config_file | jq .chain.base_url`
275 | storage_base_url=`cat $config_file | jq .base_url`
276 |
277 | if [ x"$api_base_url" = x"" ] || [ x"$storage_base_url" = x"" ]; then
278 | log_err "please give right config file"
279 | return 1
280 | fi
281 |
282 | api_base_url=`echo "$api_base_url" | sed -e 's/^"//' -e 's/"$//'`
283 | storage_base_url=`echo "$storage_base_url" | sed -e 's/^"//' -e 's/"$//'`
284 |
285 | log_info "Read configurations success."
286 |
287 | if [ x"$2" != x"--offline" ]; then
288 | # Check chain
289 | while :
290 | do
291 | system_health=`curl --max-time 30 $api_base_url/system/health 2>/dev/null`
292 | if [ x"$system_health" = x"" ]; then
293 | log_err "Service spacex chain or api is not started or exited now"
294 | return 1
295 | fi
296 |
297 | is_syncing=`echo $system_health | jq .isSyncing`
298 | if [ x"$is_syncing" = x"" ]; then
299 | log_err "Service spacex api dose not connet to spacex chain"
300 | return 1
301 | fi
302 |
303 | if [ x"$is_syncing" = x"true" ]; then
304 | printf "\n"
305 | for i in $(seq 1 60); do
306 | printf "spacex chain is syncing, please wait 60s, now is %s\r" "${i}s"
307 | sleep 1
308 | done
309 | continue
310 | fi
311 | break
312 | done
313 | fi
314 |
315 | # Get code from storage
316 | local id_info=`curl --max-time 30 $storage_base_url/enclave/id_info 2>/dev/null`
317 | if [ x"$id_info" = x"" ]; then
318 | log_err "Please check storage logs to find more information"
319 | return 1
320 | fi
321 |
322 | local mrenclave=`echo $id_info | jq .mrenclave`
323 | if [ x"$mrenclave" = x"" ] || [ ! ${#mrenclave} -eq 66 ]; then
324 | log_err "Please check storage logs to find more information"
325 | return 1
326 | fi
327 | mrenclave=`echo ${mrenclave: 1: 64}`
328 | log_info "storage self code: $mrenclave"
329 |
330 | if [ x"$mrenclave" == x"$code" ]; then
331 | log_success "storage is already latest"
332 | while :
333 | do
334 | check_docker_status spacex-storage-a
335 | local resa=$?
336 | check_docker_status spacex-storage-b
337 | local resb=$?
338 | if [ $resa -eq 0 ] && [ $resb -eq 0 ] ; then
339 | sleep 10
340 | continue
341 | fi
342 | break
343 | done
344 |
345 | check_docker_status spacex-storage-a
346 | if [ $? -eq 0 ]; then
347 | local aimage=(`docker ps -a | grep 'spacex-storage-a'`)
348 | aimage=${aimage[1]}
349 | if [ x"$aimage" != x"mannheimworld/spacex-storage:latest" ]; then
350 | docker tag $aimage mannheimworld/spacex-storage:latest
351 | fi
352 | fi
353 |
354 | check_docker_status spacex-storage-b
355 | if [ $? -eq 0 ]; then
356 | local bimage=(`docker ps -a | grep 'spacex-storage-b'`)
357 | bimage=${bimage[1]}
358 | if [ x"$bimage" != x"mannheimworld/spacex-storage:latest" ]; then
359 | docker tag $bimage mannheimworld/spacex-storage:latest
360 | fi
361 | fi
362 | return 0
363 | fi
364 |
365 | # Upgrade storage images
366 | local old_image=(`docker images | grep '^\b'mannheimworld/spacex-storage'\b ' | grep 'latest'`)
367 | old_image=${old_image[2]}
368 |
369 | local region=`cat $basedir/etc/region.conf`
370 | local docker_org="mannheimworld"
371 | if [ x"$region" == x"cn" ]; then
372 | docker_org=$aliyun_address/$docker_org
373 | fi
374 |
375 | local res=0
376 | docker pull $docker_org/spacex-storage:$code
377 | res=$(($?|$res))
378 | docker tag $docker_org/spacex-storage:$code mannheimworld/spacex-storage:latest
379 |
380 | if [ $res -ne 0 ]; then
381 | log_err "Download storage docker image failed"
382 | return 1
383 | fi
384 |
385 | local new_image=(`docker images | grep '^\b'mannheimworld/spacex-storage'\b ' | grep 'latest'`)
386 | new_image=${new_image[2]}
387 | if [ x"$old_image" = x"$new_image" ]; then
388 | log_info "The current storage docker image is already the latest"
389 | return 1
390 | fi
391 |
392 | # Start A/B
393 | if [ x"$a_or_b" = x"a" ]; then
394 | a_or_b='b'
395 | else
396 | a_or_b='a'
397 | fi
398 |
399 | check_docker_status spacex-storage-a
400 | local resa=$?
401 | check_docker_status spacex-storage-b
402 | local resb=$?
403 | if [ $resa -eq 0 ] && [ $resb -eq 0 ] ; then
404 | log_info "storage A/B upgrade is already in progress"
405 | else
406 | docker stop spacex-storage-$a_or_b &>/dev/null
407 | docker rm spacex-storage-$a_or_b &>/dev/null
408 |
409 | shift
410 | EX_STORAGE_ARGS="--upgrade $@" docker-compose -f $composeyaml up -d spacex-storage-$a_or_b
411 |
412 | if [ $? -ne 0 ]; then
413 | log_err "Setup new storage failed"
414 | docker tag $old_image mannheimworld/spacex-storage:latest
415 | return 1
416 | fi
417 | fi
418 |
419 | # Change back to older image
420 | docker tag $old_image mannheimworld/spacex-storage:latest
421 | log_info "Please do not close this program and wait patiently, ."
422 | log_info "If you need more information, please use other terminal to execute 'sudo spacex logs storage-a' and 'sudo spacex logs storage-b'"
423 |
424 | # Check A/B status
425 | local acc=0
426 | while :
427 | do
428 | printf "storage is upgrading, please do not close this program. Wait %s\r" "${acc}s"
429 | ((acc++))
430 | sleep 1
431 |
432 | # Get code from storage
433 | local id_info=`curl --max-time 30 $storage_base_url/enclave/id_info 2>/dev/null`
434 | if [ x"$id_info" != x"" ]; then
435 | local mrenclave=`echo $id_info | jq .mrenclave`
436 | if [ x"$mrenclave" != x"" ]; then
437 | mrenclave=`echo ${mrenclave: 1: 64}`
438 | if [ x"$mrenclave" == x"$code" ]; then
439 | break
440 | fi
441 | fi
442 | fi
443 |
444 | # Check upgrade storage status
445 | check_docker_status spacex-storage-$a_or_b
446 | if [ $? -ne 0 ]; then
447 | printf "\n"
448 | log_err "storage update failed, please use 'sudo spacex logs storage-a' and 'sudo spacex logs storage-b' to find more details"
449 | return 1
450 | fi
451 | done
452 |
453 | # Set new information
454 | docker tag $new_image mannheimworld/spacex-storage:latest
455 |
456 | if [ x"$a_or_b" = x"a" ]; then
457 | sed -i 's/b/a/g' $basedir/etc/storage.ab
458 | else
459 | sed -i 's/a/b/g' $basedir/etc/storage.ab
460 | fi
461 |
462 | printf "\n"
463 | log_success "storage update success, setup new storage 'spacex-storage-$a_or_b'"
464 | }
465 |
466 | watch_chain()
467 | {
468 | cp $basedir/etc/watch-chain.yaml watch-chain.yaml
469 |
470 | cat << EOF
471 | The 'watch-chain.yaml' file has been generated your current path, use docker-compose to start the watch chain node
472 |
473 | PS:
474 | 1. Watch chain node can provide ws and rpc services, please open 30888, 19933 and 19944 ports
475 | 2. You can edit 'watch-chain.yaml' to customize your watch chain
476 | 3. The simplest startup example: 'sudo docker-compose -f watch-chain.yaml up -d'
477 | 4. With external connect chain configuration, a topology structure where one chain node serves multiple members can be realized
478 | EOF
479 | }
480 |
481 | tools()
482 | {
483 | case "$1" in
484 | space-info)
485 | space_info
486 | ;;
487 | change-srd)
488 | change_srd $2
489 | ;;
490 | rotate-keys)
491 | rotate_keys
492 | ;;
493 | workload)
494 | workload
495 | ;;
496 | file-info)
497 | file_info $2
498 | ;;
499 | delete-file)
500 | delete_file $2
501 | ;;
502 | set-storage-debug)
503 | set_storage_debug $2
504 | ;;
505 | upgrade-image)
506 | upgrade_image $2 $3
507 | ;;
508 | storage-ab-upgrade)
509 | shift
510 | storage_ab_upgrade $@
511 | ;;
512 | watch-chain)
513 | watch_chain
514 | ;;
515 | ipfs)
516 | shift
517 | ipfs_cmd $@
518 | ;;
519 | *)
520 | tools_help
521 | esac
522 | }
523 |
--------------------------------------------------------------------------------
/generator/pnpm-lock.yaml:
--------------------------------------------------------------------------------
1 | dependencies:
2 | bluebird: 3.7.2
3 | execa: 4.0.3
4 | fs-extra: 9.0.1
5 | joi: 17.1.1
6 | js-yaml: 3.14.0
7 | lodash: 4.17.19
8 | shelljs: 0.8.4
9 | winston: 3.3.3
10 | lockfileVersion: 5.1
11 | packages:
12 | /@dabh/diagnostics/2.0.2:
13 | dependencies:
14 | colorspace: 1.1.2
15 | enabled: 2.0.0
16 | kuler: 2.0.0
17 | dev: false
18 | resolution:
19 | integrity: sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q==
20 | /@hapi/address/4.1.0:
21 | dependencies:
22 | '@hapi/hoek': 9.0.4
23 | dev: false
24 | resolution:
25 | integrity: sha512-SkszZf13HVgGmChdHo/PxchnSaCJ6cetVqLzyciudzZRT0jcOouIF/Q93mgjw8cce+D+4F4C1Z/WrfFN+O3VHQ==
26 | /@hapi/formula/2.0.0:
27 | deprecated: This version has been deprecated and is no longer supported or maintained
28 | dev: false
29 | resolution:
30 | integrity: sha512-V87P8fv7PI0LH7LiVi8Lkf3x+KCO7pQozXRssAHNXXL9L1K+uyu4XypLXwxqVDKgyQai6qj3/KteNlrqDx4W5A==
31 | /@hapi/hoek/9.0.4:
32 | dev: false
33 | resolution:
34 | integrity: sha512-EwaJS7RjoXUZ2cXXKZZxZqieGtc7RbvQhUy8FwDoMQtxWVi14tFjeFCYPZAM1mBCpOpiBpyaZbb9NeHc7eGKgw==
35 | /@hapi/pinpoint/2.0.0:
36 | dev: false
37 | resolution:
38 | integrity: sha512-vzXR5MY7n4XeIvLpfl3HtE3coZYO4raKXW766R6DZw/6aLqR26iuZ109K7a0NtF2Db0jxqh7xz2AxkUwpUFybw==
39 | /@hapi/topo/5.0.0:
40 | dependencies:
41 | '@hapi/hoek': 9.0.4
42 | dev: false
43 | resolution:
44 | integrity: sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw==
45 | /argparse/1.0.10:
46 | dependencies:
47 | sprintf-js: 1.0.3
48 | dev: false
49 | resolution:
50 | integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
51 | /async/3.2.0:
52 | dev: false
53 | resolution:
54 | integrity: sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==
55 | /at-least-node/1.0.0:
56 | dev: false
57 | engines:
58 | node: '>= 4.0.0'
59 | resolution:
60 | integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
61 | /balanced-match/1.0.0:
62 | dev: false
63 | resolution:
64 | integrity: sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
65 | /bluebird/3.7.2:
66 | dev: false
67 | resolution:
68 | integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
69 | /brace-expansion/1.1.11:
70 | dependencies:
71 | balanced-match: 1.0.0
72 | concat-map: 0.0.1
73 | dev: false
74 | resolution:
75 | integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
76 | /color-convert/1.9.3:
77 | dependencies:
78 | color-name: 1.1.3
79 | dev: false
80 | resolution:
81 | integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
82 | /color-name/1.1.3:
83 | dev: false
84 | resolution:
85 | integrity: sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
86 | /color-name/1.1.4:
87 | dev: false
88 | resolution:
89 | integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
90 | /color-string/1.5.3:
91 | dependencies:
92 | color-name: 1.1.4
93 | simple-swizzle: 0.2.2
94 | dev: false
95 | resolution:
96 | integrity: sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==
97 | /color/3.0.0:
98 | dependencies:
99 | color-convert: 1.9.3
100 | color-string: 1.5.3
101 | dev: false
102 | resolution:
103 | integrity: sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==
104 | /colors/1.4.0:
105 | dev: false
106 | engines:
107 | node: '>=0.1.90'
108 | resolution:
109 | integrity: sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==
110 | /colorspace/1.1.2:
111 | dependencies:
112 | color: 3.0.0
113 | text-hex: 1.0.0
114 | dev: false
115 | resolution:
116 | integrity: sha512-vt+OoIP2d76xLhjwbBaucYlNSpPsrJWPlBTtwCpQKIu6/CSMutyzX93O/Do0qzpH3YoHEes8YEFXyZ797rEhzQ==
117 | /concat-map/0.0.1:
118 | dev: false
119 | resolution:
120 | integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
121 | /core-util-is/1.0.2:
122 | dev: false
123 | resolution:
124 | integrity: sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=
125 | /cross-spawn/7.0.3:
126 | dependencies:
127 | path-key: 3.1.1
128 | shebang-command: 2.0.0
129 | which: 2.0.2
130 | dev: false
131 | engines:
132 | node: '>= 8'
133 | resolution:
134 | integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
135 | /enabled/2.0.0:
136 | dev: false
137 | resolution:
138 | integrity: sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==
139 | /end-of-stream/1.4.4:
140 | dependencies:
141 | once: 1.4.0
142 | dev: false
143 | resolution:
144 | integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==
145 | /esprima/4.0.1:
146 | dev: false
147 | engines:
148 | node: '>=4'
149 | hasBin: true
150 | resolution:
151 | integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
152 | /execa/4.0.3:
153 | dependencies:
154 | cross-spawn: 7.0.3
155 | get-stream: 5.1.0
156 | human-signals: 1.1.1
157 | is-stream: 2.0.0
158 | merge-stream: 2.0.0
159 | npm-run-path: 4.0.1
160 | onetime: 5.1.0
161 | signal-exit: 3.0.3
162 | strip-final-newline: 2.0.0
163 | dev: false
164 | engines:
165 | node: '>=10'
166 | resolution:
167 | integrity: sha512-WFDXGHckXPWZX19t1kCsXzOpqX9LWYNqn4C+HqZlk/V0imTkzJZqf87ZBhvpHaftERYknpk0fjSylnXVlVgI0A==
168 | /fast-safe-stringify/2.0.7:
169 | dev: false
170 | resolution:
171 | integrity: sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==
172 | /fecha/4.2.0:
173 | dev: false
174 | resolution:
175 | integrity: sha512-aN3pcx/DSmtyoovUudctc8+6Hl4T+hI9GBBHLjA76jdZl7+b1sgh5g4k+u/GL3dTy1/pnYzKp69FpJ0OicE3Wg==
176 | /fn.name/1.1.0:
177 | dev: false
178 | resolution:
179 | integrity: sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==
180 | /fs-extra/9.0.1:
181 | dependencies:
182 | at-least-node: 1.0.0
183 | graceful-fs: 4.2.4
184 | jsonfile: 6.0.1
185 | universalify: 1.0.0
186 | dev: false
187 | engines:
188 | node: '>=10'
189 | resolution:
190 | integrity: sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==
191 | /fs.realpath/1.0.0:
192 | dev: false
193 | resolution:
194 | integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
195 | /get-stream/5.1.0:
196 | dependencies:
197 | pump: 3.0.0
198 | dev: false
199 | engines:
200 | node: '>=8'
201 | resolution:
202 | integrity: sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==
203 | /glob/7.1.6:
204 | dependencies:
205 | fs.realpath: 1.0.0
206 | inflight: 1.0.6
207 | inherits: 2.0.4
208 | minimatch: 3.0.4
209 | once: 1.4.0
210 | path-is-absolute: 1.0.1
211 | dev: false
212 | resolution:
213 | integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
214 | /graceful-fs/4.2.4:
215 | dev: false
216 | resolution:
217 | integrity: sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
218 | /human-signals/1.1.1:
219 | dev: false
220 | engines:
221 | node: '>=8.12.0'
222 | resolution:
223 | integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==
224 | /inflight/1.0.6:
225 | dependencies:
226 | once: 1.4.0
227 | wrappy: 1.0.2
228 | dev: false
229 | resolution:
230 | integrity: sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
231 | /inherits/2.0.4:
232 | dev: false
233 | resolution:
234 | integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
235 | /interpret/1.4.0:
236 | dev: false
237 | engines:
238 | node: '>= 0.10'
239 | resolution:
240 | integrity: sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==
241 | /is-arrayish/0.3.2:
242 | dev: false
243 | resolution:
244 | integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==
245 | /is-stream/2.0.0:
246 | dev: false
247 | engines:
248 | node: '>=8'
249 | resolution:
250 | integrity: sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==
251 | /isarray/1.0.0:
252 | dev: false
253 | resolution:
254 | integrity: sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
255 | /isexe/2.0.0:
256 | dev: false
257 | resolution:
258 | integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=
259 | /joi/17.1.1:
260 | dependencies:
261 | '@hapi/address': 4.1.0
262 | '@hapi/formula': 2.0.0
263 | '@hapi/hoek': 9.0.4
264 | '@hapi/pinpoint': 2.0.0
265 | '@hapi/topo': 5.0.0
266 | dev: false
267 | resolution:
268 | integrity: sha512-fww3Ae9cRyj6yHy90cpxvL2y39V5JCY2KaXV3KfALhoFfFcAuyQBPOq+2q6EZ2QNMn1FhkDy+eRkGVG7J+BvyA==
269 | /js-yaml/3.14.0:
270 | dependencies:
271 | argparse: 1.0.10
272 | esprima: 4.0.1
273 | dev: false
274 | hasBin: true
275 | resolution:
276 | integrity: sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==
277 | /jsonfile/6.0.1:
278 | dependencies:
279 | universalify: 1.0.0
280 | dev: false
281 | optionalDependencies:
282 | graceful-fs: 4.2.4
283 | resolution:
284 | integrity: sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==
285 | /kuler/2.0.0:
286 | dev: false
287 | resolution:
288 | integrity: sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==
289 | /lodash/4.17.19:
290 | dev: false
291 | resolution:
292 | integrity: sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
293 | /logform/2.2.0:
294 | dependencies:
295 | colors: 1.4.0
296 | fast-safe-stringify: 2.0.7
297 | fecha: 4.2.0
298 | ms: 2.1.2
299 | triple-beam: 1.3.0
300 | dev: false
301 | resolution:
302 | integrity: sha512-N0qPlqfypFx7UHNn4B3lzS/b0uLqt2hmuoa+PpuXNYgozdJYAyauF5Ky0BWVjrxDlMWiT3qN4zPq3vVAfZy7Yg==
303 | /merge-stream/2.0.0:
304 | dev: false
305 | resolution:
306 | integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
307 | /mimic-fn/2.1.0:
308 | dev: false
309 | engines:
310 | node: '>=6'
311 | resolution:
312 | integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
313 | /minimatch/3.0.4:
314 | dependencies:
315 | brace-expansion: 1.1.11
316 | dev: false
317 | resolution:
318 | integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
319 | /ms/2.1.2:
320 | dev: false
321 | resolution:
322 | integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
323 | /npm-run-path/4.0.1:
324 | dependencies:
325 | path-key: 3.1.1
326 | dev: false
327 | engines:
328 | node: '>=8'
329 | resolution:
330 | integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==
331 | /once/1.4.0:
332 | dependencies:
333 | wrappy: 1.0.2
334 | dev: false
335 | resolution:
336 | integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
337 | /one-time/1.0.0:
338 | dependencies:
339 | fn.name: 1.1.0
340 | dev: false
341 | resolution:
342 | integrity: sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==
343 | /onetime/5.1.0:
344 | dependencies:
345 | mimic-fn: 2.1.0
346 | dev: false
347 | engines:
348 | node: '>=6'
349 | resolution:
350 | integrity: sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==
351 | /path-is-absolute/1.0.1:
352 | dev: false
353 | engines:
354 | node: '>=0.10.0'
355 | resolution:
356 | integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
357 | /path-key/3.1.1:
358 | dev: false
359 | engines:
360 | node: '>=8'
361 | resolution:
362 | integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
363 | /path-parse/1.0.6:
364 | dev: false
365 | resolution:
366 | integrity: sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
367 | /process-nextick-args/2.0.1:
368 | dev: false
369 | resolution:
370 | integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
371 | /pump/3.0.0:
372 | dependencies:
373 | end-of-stream: 1.4.4
374 | once: 1.4.0
375 | dev: false
376 | resolution:
377 | integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==
378 | /readable-stream/2.3.7:
379 | dependencies:
380 | core-util-is: 1.0.2
381 | inherits: 2.0.4
382 | isarray: 1.0.0
383 | process-nextick-args: 2.0.1
384 | safe-buffer: 5.1.2
385 | string_decoder: 1.1.1
386 | util-deprecate: 1.0.2
387 | dev: false
388 | resolution:
389 | integrity: sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==
390 | /readable-stream/3.6.0:
391 | dependencies:
392 | inherits: 2.0.4
393 | string_decoder: 1.3.0
394 | util-deprecate: 1.0.2
395 | dev: false
396 | engines:
397 | node: '>= 6'
398 | resolution:
399 | integrity: sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==
400 | /rechoir/0.6.2:
401 | dependencies:
402 | resolve: 1.17.0
403 | dev: false
404 | engines:
405 | node: '>= 0.10'
406 | resolution:
407 | integrity: sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=
408 | /resolve/1.17.0:
409 | dependencies:
410 | path-parse: 1.0.6
411 | dev: false
412 | resolution:
413 | integrity: sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==
414 | /safe-buffer/5.1.2:
415 | dev: false
416 | resolution:
417 | integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
418 | /safe-buffer/5.2.1:
419 | dev: false
420 | resolution:
421 | integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
422 | /shebang-command/2.0.0:
423 | dependencies:
424 | shebang-regex: 3.0.0
425 | dev: false
426 | engines:
427 | node: '>=8'
428 | resolution:
429 | integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==
430 | /shebang-regex/3.0.0:
431 | dev: false
432 | engines:
433 | node: '>=8'
434 | resolution:
435 | integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
436 | /shelljs/0.8.4:
437 | dependencies:
438 | glob: 7.1.6
439 | interpret: 1.4.0
440 | rechoir: 0.6.2
441 | dev: false
442 | engines:
443 | node: '>=4'
444 | hasBin: true
445 | resolution:
446 | integrity: sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
447 | /signal-exit/3.0.3:
448 | dev: false
449 | resolution:
450 | integrity: sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==
451 | /simple-swizzle/0.2.2:
452 | dependencies:
453 | is-arrayish: 0.3.2
454 | dev: false
455 | resolution:
456 | integrity: sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=
457 | /sprintf-js/1.0.3:
458 | dev: false
459 | resolution:
460 | integrity: sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
461 | /stack-trace/0.0.10:
462 | dev: false
463 | resolution:
464 | integrity: sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=
465 | /string_decoder/1.1.1:
466 | dependencies:
467 | safe-buffer: 5.1.2
468 | dev: false
469 | resolution:
470 | integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
471 | /string_decoder/1.3.0:
472 | dependencies:
473 | safe-buffer: 5.2.1
474 | dev: false
475 | resolution:
476 | integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==
477 | /strip-final-newline/2.0.0:
478 | dev: false
479 | engines:
480 | node: '>=6'
481 | resolution:
482 | integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==
483 | /text-hex/1.0.0:
484 | dev: false
485 | resolution:
486 | integrity: sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==
487 | /triple-beam/1.3.0:
488 | dev: false
489 | resolution:
490 | integrity: sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==
491 | /universalify/1.0.0:
492 | dev: false
493 | engines:
494 | node: '>= 10.0.0'
495 | resolution:
496 | integrity: sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==
497 | /util-deprecate/1.0.2:
498 | dev: false
499 | resolution:
500 | integrity: sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
501 | /which/2.0.2:
502 | dependencies:
503 | isexe: 2.0.0
504 | dev: false
505 | engines:
506 | node: '>= 8'
507 | hasBin: true
508 | resolution:
509 | integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==
510 | /winston-transport/4.4.0:
511 | dependencies:
512 | readable-stream: 2.3.7
513 | triple-beam: 1.3.0
514 | dev: false
515 | engines:
516 | node: '>= 6.4.0'
517 | resolution:
518 | integrity: sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw==
519 | /winston/3.3.3:
520 | dependencies:
521 | '@dabh/diagnostics': 2.0.2
522 | async: 3.2.0
523 | is-stream: 2.0.0
524 | logform: 2.2.0
525 | one-time: 1.0.0
526 | readable-stream: 3.6.0
527 | stack-trace: 0.0.10
528 | triple-beam: 1.3.0
529 | winston-transport: 4.4.0
530 | dev: false
531 | engines:
532 | node: '>= 6.4.0'
533 | resolution:
534 | integrity: sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw==
535 | /wrappy/1.0.2:
536 | dev: false
537 | resolution:
538 | integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
539 | specifiers:
540 | bluebird: ^3.7.2
541 | execa: ^4.0.3
542 | fs-extra: ^9.0.1
543 | joi: ^17.1.1
544 | js-yaml: ^3.14.0
545 | lodash: ^4.17.19
546 | shelljs: ^0.8.4
547 | winston: ^3.3.3
548 |
--------------------------------------------------------------------------------
/scripts/spacex.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | source /opt/mannheimworld/spacex-script/scripts/utils.sh
4 | source /opt/mannheimworld/spacex-script/scripts/version.sh
5 | source /opt/mannheimworld/spacex-script/scripts/config.sh
6 | source /opt/mannheimworld/spacex-script/scripts/tools.sh
7 | export EX_STORAGE_ARGS=''
8 |
9 |
10 | start()
11 | {
12 | if [ ! -f "$composeyaml" ]; then
13 | log_err "No configuration file, please set config"
14 | exit 1
15 | fi
16 |
17 | if [ x"$1" = x"" ]; then
18 | log_info "Start spacex"
19 |
20 | if [ -f "$builddir/api/api_config.json" ]; then
21 | local chain_ws_url=`cat $builddir/api/api_config.json | jq .chain_ws_url`
22 | if [ x"$chain_ws_url" == x"\"ws://127.0.0.1:19944\"" ]; then
23 | start_chain
24 | if [ $? -ne 0 ]; then
25 | docker-compose -f $composeyaml down
26 | exit 1
27 | fi
28 | else
29 | log_info "API will connect to other chain: ${chain_ws_url}"
30 | fi
31 | else
32 | start_chain
33 | if [ $? -ne 0 ]; then
34 | docker-compose -f $composeyaml down
35 | exit 1
36 | fi
37 | fi
38 |
39 | start_storage
40 | if [ $? -ne 0 ]; then
41 | docker-compose -f $composeyaml down
42 | exit 1
43 | fi
44 |
45 | start_api
46 | if [ $? -ne 0 ]; then
47 | docker-compose -f $composeyaml down
48 | exit 1
49 | fi
50 |
51 | start_sdatamanager
52 | if [ $? -ne 0 ]; then
53 | docker-compose -f $composeyaml down
54 | exit 1
55 | fi
56 |
57 | start_ipfs
58 | if [ $? -ne 0 ]; then
59 | docker-compose -f $composeyaml down
60 | exit 1
61 | fi
62 |
63 | log_success "Start spacex success"
64 | return 0
65 | fi
66 |
67 | if [ x"$1" = x"chain" ]; then
68 | log_info "Start chain service"
69 | start_chain
70 | if [ $? -ne 0 ]; then
71 | exit 1
72 | fi
73 | log_success "Start chain service success"
74 | return 0
75 | fi
76 |
77 | if [ x"$1" = x"api" ]; then
78 | log_info "Start api service"
79 | start_api
80 | if [ $? -ne 0 ]; then
81 | exit 1
82 | fi
83 | log_success "Start api service success"
84 | return 0
85 | fi
86 |
87 | if [ x"$1" = x"storage" ]; then
88 | log_info "Start storage service"
89 | shift
90 | start_storage $@
91 | if [ $? -ne 0 ]; then
92 | exit 1
93 | fi
94 | log_success "Start storage service success"
95 | return 0
96 | fi
97 |
98 | if [ x"$1" = x"sdatamanager" ]; then
99 | log_info "Start sdatamanager service"
100 | start_sdatamanager
101 | if [ $? -ne 0 ]; then
102 | exit 1
103 | fi
104 | log_success "Start sdatamanager service success"
105 | return 0
106 | fi
107 |
108 | if [ x"$1" = x"ipfs" ]; then
109 | log_info "Start ipfs service"
110 | start_ipfs
111 | if [ $? -ne 0 ]; then
112 | exit 1
113 | fi
114 | log_success "Start ipfs service success"
115 | return 0
116 | fi
117 |
118 | help
119 | return 1
120 | }
121 |
122 | stop()
123 | {
124 | if [ x"$1" = x"" ]; then
125 | log_info "Stop spacex"
126 | stop_chain
127 | stop_sdatamanager
128 | stop_api
129 | stop_storage
130 | stop_ipfs
131 | log_success "Stop spacex success"
132 | return 0
133 | fi
134 |
135 | if [ x"$1" = x"chain" ]; then
136 | log_info "Stop chain service"
137 | stop_chain
138 | log_success "Stop chain service success"
139 | return 0
140 | fi
141 |
142 | if [ x"$1" = x"api" ]; then
143 | log_info "Stop api service"
144 | stop_api
145 | log_success "Stop api service success"
146 | return 0
147 | fi
148 |
149 | if [ x"$1" = x"storage" ]; then
150 | log_info "Stop storage service"
151 | stop_storage
152 | log_success "Stop storage service success"
153 | return 0
154 | fi
155 |
156 | if [ x"$1" = x"sdatamanager" ]; then
157 | log_info "Cannot stop the sdatamanager service alone, this will affect your benefits"
158 | return 0
159 | fi
160 |
161 | if [ x"$1" = x"ipfs" ]; then
162 | log_info "Stop ipfs service"
163 | stop_ipfs
164 | log_success "Stop ipfs service success"
165 | return 0
166 | fi
167 |
168 | help
169 | return 1
170 | }
171 |
172 | start_chain()
173 | {
174 | if [ ! -f "$composeyaml" ]; then
175 | log_err "No configuration file, please set config"
176 | return 1
177 | fi
178 |
179 | check_docker_status spacex
180 | if [ $? -eq 0 ]; then
181 | return 0
182 | fi
183 |
184 | local config_file=$builddir/chain/chain_config.json
185 | if [ x"$config_file" = x"" ]; then
186 | log_err "Please give right chain config file"
187 | return 1
188 | fi
189 |
190 | local chain_port=`cat $config_file | jq .port`
191 |
192 | if [ x"$chain_port" = x"" ] || [ x"$chain_port" = x"null" ]; then
193 | chain_port=30888
194 | fi
195 |
196 | if [ $chain_port -lt 0 ] || [ $chain_port -gt 65535 ]; then
197 | log_err "The range of chain port is 0 ~ 65535"
198 | return 1
199 | fi
200 |
201 | local res=0
202 | check_port $chain_port
203 | res=$(($?|$res))
204 | check_port 19933
205 | res=$(($?|$res))
206 | check_port 19944
207 | res=$(($?|$res))
208 | if [ $res -ne 0 ]; then
209 | return 1
210 | fi
211 |
212 | docker-compose -f $composeyaml up -d spacex
213 | if [ $? -ne 0 ]; then
214 | log_err "Start spacex-api failed"
215 | return 1
216 | fi
217 | return 0
218 | }
219 |
220 | stop_chain()
221 | {
222 | check_docker_status spacex
223 | if [ $? -ne 1 ]; then
224 | log_info "Stopping spacex chain service"
225 | docker stop spacex &>/dev/null
226 | docker rm spacex &>/dev/null
227 | fi
228 | return 0
229 | }
230 |
231 |
232 | ### start storage ###
233 | start_storage()
234 | {
235 | if [ ! -f "$composeyaml" ]; then
236 | log_err "No configuration file, please set config"
237 | return 1
238 | fi
239 |
240 | if [ -d "$builddir/storage" ]; then
241 | local a_or_b=`cat $basedir/etc/storage.ab`
242 | check_docker_status spacex-storage-$a_or_b
243 | if [ $? -eq 0 ]; then
244 | return 0
245 | fi
246 |
247 | check_port 12222
248 | if [ $? -ne 0 ]; then
249 | return 1
250 | fi
251 |
252 | if [ -f "$scriptdir/install_sgx.sh" ]; then
253 | $scriptdir/install_sgx.sh
254 | if [ $? -ne 0 ]; then
255 | log_err "Install sgx dirver failed"
256 | return 1
257 | fi
258 | fi
259 |
260 | if [ ! -e "/dev/isgx" ]; then
261 | log_err "Your device can't install sgx dirver, please check your CPU and BIOS to determine if they support SGX."
262 | return 1
263 | fi
264 | EX_STORAGE_ARGS=$@ docker-compose -f $composeyaml up -d spacex-storage-$a_or_b
265 | if [ $? -ne 0 ]; then
266 | log_err "Start spacex-storage-$a_or_b failed"
267 | return 1
268 | fi
269 | fi
270 | return 0
271 | }
272 |
273 | stop_storage()
274 | {
275 | check_docker_status spacex-storage-a
276 | if [ $? -ne 1 ]; then
277 | log_info "Stopping spacex storage A service"
278 | docker stop spacex-storage-a &>/dev/null
279 | docker rm spacex-storage-a &>/dev/null
280 | fi
281 |
282 | check_docker_status spacex-storage-b
283 | if [ $? -ne 1 ]; then
284 | log_info "Stopping spacex storage B service"
285 | docker stop spacex-storage-b &>/dev/null
286 | docker rm spacex-storage-b &>/dev/null
287 | fi
288 |
289 | return 0
290 | }
291 |
292 | start_api()
293 | {
294 | if [ ! -f "$composeyaml" ]; then
295 | log_err "No configuration file, please set config"
296 | return 1
297 | fi
298 |
299 | if [ -d "$builddir/storage" ]; then
300 | check_docker_status spacex-api
301 | if [ $? -eq 0 ]; then
302 | return 0
303 | fi
304 |
305 | check_port 56666
306 | if [ $? -ne 0 ]; then
307 | return 1
308 | fi
309 |
310 | docker-compose -f $composeyaml up -d spacex-api
311 | if [ $? -ne 0 ]; then
312 | log_err "Start spacex-api failed"
313 | return 1
314 | fi
315 | fi
316 | return 0
317 | }
318 |
319 | stop_api()
320 | {
321 | check_docker_status spacex-api
322 | if [ $? -ne 1 ]; then
323 | log_info "Stopping spacex API service"
324 | docker stop spacex-api &>/dev/null
325 | docker rm spacex-api &>/dev/null
326 | fi
327 | return 0
328 | }
329 |
330 | start_sdatamanager()
331 | {
332 | if [ ! -f "$composeyaml" ]; then
333 | log_err "No configuration file, please set config"
334 | return 1
335 | fi
336 |
337 | if [ -d "$builddir/sdatamanager" ]; then
338 | check_docker_status spacex-sdatamanager
339 | if [ $? -eq 0 ]; then
340 | return 0
341 | fi
342 |
343 | docker-compose -f $composeyaml up -d spacex-sdatamanager
344 | if [ $? -ne 0 ]; then
345 | log_err "Start spacex-sdatamanager failed"
346 | return 1
347 | fi
348 |
349 | local upgrade_pid=$(ps -ef | grep "/opt/mannheimworld/spacex-script/scripts/auto_sdatamanager.sh" | grep -v grep | awk '{print $2}')
350 | if [ x"$upgrade_pid" != x"" ]; then
351 | kill -9 $upgrade_pid
352 | fi
353 |
354 | if [ -f "$scriptdir/auto_sdatamanager.sh" ]; then
355 | nohup $scriptdir/auto_sdatamanager.sh &>$basedir/auto_sdatamanager.log &
356 | if [ $? -ne 0 ]; then
357 | log_err "Start spacex-sdatamanager upgrade failed"
358 | return 1
359 | fi
360 | fi
361 | fi
362 | return 0
363 | }
364 |
365 | stop_sdatamanager()
366 | {
367 | local upgrade_pid=$(ps -ef | grep "/opt/mannheimworld/spacex-script/scripts/auto_sdatamanager.sh" | grep -v grep | awk '{print $2}')
368 |
369 | if [ x"$upgrade_pid" != x"" ]; then
370 | kill -9 $upgrade_pid
371 | fi
372 |
373 | check_docker_status spacex-sdatamanager
374 | if [ $? -ne 1 ]; then
375 | log_info "Stopping spacex sdatamanager service"
376 | docker stop spacex-sdatamanager &>/dev/null
377 | docker rm spacex-sdatamanager &>/dev/null
378 | fi
379 | return 0
380 | }
381 |
382 | start_ipfs()
383 | {
384 | if [ ! -f "$composeyaml" ]; then
385 | log_err "No configuration file, please set config"
386 | return 1
387 | fi
388 |
389 | if [ -d "$builddir/ipfs" ]; then
390 | check_docker_status ipfs
391 | if [ $? -eq 0 ]; then
392 | return 0
393 | fi
394 |
395 | local res=0
396 | check_port 4001
397 | res=$(($?|$res))
398 | check_port 5001
399 | res=$(($?|$res))
400 | check_port 37773
401 | res=$(($?|$res))
402 | if [ $res -ne 0 ]; then
403 | return 1
404 | fi
405 |
406 | docker-compose -f $composeyaml up -d ipfs
407 | if [ $? -ne 0 ]; then
408 | log_err "Start ipfs failed"
409 | return 1
410 | fi
411 | fi
412 | return 0
413 | }
414 |
415 | stop_ipfs()
416 | {
417 | check_docker_status ipfs
418 | if [ $? -ne 1 ]; then
419 | log_info "Stopping ipfs service"
420 | docker stop ipfs &>/dev/null
421 | docker rm ipfs &>/dev/null
422 | fi
423 | return 0
424 | }
425 |
426 |
427 |
428 |
429 |
430 | reload() {
431 | if [ x"$1" = x"" ]; then
432 | log_info "Reload all service"
433 | stop
434 | start
435 | log_success "Reload all service success"
436 | return 0
437 | fi
438 |
439 | if [ x"$1" = x"chain" ]; then
440 | log_info "Reload chain service"
441 |
442 | stop_chain
443 | start_chain
444 |
445 | log_success "Reload chain service success"
446 | return 0
447 | fi
448 |
449 | if [ x"$1" = x"api" ]; then
450 | log_info "Reload api service"
451 |
452 | stop_api
453 | start_api
454 |
455 | log_success "Reload api service success"
456 | return 0
457 | fi
458 |
459 | if [ x"$1" = x"storage" ]; then
460 | log_info "Reload storage service"
461 |
462 | stop_storage
463 | shift
464 | start_storage $@
465 |
466 | log_success "Reload storage service success"
467 | return 0
468 | fi
469 |
470 | if [ x"$1" = x"sdatamanager" ]; then
471 | log_info "Reload sdatamanager service"
472 |
473 | stop_sdatamanager
474 | start_sdatamanager
475 |
476 | log_success "Reload sdatamanager service success"
477 | return 0
478 | fi
479 |
480 | if [ x"$1" = x"ipfs" ]; then
481 | log_info "Reload ipfs service"
482 |
483 | stop_ipfs
484 | start_ipfs
485 |
486 | log_success "Reload ipfs service success"
487 | return 0
488 | fi
489 |
490 | help
491 | return 1
492 | }
493 |
494 | ########################################logs################################################
495 |
496 | logs_help()
497 | {
498 | cat << EOF
499 | Usage: spacex logs [OPTIONS] {chain|api|storage|storage-a|storage-b|sdatamanager|ipfs}
500 |
501 | Fetch the logs of a service
502 |
503 | Options:
504 | --details Show extra details provided to logs
505 | -f, --follow Follow log output
506 | --since string Show logs since timestamp (e.g. 2012-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
507 | --tail string Number of lines to show from the end of the logs (default "all")
508 | -t, --timestamps Show timestamps
509 | --until string Show logs before a timestamp (e.g. 2012-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
510 | EOF
511 | }
512 |
513 | logs()
514 | {
515 | local name="${!#}"
516 | local array=( "$@" )
517 | local logs_help_flag=0
518 | unset "array[${#array[@]}-1]"
519 |
520 | if [ x"$name" == x"chain" ]; then
521 | check_docker_status spacex
522 | if [ $? -eq 1 ]; then
523 | log_info "Service spacex chain is not started now"
524 | return 0
525 | fi
526 | docker logs ${array[@]} -f spacex
527 | logs_help_flag=$?
528 | elif [ x"$name" == x"api" ]; then
529 | check_docker_status spacex-api
530 | if [ $? -eq 1 ]; then
531 | log_info "Service spacex API is not started now"
532 | return 0
533 | fi
534 | docker logs ${array[@]} -f spacex-api
535 | logs_help_flag=$?
536 | elif [ x"$name" == x"storage" ]; then
537 | local a_or_b=`cat $basedir/etc/storage.ab`
538 | check_docker_status spacex-storage-$a_or_b
539 | if [ $? -eq 1 ]; then
540 | log_info "Service spacex storage is not started now"
541 | return 0
542 | fi
543 | docker logs ${array[@]} -f spacex-storage-$a_or_b
544 | logs_help_flag=$?
545 | elif [ x"$name" == x"ipfs" ]; then
546 | check_docker_status ipfs
547 | if [ $? -eq 1 ]; then
548 | log_info "Service ipfs is not started now"
549 | return 0
550 | fi
551 | docker logs ${array[@]} -f ipfs
552 | logs_help_flag=$?
553 | elif [ x"$name" == x"sdatamanager" ]; then
554 | check_docker_status spacex-sdatamanager
555 | if [ $? -eq 1 ]; then
556 | log_info "Service spacex sdatamanager is not started now"
557 | return 0
558 | fi
559 | docker logs ${array[@]} -f spacex-sdatamanager
560 | logs_help_flag=$?
561 | elif [ x"$name" == x"storage-a" ]; then
562 | check_docker_status spacex-storage-a
563 | if [ $? -eq 1 ]; then
564 | log_info "Service spacex storage-a is not started now"
565 | return 0
566 | fi
567 | docker logs ${array[@]} -f spacex-storage-a
568 | logs_help_flag=$?
569 | elif [ x"$name" == x"storage-b" ]; then
570 | check_docker_status spacex-storage-b
571 | if [ $? -eq 1 ]; then
572 | log_info "Service spacex storage-b is not started now"
573 | return 0
574 | fi
575 | docker logs ${array[@]} -f spacex-storage-b
576 | logs_help_flag=$?
577 | elif [ x"$name" == x"sdatamanager-upshell" ]; then
578 | local upgrade_pid=$(ps -ef | grep "/opt/mannheimworld/spacex-script/scripts/auto_sdatamanager.sh" | grep -v grep | awk '{print $2}')
579 | if [ x"$upgrade_pid" == x"" ]; then
580 | log_info "Service spacex sdatamanager upgrade shell is not started now"
581 | return 0
582 | fi
583 | tail -f $basedir/auto_sdatamanager.log
584 | else
585 | logs_help
586 | return 1
587 | fi
588 |
589 | if [ $logs_help_flag -ne 0 ]; then
590 | logs_help
591 | return 1
592 | fi
593 | }
594 |
595 |
596 | #######################################status################################################
597 |
598 | status()
599 | {
600 | if [ x"$1" == x"chain" ]; then
601 | chain_status
602 | elif [ x"$1" == x"api" ]; then
603 | api_status
604 | elif [ x"$1" == x"storage" ]; then
605 | storage_status
606 | elif [ x"$1" == x"sdatamanager" ]; then
607 | sdatamanager_status
608 | elif [ x"$1" == x"ipfs" ]; then
609 | ipfs_status
610 | elif [ x"$1" == x"" ]; then
611 | all_status
612 | else
613 | help
614 | fi
615 | }
616 |
617 | all_status()
618 | {
619 | local chain_status="stop"
620 | local api_status="stop"
621 | local storage_status="stop"
622 | local sdatamanager_status="stop"
623 | local ipfs_status="stop"
624 |
625 | check_docker_status spacex
626 | local res=$?
627 | if [ $res -eq 0 ]; then
628 | chain_status="running"
629 | elif [ $res -eq 2 ]; then
630 | chain_status="exited"
631 | fi
632 |
633 | check_docker_status spacex-api
634 | res=$?
635 | if [ $res -eq 0 ]; then
636 | api_status="running"
637 | elif [ $res -eq 2 ]; then
638 | api_status="exited"
639 | fi
640 |
641 | local a_or_b=`cat $basedir/etc/storage.ab`
642 | check_docker_status spacex-storage-$a_or_b
643 | res=$?
644 | if [ $res -eq 0 ]; then
645 | storage_status="running"
646 | elif [ $res -eq 2 ]; then
647 | storage_status="exited"
648 | fi
649 |
650 | check_docker_status spacex-sdatamanager
651 | res=$?
652 | if [ $res -eq 0 ]; then
653 | sdatamanager_status="running"
654 | elif [ $res -eq 2 ]; then
655 | sdatamanager_status="exited"
656 | fi
657 |
658 | check_docker_status ipfs
659 | res=$?
660 | if [ $res -eq 0 ]; then
661 | ipfs_status="running"
662 | elif [ $res -eq 2 ]; then
663 | ipfs_status="exited"
664 | fi
665 |
666 | cat << EOF
667 | -----------------------------------------
668 | Service Status
669 | -----------------------------------------
670 | chain ${chain_status}
671 | api ${api_status}
672 | storage ${storage_status}
673 | sdatamanager ${sdatamanager_status}
674 | ipfs ${ipfs_status}
675 | -----------------------------------------
676 | EOF
677 | }
678 |
679 | chain_status()
680 | {
681 | local chain_status="stop"
682 |
683 | check_docker_status spacex
684 | local res=$?
685 | if [ $res -eq 0 ]; then
686 | chain_status="running"
687 | elif [ $res -eq 2 ]; then
688 | chain_status="exited"
689 | fi
690 |
691 | cat << EOF
692 | -----------------------------------------
693 | Service Status
694 | -----------------------------------------
695 | chain ${chain_status}
696 | -----------------------------------------
697 | EOF
698 | }
699 |
700 | api_status()
701 | {
702 | local api_status="stop"
703 |
704 | check_docker_status spacex-api
705 | res=$?
706 | if [ $res -eq 0 ]; then
707 | api_status="running"
708 | elif [ $res -eq 2 ]; then
709 | api_status="exited"
710 | fi
711 |
712 | cat << EOF
713 | -----------------------------------------
714 | Service Status
715 | -----------------------------------------
716 | api ${api_status}
717 | -----------------------------------------
718 | EOF
719 | }
720 |
721 | storage_status()
722 | {
723 | local storage_a_status="stop"
724 | local storage_b_status="stop"
725 | local a_or_b=`cat $basedir/etc/storage.ab`
726 |
727 | check_docker_status spacex-storage-a
728 | local res=$?
729 | if [ $res -eq 0 ]; then
730 | storage_a_status="running"
731 | elif [ $res -eq 2 ]; then
732 | storage_a_status="exited"
733 | fi
734 |
735 | check_docker_status spacex-storage-b
736 | res=$?
737 | if [ $res -eq 0 ]; then
738 | storage_b_status="running"
739 | elif [ $res -eq 2 ]; then
740 | storage_b_status="exited"
741 | fi
742 |
743 | cat << EOF
744 | -----------------------------------------
745 | Service Status
746 | -----------------------------------------
747 | storage-a ${storage_a_status}
748 | storage-b ${storage_b_status}
749 | main-progress ${a_or_b}
750 | -----------------------------------------
751 | EOF
752 | }
753 |
754 | sdatamanager_status()
755 | {
756 | local sdatamanager_status="stop"
757 | local upgrade_shell_status="stop"
758 |
759 | check_docker_status spacex-sdatamanager
760 | res=$?
761 | if [ $res -eq 0 ]; then
762 | sdatamanager_status="running"
763 | elif [ $res -eq 2 ]; then
764 | sdatamanager_status="exited"
765 | fi
766 |
767 | local upgrade_pid=$(ps -ef | grep "/opt/mannheimworld/spacex-script/scripts/auto_sdatamanager.sh" | grep -v grep | awk '{print $2}')
768 | if [ x"$upgrade_pid" != x"" ]; then
769 | upgrade_shell_status="running->${upgrade_pid}"
770 | fi
771 |
772 |
773 | cat << EOF
774 | -----------------------------------------
775 | Service Status
776 | -----------------------------------------
777 | sdatamanager ${sdatamanager_status}
778 | upgrade-shell ${upgrade_shell_status}
779 | -----------------------------------------
780 | EOF
781 | }
782 |
783 | ipfs_status()
784 | {
785 | local ipfs_status="stop"
786 |
787 | check_docker_status ipfs
788 | res=$?
789 | if [ $res -eq 0 ]; then
790 | ipfs_status="running"
791 | elif [ $res -eq 2 ]; then
792 | ipfs_status="exited"
793 | fi
794 |
795 | cat << EOF
796 | -----------------------------------------
797 | Service Status
798 | -----------------------------------------
799 | ipfs ${ipfs_status}
800 | -----------------------------------------
801 | EOF
802 | }
803 |
804 | ######################################main entrance############################################
805 |
806 | help()
807 | {
808 | cat << EOF
809 | Usage:
810 | help show help information
811 | version show version
812 |
813 | start {chain|api|storage|sdatamanager|ipfs} start all spacex service
814 | stop {chain|api|storage|sdatamanager|ipfs} stop all spacex service or stop one service
815 |
816 | status {chain|api|storage|sdatamanager|ipfs} check status or reload one service status
817 | reload {chain|api|storage|sdatamanager|ipfs} reload all service or reload one service
818 | logs {chain|api|storage|storage-a|storage-b|sdatamanager|ipfs} track service logs, ctrl-c to exit. use 'spacex logs help' for more details
819 |
820 | tools {...} use 'spacex tools help' for more details
821 | config {...} configuration operations, use 'spacex config help' for more details
822 | EOF
823 | }
824 |
825 | case "$1" in
826 | version)
827 | version
828 | ;;
829 | start)
830 | shift
831 | start $@
832 | ;;
833 | stop)
834 | stop $2
835 | ;;
836 | reload)
837 | shift
838 | reload $@
839 | ;;
840 | status)
841 | status $2
842 | ;;
843 | logs)
844 | shift
845 | logs $@
846 | ;;
847 | config)
848 | shift
849 | config $@
850 | ;;
851 | tools)
852 | shift
853 | tools $@
854 | ;;
855 | *)
856 | help
857 | esac
858 | exit 0
859 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------