|
41 | 41 | PROFILE="/etc/profile" |
42 | 42 | fi |
43 | 43 | if [ -z "$network" ]; then |
44 | | - echo "🛜 No network selected. Defaulting to goldberg." |
| 44 | + echo "🛜 No network selected. Defaulting to goldberg testnet." |
45 | 45 | NETWORK="goldberg" |
46 | 46 | else |
47 | 47 | NETWORK="$network" |
48 | 48 | fi |
49 | 49 | if [ "$NETWORK" = "goldberg" ]; then |
50 | | - echo "📌 Goldberg network selected." |
| 50 | + echo "📌 Goldberg testnet selected." |
51 | 51 | VERSION="v1.7.9" |
52 | 52 | elif [ "$NETWORK" = "local" ]; then |
53 | | - echo "📌 Local network selected." |
| 53 | + echo "📌 Local testnet selected." |
54 | 54 | VERSION="v1.7.9" |
55 | 55 | else |
56 | | - echo "🚫 Invalid network selected. Please select one of the following: goldberg, kate, local." |
| 56 | + echo "🚫 Invalid network selected. Select one of the following: goldberg, local." |
57 | 57 | exit 1 |
58 | 58 | fi |
59 | 59 | if [ -z "$app_id" ]; then |
60 | | - echo "📲 No app ID specified. Defaulting to 0." |
| 60 | + echo "📲 No app ID specified. Defaulting to light client mode." |
61 | 61 | APPID="0" |
62 | 62 | else |
63 | 63 | APPID="$app_id" |
64 | 64 | fi |
65 | 65 | if [ -z "$identity" ]; then |
66 | 66 | IDENTITY=$HOME/.avail/identity/identity.toml |
67 | | - if [ -f "$HOME/.avail/identity/identity.toml" ]; then |
| 67 | + if [ -f "$IDENTITY" ]; then |
68 | 68 | echo "🔑 Identity found at $IDENTITY." |
69 | 69 | else |
70 | 70 | echo "🤷 No identity set. This will be automatically generated at startup." |
71 | 71 | fi |
72 | | -else |
| 72 | +else |
73 | 73 | IDENTITY="$identity" |
74 | 74 | fi |
75 | 75 | if [ ! -d "$HOME/.avail" ]; then |
|
85 | 85 | UPGRADE=0 |
86 | 86 | if [ ! -z "$upgrade" ]; then |
87 | 87 | echo "🔄 Checking for updates..." |
88 | | - if command -v avail-light >/dev/null 2>&1; then |
89 | | - CURRENT_VERSION="v$(avail-light --version | cut -d " " -f 2)" |
| 88 | + if [ -f $HOME/.avail/bin/avail-light ]; then |
| 89 | + CURRENT_VERSION="v$($HOME/.avail/bin/avail-light --version | cut -d " " -f 2)" |
90 | 90 | if [ "$CURRENT_VERSION" = "v1.7.8" ] && [ "$VERSION" = "v1.7.9" ]; then |
91 | 91 | UPGRADE=0 |
92 | 92 | echo "✨ Avail binary is up to date. Skipping upgrade." |
93 | 93 | elif [ "$CURRENT_VERSION" != "$VERSION" ]; then |
94 | 94 | UPGRADE=1 |
95 | 95 | echo "✨ Avail binary is up to date. Skipping upgrade." |
96 | 96 | else |
97 | | - if [ "$upgrade" = "y" ] || [ "$upgrade" = "yes" ]; then |
| 97 | + if [ "$upgrade" = "y" -o "$upgrade" = "yes" ]; then |
98 | 98 | UPGRADE=1 |
99 | 99 | fi |
100 | 100 | fi |
101 | 101 | fi |
102 | 102 | fi |
103 | 103 |
|
104 | 104 | onexit() { |
| 105 | + chmod 600 $IDENTITY |
105 | 106 | echo "🔄 Avail stopped. Future instances of the light client can be started by invoking the avail-light binary or rerunning this script$EXTRAPROMPT" |
106 | 107 | if [[ ":$PATH:" != *":$HOME/.avail/bin:"* ]]; then |
107 | 108 | if ! grep -q "export PATH=\"\$PATH:$HOME/.avail/bin\"" "$PROFILE"; then |
108 | 109 | echo -e "export PATH=\"\$PATH:$HOME/.avail/bin\"\n" >> $PROFILE |
109 | 110 | fi |
110 | | - echo -e "📌 Avail has been added to your profile. Run the following command to load it in the current terminal session:\n. $PROFILE\n" |
| 111 | + echo -e "📌 Avail has been added to your profile. Run the following command to load it in the current session:\n. $PROFILE\n" |
111 | 112 | fi |
112 | 113 | exit 0 |
113 | 114 | } |
114 | 115 | # check if avail-light binary is available and check if upgrade variable is set to 0 |
115 | | -if command -v avail-light >/dev/null 2>&1 && [ "$UPGRADE" = 0 ]; then |
| 116 | +if [ -f $HOME/.avail/bin/avail-light -a "$UPGRADE" = 0 ]; then |
116 | 117 | echo "✅ Avail is already installed. Starting Avail..." |
117 | 118 | trap onexit EXIT |
118 | | - if [ -z "$config" ] && [ ! -z "$identity" ]; then |
| 119 | + if [ -z "$config" ]; then |
119 | 120 | $HOME/.avail/bin/avail-light --network $NETWORK --app-id $APPID --identity $IDENTITY |
120 | | - elif [ -z "$config" ]; then |
121 | | - $HOME/.avail/bin/avail-light --network $NETWORK --app-id $APPID |
122 | | - elif [ ! -z "$config" ] && [ ! -z "$identity" ]; then |
123 | | - $HOME/.avail/bin/avail-light --config $CONFIG --app-id $APPID --identity $IDENTITY |
124 | 121 | else |
125 | | - $HOME/.avail/bin/avail-light --config $CONFIG --app-id $APPID |
| 122 | + $HOME/.avail/bin/avail-light --config $CONFIG --app-id $APPID --identity $IDENTITY |
126 | 123 | fi |
127 | 124 | exit 0 |
128 | 125 | fi |
|
174 | 171 | echo "🚫 Neither curl nor wget are available. Please install one of these and try again." |
175 | 172 | exit 1 |
176 | 173 | fi |
177 | | - # use tar to extract the downloaded file and move it to /usr/local/bin |
| 174 | + # use tar to extract the downloaded file and move it to .avail/bin/ directory |
178 | 175 | tar -xzf avail-light-$ARCH_STRING.tar.gz |
179 | 176 | chmod +x avail-light-$ARCH_STRING |
180 | 177 | mv avail-light-$ARCH_STRING $HOME/.avail/bin/avail-light |
|
183 | 180 | echo "✅ Availup exited successfully." |
184 | 181 | echo "🧱 Starting Avail." |
185 | 182 | trap onexit EXIT |
186 | | -if [ -z "$config" ] && [ ! -z "$identity" ]; then |
| 183 | +if [ -z "$config" ]; then |
187 | 184 | $HOME/.avail/bin/avail-light --network $NETWORK --app-id $APPID --identity $IDENTITY |
188 | | -elif [ -z "$config" ]; then |
189 | | - $HOME/.avail/bin/avail-light --network $NETWORK --app-id $APPID |
190 | | -elif [ ! -z "$config" ] && [ ! -z "$identity" ]; then |
191 | | - $HOME/.avail/bin/avail-light --config $CONFIG --app-id $APPID --identity $IDENTITY |
192 | 185 | else |
193 | | - $HOME/.avail/bin/avail-light --config $CONFIG --app-id $APPID |
| 186 | + $HOME/.avail/bin/avail-light --config $CONFIG --app-id $APPID --identity $IDENTITY |
194 | 187 | fi |
0 commit comments