Skip to content

Commit f987c0f

Browse files
committed
Change install commands to use local assets instead of downloading from github
1 parent a3d2d91 commit f987c0f

6 files changed

Lines changed: 150 additions & 201 deletions

File tree

rocketpool-cli/service/commands.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package service
22

33
import (
44
"fmt"
5+
"os"
56
"strings"
67

78
"github.com/urfave/cli"
@@ -131,7 +132,6 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
131132
cli.StringFlag{
132133
Name: "version, v",
133134
Usage: "The smart node package version to install",
134-
Value: fmt.Sprintf("v%s", shared.RocketPoolVersion),
135135
},
136136
},
137137
Action: func(c *cli.Context) error {
@@ -141,6 +141,11 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
141141
return err
142142
}
143143

144+
if c.String("version") != "" {
145+
fmt.Fprintf(os.Stderr, "--version/-v is no longer supported. Instead, download the correct version of the `rocketpool` binary and install that. Current version: %s\n", shared.RocketPoolVersion)
146+
os.Exit(1)
147+
}
148+
144149
// Run command
145150
return installService(c)
146151

@@ -417,8 +422,7 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
417422
},
418423
cli.StringFlag{
419424
Name: "version, v",
420-
Usage: "The update tracker package version to install",
421-
Value: fmt.Sprintf("v%s", shared.RocketPoolVersion),
425+
Usage: "DEPRECATED: The update tracker package version to install",
422426
},
423427
},
424428
Action: func(c *cli.Context) error {
@@ -428,6 +432,11 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
428432
return err
429433
}
430434

435+
if c.String("version") != "" {
436+
fmt.Fprintf(os.Stderr, "--version/-v is no longer supported. Instead, download the correct version of the `rocketpool` binary and install the update tracker from there. Current version: %s\n", shared.RocketPoolVersion)
437+
os.Exit(1)
438+
}
439+
431440
// Run command
432441
return installUpdateTracker(c)
433442

rocketpool-cli/service/service.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func installService(c *cli.Context) error {
5858

5959
// Prompt for confirmation
6060
if !(c.Bool("yes") || prompt.Confirm(fmt.Sprintf(
61-
"The Rocket Pool service will be installed --Version: %s\n\n%sIf you're upgrading, your existing configuration will be backed up and preserved.\nAll of your previous settings will be migrated automatically.%s\nAre you sure you want to continue?",
62-
c.String("version"), colorGreen, colorReset,
61+
"The Rocket Pool %s service will be installed.\n\n%sIf you're upgrading, your existing configuration will be backed up and preserved.\nAll of your previous settings will be migrated automatically.%s\nAre you sure you want to continue?",
62+
shared.RocketPoolVersion, colorGreen, colorReset,
6363
))) {
6464
fmt.Println("Cancelled.")
6565
return nil
@@ -83,7 +83,7 @@ func installService(c *cli.Context) error {
8383
}
8484

8585
// Install service
86-
err = rp.InstallService(c.Bool("verbose"), c.Bool("no-deps"), c.String("version"), c.String("path"), dataPath)
86+
err = rp.InstallService(c.Bool("verbose"), c.Bool("no-deps"), c.String("path"), dataPath)
8787
if err != nil {
8888
return err
8989
}
@@ -150,7 +150,7 @@ func installUpdateTracker(c *cli.Context) error {
150150
defer rp.Close()
151151

152152
// Install service
153-
err := rp.InstallUpdateTracker(c.Bool("verbose"), c.String("version"))
153+
err := rp.InstallUpdateTracker(c.Bool("verbose"))
154154
if err != nil {
155155
return err
156156
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package assets
2+
3+
import (
4+
"embed"
5+
"io/fs"
6+
)
7+
8+
// the all: prefix is used because there are hidden files in the install directory
9+
//
10+
//go:embed all:install
11+
var installFS embed.FS
12+
13+
//go:embed rp-update-tracker
14+
var rpUpdateTrackerFS embed.FS
15+
16+
//go:embed scripts/install.sh
17+
var installScript []byte
18+
19+
//go:embed scripts/install-update-tracker.sh
20+
var installUpdateTrackerScript []byte
21+
22+
type ScriptWithContext struct {
23+
Script []byte
24+
Context fs.FS
25+
}
26+
27+
func InstallScript() ScriptWithContext {
28+
return ScriptWithContext{Script: installScript, Context: installFS}
29+
}
30+
31+
func InstallUpdateTrackerScript() ScriptWithContext {
32+
return ScriptWithContext{Script: installUpdateTrackerScript, Context: rpUpdateTrackerFS}
33+
}

shared/services/rocketpool/assets/scripts/install-update-tracker.sh

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ else
7575
fi
7676

7777

78-
# The default smart node package version to download
79-
PACKAGE_VERSION="latest"
80-
81-
8278
# Print progress
8379
progress() {
8480
STEP_NUMBER=$1
@@ -92,29 +88,14 @@ install() {
9288

9389

9490
# Parse arguments
95-
while getopts "v:" FLAG; do
91+
while getopts "" FLAG; do
9692
case "$FLAG" in
97-
v) PACKAGE_VERSION="$OPTARG" ;;
9893
*) fail "Incorrect usage." ;;
9994
esac
10095
done
10196

102-
103-
# Get package files URL
104-
if [ "$PACKAGE_VERSION" = "latest" ]; then
105-
PACKAGE_URL="https://github.com/rocket-pool/smartnode-install/releases/latest/download/rp-update-tracker.tar.xz"
106-
else
107-
PACKAGE_URL="https://github.com/rocket-pool/smartnode-install/releases/download/$PACKAGE_VERSION/rp-update-tracker.tar.xz"
108-
fi
109-
110-
111-
# Create temporary data folder; clean up on exit
112-
TEMPDIR=$(mktemp -d 2>/dev/null) || fail "Could not create temporary data directory."
113-
trap 'rm -rf "$TEMPDIR"' EXIT
114-
115-
11697
# Get temporary data paths
117-
PACKAGE_FILES_PATH="$TEMPDIR/rp-update-tracker"
98+
PACKAGE_FILES_PATH="$(dirname $0)/rp-update-tracker"
11899

119100

120101
case "$INSTALLER" in
@@ -123,7 +104,7 @@ case "$INSTALLER" in
123104
apt)
124105

125106
# The total number of steps in the installation process
126-
TOTAL_STEPS="3"
107+
TOTAL_STEPS="2"
127108

128109
# Install dependencies
129110
progress 1 "Installing dependencies..."
@@ -132,13 +113,8 @@ case "$INSTALLER" in
132113
{ sudo apt -y install update-notifier-common || true; } >&2
133114
{ sudo apt -y install moreutils || fail "Could not install OS dependencies."; } >&2
134115

135-
# Download and extract package files
136-
progress 2 "Downloading Rocket Pool update tracker package files..."
137-
{ curl -L "$PACKAGE_URL" | tar -xJ -C "$TEMPDIR" || fail "Could not download and extract the Rocket Pool update tracker package files."; } >&2
138-
{ test -d "$PACKAGE_FILES_PATH" || fail "Could not extract the Rocket Pool update tracker package files."; } >&2
139-
140116
# Install the update tracker files
141-
progress 3 "Installing update tracker..."
117+
progress 2 "Installing update tracker..."
142118
{ sudo mkdir -p "$TEXTFILE_COLLECTOR_PATH" || fail "Could not create textfile collector path."; } >&2
143119
{ sudo mv "$PACKAGE_FILES_PATH/apt/apt-metrics.sh" "$UPDATE_SCRIPT_PATH" || fail "Could not move apt update collector."; } >&2
144120
{ sudo mv "$PACKAGE_FILES_PATH/rp-version-check.sh" "$UPDATE_SCRIPT_PATH" || fail "Could not move Rocket Pool update collector."; } >&2
@@ -152,7 +128,7 @@ case "$INSTALLER" in
152128
dnf)
153129

154130
# The total number of steps in the installation process
155-
TOTAL_STEPS="4"
131+
TOTAL_STEPS="3"
156132

157133
# Install dependencies
158134
progress 1 "Installing dependencies..."
@@ -163,13 +139,8 @@ case "$INSTALLER" in
163139
{ sudo dnf -y install epel-release || true; } >&2
164140
{ sudo dnf -y install moreutils || fail "Could not install moreutils."; } >&2
165141

166-
# Download and extract package files
167-
progress 2 "Downloading Rocket Pool update tracker package files..."
168-
{ curl -L "$PACKAGE_URL" | tar -xJ -C "$TEMPDIR" || fail "Could not download and extract the Rocket Pool update tracker package files."; } >&2
169-
{ test -d "$PACKAGE_FILES_PATH" || fail "Could not extract the Rocket Pool update tracker package files."; } >&2
170-
171142
# Install the update tracker files
172-
progress 3 "Installing update tracker..."
143+
progress 2 "Installing update tracker..."
173144
{ sudo mkdir -p "$TEXTFILE_COLLECTOR_PATH" || fail "Could not create textfile collector path."; } >&2
174145
{ sudo mv "$PACKAGE_FILES_PATH/dnf/dnf-metrics.sh" "$UPDATE_SCRIPT_PATH" || fail "Could not move dnf update collector."; } >&2
175146
{ sudo mv "$PACKAGE_FILES_PATH/rp-version-check.sh" "$UPDATE_SCRIPT_PATH" || fail "Could not move Rocket Pool update collector."; } >&2
@@ -181,7 +152,7 @@ case "$INSTALLER" in
181152
{ sudo chmod +x "$UPDATE_SCRIPT_PATH/rp-dnf-check.sh" || fail "Could not set permissions on Rocket Pool update tracker script."; } >&2
182153

183154
# Install the update checking service
184-
progress 4 "Installing update tracker service..."
155+
progress 3 "Installing update tracker service..."
185156
if [ "$SELINUX" = true ]; then
186157
echo -e "${COLOR_YELLOW}Your system has SELinux enabled, so Rocket Pool can't automatically start the update tracker service."
187158
echo "Please run the following commands manually:"
@@ -203,7 +174,7 @@ case "$INSTALLER" in
203174
yum)
204175

205176
# The total number of steps in the installation process
206-
TOTAL_STEPS="4"
177+
TOTAL_STEPS="3"
207178

208179
# Install dependencies
209180
progress 1 "Installing dependencies..."
@@ -213,13 +184,8 @@ case "$INSTALLER" in
213184
{ sudo yum -y install epel-release || true; } >&2
214185
{ sudo yum -y install moreutils || fail "Could not install moreutils."; } >&2
215186

216-
# Download and extract package files
217-
progress 2 "Downloading Rocket Pool update tracker package files..."
218-
{ curl -L "$PACKAGE_URL" | tar -xJ -C "$TEMPDIR" || fail "Could not download and extract the Rocket Pool update tracker package files."; } >&2
219-
{ test -d "$PACKAGE_FILES_PATH" || fail "Could not extract the Rocket Pool update tracker package files."; } >&2
220-
221187
# Install the update tracker files
222-
progress 3 "Installing update tracker..."
188+
progress 2 "Installing update tracker..."
223189
{ sudo mkdir -p "$TEXTFILE_COLLECTOR_PATH" || fail "Could not create textfile collector path."; } >&2
224190
{ sudo mv "$PACKAGE_FILES_PATH/yum/yum-metrics.sh" "$UPDATE_SCRIPT_PATH" || fail "Could not move yum update collector."; } >&2
225191
{ sudo mv "$PACKAGE_FILES_PATH/rp-version-check.sh" "$UPDATE_SCRIPT_PATH" || fail "Could not move Rocket Pool update collector."; } >&2
@@ -231,7 +197,7 @@ case "$INSTALLER" in
231197
{ sudo chmod +x "$UPDATE_SCRIPT_PATH/rp-yum-check.sh" || fail "Could not set permissions on Rocket Pool update tracker script."; } >&2
232198

233199
# Install the update checking service
234-
progress 4 "Installing update tracker service..."
200+
progress 3 "Installing update tracker service..."
235201
if [ "$SELINUX" = true ]; then
236202
echo -e "${COLOR_YELLOW}Your system has SELinux enabled, so Rocket Pool can't automatically start the update tracker service."
237203
echo "Please run the following commands manually:"

shared/services/rocketpool/assets/scripts/install.sh

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ fi
4747

4848

4949
# The total number of steps in the installation process
50-
TOTAL_STEPS="9"
50+
TOTAL_STEPS="8"
5151
# The Rocket Pool user data path
5252
RP_PATH="$HOME/.rocketpool"
53-
# The default smart node package version to download
54-
PACKAGE_VERSION="latest"
5553
# The default network to run Rocket Pool on
5654
NETWORK="mainnet"
5755

@@ -96,13 +94,12 @@ install() {
9694

9795

9896
# Parse arguments
99-
while getopts "dp:u:n:v:" FLAG; do
97+
while getopts "dp:u:n:" FLAG; do
10098
case "$FLAG" in
10199
d) NO_DEPS=true ;;
102100
p) RP_PATH="$OPTARG" ;;
103101
u) DATA_PATH="$OPTARG" ;;
104102
n) NETWORK="$OPTARG" ;;
105-
v) PACKAGE_VERSION="$OPTARG" ;;
106103
*) fail "Incorrect usage." ;;
107104
esac
108105
done
@@ -111,23 +108,8 @@ if [ -z "$DATA_PATH" ]; then
111108
DATA_PATH="$RP_PATH/data"
112109
fi
113110

114-
115-
# Get package files URL
116-
if [ "$PACKAGE_VERSION" = "latest" ]; then
117-
PACKAGE_URL="https://github.com/rocket-pool/smartnode-install/releases/latest/download/rp-smartnode-install.tar.xz"
118-
else
119-
PACKAGE_URL="https://github.com/rocket-pool/smartnode-install/releases/download/$PACKAGE_VERSION/rp-smartnode-install.tar.xz"
120-
fi
121-
122-
123-
# Create temporary data folder; clean up on exit
124-
TEMPDIR=$(mktemp -d 2>/dev/null) || fail "Could not create temporary data directory."
125-
trap 'rm -rf "$TEMPDIR"' EXIT
126-
127-
128111
# Get temporary data paths
129-
PACKAGE_FILES_PATH="$TEMPDIR/install"
130-
112+
PACKAGE_FILES_PATH="$(dirname $0)/install"
131113

132114
##
133115
# Installation
@@ -411,14 +393,8 @@ progress 6 "Creating Rocket Pool user data directory..."
411393
{ mkdir -p "$RP_PATH/alerting/rules" || fail "Could not create the alerting rules directory."; } >&2
412394

413395

414-
# Download and extract package files
415-
progress 7 "Downloading Rocket Pool package files..."
416-
{ curl -L "$PACKAGE_URL" | tar -xJ -C "$TEMPDIR" || fail "Could not download and extract the Rocket Pool package files."; } >&2
417-
{ test -d "$PACKAGE_FILES_PATH" || fail "Could not extract the Rocket Pool package files."; } >&2
418-
419-
420396
# Copy package files
421-
progress 8 "Copying package files to Rocket Pool user data directory..."
397+
progress 7 "Copying package files to Rocket Pool user data directory..."
422398
{ cp -r "$PACKAGE_FILES_PATH/addons" "$RP_PATH" || fail "Could not copy addons folder to the Rocket Pool user data directory."; } >&2
423399
{ cp -r -n "$PACKAGE_FILES_PATH/override" "$RP_PATH" || rsync -r --ignore-existing "$PACKAGE_FILES_PATH/override" "$RP_PATH" || fail "Could not copy new override files to the Rocket Pool user data directory."; } >&2
424400
{ cp -r "$PACKAGE_FILES_PATH/scripts" "$RP_PATH" || fail "Could not copy scripts folder to the Rocket Pool user data directory."; } >&2
@@ -429,7 +405,7 @@ progress 8 "Copying package files to Rocket Pool user data directory..."
429405
{ touch -a "$RP_PATH/.firstrun" || fail "Could not create the first-run flag file."; } >&2
430406

431407
# Clean up unnecessary files from old installations
432-
progress 9 "Cleaning up obsolete files from previous installs..."
408+
progress 8 "Cleaning up obsolete files from previous installs..."
433409
{ rm -rf "$DATA_PATH/fr-default" || echo "NOTE: Could not remove '$DATA_PATH/fr-default' which is no longer needed."; } >&2
434410
GRAFFITI_OWNER=$(stat -c "%U" $RP_PATH/addons/gww/graffiti.txt)
435411
if [ "$GRAFFITI_OWNER" = "$USER" ]; then

0 commit comments

Comments
 (0)