@@ -11,28 +11,33 @@ LOG_DIR="/var/log"
1111
1212# Function to generate a random 25-character password
1313generate_password () {
14- mkdir -p $( dirname " $PASSWORD_FILE " )
15- cat /dev/urandom | tr -dc ' A-Za-z0-9' | head -c 25 > " $PASSWORD_FILE "
14+ echo " generating password"
15+ sudo mkdir -p $( dirname " $PASSWORD_FILE " )
16+ sudo cat /dev/urandom | tr -dc ' A-Za-z0-9' | head -c 25 > " $PASSWORD_FILE "
1617}
1718
1819# Function to install Go 1.21 from source
1920install_go () {
21+ echo " Installing go"
2022 # Check if Go is already installed
2123 if ! command -v go & > /dev/null && [ ! -d " /usr/local/go" ]; then
2224 echo " Go is not installed. Installing Go..."
2325
2426 # Download the pre-compiled binary of Go 1.21
25- wget https://golang.org/dl/go1.21.0.linux-amd64.tar.gz
27+ sudo wget https://golang.org/dl/go1.21.0.linux-amd64.tar.gz
2628 sudo tar -xvf go1.21.0.linux-amd64.tar.gz
2729 sudo mv go /usr/local
2830
29- # Set environment variables so the system knows where to find Go
30- echo " export GOROOT=/usr/local/go" | sudo tee /etc/profile.d/goenv.sh
31- echo " export PATH=\$ PATH:\$ GOROOT/bin" | sudo tee -a /etc/profile.d/goenv.sh
31+ # ## Set environment variables so the system knows where to find Go
32+ # echo "export GOROOT=/usr/local/go" | sudo tee /etc/profile.d/goenv.sh
33+ # echo "export PATH=\$PATH:\$GOROOT/bin" | sudo tee -a /etc/profile.d/goenv.sh
3234
33- source /etc/profile.d/goenv.sh
35+ # source /etc/profile.d/goenv.sh
3436
35- sudo ln -s /usr/local/go/bin/go /usr/local/bin/go
37+ # sudo ln -s /usr/local/go/bin/go /usr/local/bin/go
38+ echo " export GOROOT=/usr/local/go" >> ~ /.profile
39+ echo " export PATH=\$ PATH:\$ GOROOT/bin" >> ~ /.profile
40+ source ~ /.profile
3641 else
3742 echo " Go is already installed. Skipping installation."
3843 fi
@@ -42,26 +47,36 @@ install_go() {
4247
4348# Function to install Rust and Cargo
4449install_rust () {
45- curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
50+ echo " Installing rust"
51+ curl https://sh.rustup.rs -sSf | sh -s -- -y
4652 source " $HOME /.cargo/env"
53+
54+ rustup default stable
55+ rustup update nightly
56+ rustup update stable
57+ rustup target add wasm32-unknown-unknown --toolchain nightly
58+ rustup target add wasm32-unknown-unknown
4759}
4860
4961# Function to clone and build repositories
5062clone_and_build () {
63+ echo " Installing sugarfunge-api"
5164 if [ ! -d " sugarfunge-api" ] || [ -z " $( ls -A sugarfunge-api) " ]; then
5265 git clone https://github.com/functionland/sugarfunge-api.git
5366 fi
5467 cd sugarfunge-api
5568 cargo build --release
5669 cd ..
57-
70+
71+ echo " Installing sugarfunge-node"
5872 if [ ! -d " sugarfunge-node" ] || [ -z " $( ls -A sugarfunge-node) " ]; then
5973 git clone https://github.com/functionland/sugarfunge-node.git
6074 fi
6175 cd sugarfunge-node
6276 cargo build --release
6377 cd ..
6478
79+ echo " Installing go-fula"
6580 if [ ! -d " go-fula" ] || [ -z " $( ls -A go-fula) " ]; then
6681 git clone https://github.com/functionland/go-fula.git
6782 fi
@@ -73,6 +88,7 @@ clone_and_build() {
7388
7489# Function to set up and extract keys
7590setup_and_extract_keys () {
91+ echo " setup_and_extract_keys"
7692 mkdir -p " $SECRET_DIR "
7793 if [ ! -f " $SECRET_DIR /secret_phrase.txt" ] || [ ! -f " $SECRET_DIR /secret_seed.txt" ]; then
7894 output=$( ./sugarfunge-node/target/release/sugarfunge-node key generate --scheme Sr25519 --password-filename=" $PASSWORD_FILE " 2>&1 )
@@ -99,13 +115,15 @@ setup_and_extract_keys() {
99115
100116# Function to insert keys into the node
101117insert_keys () {
118+ echo " insert_keys"
102119 secret_phrase=$( cat " $SECRET_DIR /secret_phrase.txt" )
103- ./sugarfunge-node/target/release/sugarfunge-node key insert --base-path=" $DATA_DIR " --chain . /customSpecRaw.json --scheme Sr25519 --suri " $secret_phrase " --password-filename " $PASSWORD_FILE " --key-type aura
104- ./sugarfunge-node/target/release/sugarfunge-node key insert --base-path=" $DATA_DIR " --chain . /customSpecRaw.json --scheme Ed25519 --suri " $secret_phrase " --password-filename " $PASSWORD_FILE " --key-type gran
120+ ./sugarfunge-node/target/release/sugarfunge-node key insert --base-path=" $DATA_DIR " --chain $HOME /sugarfunge-node /customSpecRaw.json --scheme Sr25519 --suri " $secret_phrase " --password-filename " $PASSWORD_FILE " --key-type aura
121+ ./sugarfunge-node/target/release/sugarfunge-node key insert --base-path=" $DATA_DIR " --chain $HOME /sugarfunge-node /customSpecRaw.json --scheme Ed25519 --suri " $secret_phrase " --password-filename " $PASSWORD_FILE " --key-type gran
105122}
106123
107124# Function to set up and start node service
108125setup_node_service () {
126+ echo " setup_node_service"
109127 sudo bash -c ' cat > /etc/systemd/system/sugarfunge-node.service' << EOF
110128[Unit]
111129Description=Sugarfunge Node
144162
145163# Function to set up and start API service
146164setup_api_service () {
165+ echo " setup_api_service"
147166 sudo bash -c ' cat > /etc/systemd/system/sugarfunge-api.service' << EOF
148167[Unit]
149168Description=Sugarfunge API
182201
183202# Function to set up and start go-fula service
184203setup_gofula_service () {
204+ echo " setup_gofula_service"
185205 sudo bash -c ' cat > /etc/systemd/system/go-fula.service' << EOF
186206[Unit]
187207Description=Go Fula Service
203223
204224# Function to fund an account
205225fund_account () {
226+ echo " fund_account"
206227 secret_seed=$( cat " $SECRET_DIR /secret_seed.txt" )
207228 account=$( cat " $SECRET_DIR /account.txt" )
208229 curl -X POST https://api.node3.functionyard.fula.network/account/fund \
@@ -212,6 +233,7 @@ fund_account() {
212233
213234# Function to create a pool
214235create_pool () {
236+ echo " create_pool"
215237 seed=$( cat " $SECRET_DIR /secret_seed.txt" )
216238 node_peerid=$( cat " $SECRET_DIR /node_peerid.txt" )
217239 pool_name=$1
@@ -230,6 +252,7 @@ create_pool() {
230252
231253# Function to setup the Fula config file
232254setup_fula_config () {
255+ echo " setup_fula_config"
233256 pool_id=" $1 "
234257 mkdir -p /home/$USER /.fula/blox/store
235258 cat > /home/$USER /.fula/config.yaml << EOF
@@ -270,14 +293,17 @@ cleanup() {
270293 # Remove Go tarball
271294 if [ -f " go1.21.0.linux-amd64.tar.gz" ]; then
272295 echo " Removing Go tarball..."
273- rm go1.21.0.linux-amd64.tar.gz
296+ sudo rm go1.21.0.linux-amd64.tar.gz
274297 fi
275298
276299 # Add other cleanup tasks here
277300}
278301
279302# Main script execution
280303main () {
304+ # Set DEBIAN_FRONTEND to noninteractive to avoid interactive prompts
305+ export DEBIAN_FRONTEND=noninteractive
306+
281307 # Check if a region is provided
282308 if [ $# -lt 1 ]; then
283309 echo " Please provide a region as an argument."
@@ -289,7 +315,12 @@ main() {
289315
290316 # Update and install dependencies
291317 sudo apt update
292- sudo apt install -y wget git curl build-essential jq pkg-config libssl-dev
318+ sudo apt install -y wget git curl build-essential jq pkg-config libssl-dev protobuf-compiler llvm libclang-dev clang plocate cmake
319+
320+ # Set LIBCLANG_PATH for the user
321+ # echo "export LIBCLANG_PATH=/usr/lib/llvm-14/lib/" | sudo tee /etc/profile.d/libclang.sh
322+ echo " export LIBCLANG_PATH=/usr/lib/llvm-14/lib/" >> ~ /.profile
323+ source ~ /.profile
293324
294325 # Install Go 1.21 from source
295326 install_go
0 commit comments