|
| 1 | +#!/usr/bin/env sh |
| 2 | +[ $SUDO_USER ] && _user=$SUDO_USER || _user=`whoami` |
| 3 | +_upgrade="No" |
| 4 | +_nodetype="masternode" |
| 5 | + |
| 6 | +for opt in "$@" |
| 7 | +do |
| 8 | + if [ $opt = "-servicenode" ] ; then |
| 9 | + _nodetype="servicenode" |
| 10 | + elif [ $opt = "-masternode" ] ; then |
| 11 | + _nodetype="masternode" |
| 12 | + elif [ $opt = "-gatewaynode" ] ; then |
| 13 | + _nodetype="gatewaynode" |
| 14 | + elif [ $opt = "-upgrade" ] ; then |
| 15 | + _upgrade="Yes" |
| 16 | + else |
| 17 | + echo "Invalid option: $opt" |
| 18 | + fi |
| 19 | +done |
| 20 | + |
| 21 | +if [ $_nodetype = "gatewaynode" ] ; then |
| 22 | + echo "ethoFS Gateway Node Setup Initiated" |
| 23 | +fi |
| 24 | +if [ $_nodetype = "masternode" ] ; then |
| 25 | + echo "Ether-1 Masternode Setup Initiated" |
| 26 | +fi |
| 27 | +if [ $_nodetype = "servicenode" ] ; then |
| 28 | + echo "Ether-1 Service Node Setup Initiated" |
| 29 | +fi |
| 30 | +if [ $_upgrade = "Yes" ] ; then |
| 31 | + echo "Upgrade Option Selected" |
| 32 | +fi |
| 33 | + |
| 34 | +echo '**************************' |
| 35 | +echo 'Installing misc dependencies' |
| 36 | +echo '**************************' |
| 37 | +# install dependencies |
| 38 | +sudo apt-get update && sudo apt-get install systemd unzip wget build-essential -y |
| 39 | + |
| 40 | +echo '**************************' |
| 41 | +echo 'Installing Ether-1 Node binary' |
| 42 | +echo '**************************' |
| 43 | +# Download node binary |
| 44 | + |
| 45 | +wget https://files.ether1.org/releases/Ether1-MN-SN-0.0.9.1.tar.gz |
| 46 | + |
| 47 | +tar -xzf Ether1-MN-SN-0.0.9.1.tar.gz |
| 48 | + |
| 49 | +# Make node executable |
| 50 | +chmod +x geth |
| 51 | + |
| 52 | +# Remove and cleanup |
| 53 | +rm Ether1-MN-SN-0.0.9.1.tar.gz |
| 54 | + |
| 55 | +echo '**************************' |
| 56 | +echo 'Creating and setting up Masternode/Service Node system service' |
| 57 | +echo '**************************' |
| 58 | + |
| 59 | +cat > /tmp/ether1node.service << EOL |
| 60 | +[Unit] |
| 61 | +Description=Ether1 Masternode/Service Node |
| 62 | +After=network.target |
| 63 | +
|
| 64 | +[Service] |
| 65 | +
|
| 66 | +User=$_user |
| 67 | +Group=$_user |
| 68 | +
|
| 69 | +Type=simple |
| 70 | +Restart=always |
| 71 | +
|
| 72 | +ExecStart=/usr/sbin/geth --syncmode=fast --cache=512 --datadir=$HOME/.ether1 |
| 73 | +
|
| 74 | +[Install] |
| 75 | +WantedBy=default.target |
| 76 | +EOL |
| 77 | + sudo systemctl stop ether1node |
| 78 | + sudo \mv /tmp/ether1node.service /etc/systemd/system |
| 79 | + sudo \mv geth /usr/sbin/ |
| 80 | + sudo systemctl daemon-reload |
| 81 | + sudo systemctl enable ether1node && systemctl start ether1node |
| 82 | + sudo systemctl restart ether1node |
| 83 | + sudo systemctl status ether1node --no-pager --full |
| 84 | + |
| 85 | +echo '**************************' |
| 86 | +echo 'Masternode Setup Complete....Deploying IPFS' |
| 87 | +echo '**************************' |
| 88 | + |
| 89 | +cd $HOME |
| 90 | +wget https://files.ether1.org/releases/ipfs.tar.gz |
| 91 | +tar -xzf ipfs.tar.gz |
| 92 | +chmod +x ipfs |
| 93 | + |
| 94 | +# Remove and cleanup |
| 95 | +rm ipfs.tar.gz |
| 96 | + |
| 97 | +echo '**************************' |
| 98 | +echo 'Creating and setting up IPFS system service' |
| 99 | +echo '**************************' |
| 100 | + |
| 101 | +cat > /tmp/ipfs.service << EOL |
| 102 | +[Unit] |
| 103 | +Description=IPFS Node System Service |
| 104 | +After=network.target |
| 105 | +
|
| 106 | +[Service] |
| 107 | +User=$_user |
| 108 | +Group=$_user |
| 109 | +
|
| 110 | +Type=simple |
| 111 | +Restart=always |
| 112 | +
|
| 113 | +ExecStart=/usr/sbin/ipfs daemon --migrate --enable-namesys-pubsub --enable-gc |
| 114 | +
|
| 115 | +[Install] |
| 116 | +WantedBy=default.target |
| 117 | +EOL |
| 118 | + sudo systemctl stop ipfs |
| 119 | + sudo \mv /tmp/ipfs.service /etc/systemd/system |
| 120 | + sudo \mv ipfs /usr/sbin/ |
| 121 | + if [ $_upgrade = "No" ] ; then |
| 122 | + sudo rm -r $HOME/.ipfs |
| 123 | + ipfs init |
| 124 | + fi |
| 125 | + ipfs bootstrap rm --all |
| 126 | + if [ $_nodetype = "gatewaynode" ] ; then |
| 127 | + _maxstorage="78GB" |
| 128 | + sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/ipfs |
| 129 | + ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/80 |
| 130 | + fi |
| 131 | + if [ $_nodetype = "masternode" ] ; then |
| 132 | + _maxstorage="38GB" |
| 133 | + fi |
| 134 | + if [ $_nodetype = "servicenode" ] ; then |
| 135 | + _maxstorage="18GB" |
| 136 | + fi |
| 137 | + ipfs config Datastore.StorageMax $_maxstorage |
| 138 | + ipfs config --json Swarm.ConnMgr.LowWater 400 |
| 139 | + ipfs config --json Swarm.ConnMgr.HighWater 600 |
| 140 | + ipfs bootstrap add /ip4/207.148.27.84/tcp/4001/ipfs/QmTFUcUuMSN7KLytjtqnHCjixqd4ig3PrSbdQ2mW9Q8qeY |
| 141 | + ipfs bootstrap add /ip4/66.42.109.75/tcp/4001/ipfs/QmV856mLWnTDaj5LQvS3dCa3qjz4DNC9cKQJNSrwtqcHzT |
| 142 | + ipfs bootstrap add /ip4/95.179.136.216/tcp/4001/ipfs/QmdFCa2ix51sV8FADGKDadKPGB55kdEQMZm9VKVSRTbVhC |
| 143 | + ipfs bootstrap add /ip4/45.63.116.102/tcp/4001/ipfs/QmSfEKCzPWA6MmG2ZLK4Vqnq6oB6rvrLyUpHdNqng5nQ4t |
| 144 | + ipfs bootstrap add /ip4/149.28.167.176/tcp/4001/ipfs/QmRwQ49Zknc2dQbywrhT8ArMDS9JdmnEyGGy4mZ1wDkgaX |
| 145 | + ipfs bootstrap add /ip4/140.82.54.221/tcp/4001/ipfs/QmeG81bELkgLBZFYZc53ioxtvRS8iNVzPqxUBKSuah2rcQ |
| 146 | + ipfs bootstrap add /ip4/45.77.170.137/tcp/4001/ipfs/QmTZsBNb7dfJJmwuAdXBjKZ7ZH6XbpestZdURWGJVyAmj2 |
| 147 | + sudo chown -R $_user:$_user $HOME/.ipfs |
| 148 | +cat > /tmp/swarm.key << EOL |
| 149 | +/key/swarm/psk/1.0.0/ |
| 150 | +/base16/ |
| 151 | +38307a74b2176d0054ffa2864e31ee22d0fc6c3266dd856f6d41bddf14e2ad63 |
| 152 | +EOL |
| 153 | + sudo \mv /tmp/swarm.key $HOME/.ipfs |
| 154 | + sudo systemctl daemon-reload |
| 155 | + sudo systemctl enable ipfs && systemctl start ipfs |
| 156 | + sudo systemctl restart ipfs |
| 157 | + sudo systemctl status ipfs --no-pager --full |
| 158 | +echo '**************************' |
| 159 | +echo 'IPFS Setup Complete....Deploying ethoFS' |
| 160 | +echo '**************************' |
| 161 | +cd $HOME |
| 162 | +wget https://files.ether1.org/releases/ethoFS.tar.gz |
| 163 | +tar -xzf ethoFS.tar.gz |
| 164 | +chmod +x ethoFS |
| 165 | + |
| 166 | +# Remove and cleanup |
| 167 | +rm ethoFS.tar.gz |
| 168 | + |
| 169 | +echo '**************************' |
| 170 | +echo 'Creating and setting up ethoFS system service' |
| 171 | +echo '**************************' |
| 172 | + |
| 173 | +cat > /tmp/ethoFS.service << EOL |
| 174 | +[Unit] |
| 175 | +Description=ethoFS Node System Service |
| 176 | +After=network.target |
| 177 | +
|
| 178 | +[Service] |
| 179 | +User=$_user |
| 180 | +Group=$_user |
| 181 | +
|
| 182 | +Type=simple |
| 183 | +Restart=always |
| 184 | +
|
| 185 | +ExecStart=/usr/sbin/ethoFS -$_nodetype |
| 186 | +
|
| 187 | +[Install] |
| 188 | +WantedBy=default.target |
| 189 | +EOL |
| 190 | + sudo systemctl stop ethoFS |
| 191 | + sudo \mv /tmp/ethoFS.service /etc/systemd/system |
| 192 | + sudo \mv ethoFS /usr/sbin/ |
| 193 | + sudo systemctl daemon-reload |
| 194 | + sudo systemctl enable ethoFS && systemctl start ethoFS |
| 195 | + sudo systemctl restart ethoFS |
| 196 | + sudo systemctl status ethoFS --no-pager --full |
| 197 | +echo '**************************' |
| 198 | +echo 'ethoFS Setup Complete' |
| 199 | +echo '**************************' |
0 commit comments