Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 1 addition & 34 deletions shared/services/rocketpool/assets/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,40 +347,6 @@ fi
# Check for existing installation
progress 5 "Checking for existing installation..."
if [ -d $RP_PATH ]; then
# Check for legacy files - key on the old config.yml
if [ -f "$RP_PATH/config.yml" ]; then
progress 5 "Old installation detected, backing it up and migrating to new config system..."
OLD_CONFIG_BACKUP_PATH="$RP_PATH/old_config_backup"
{ mkdir -p $OLD_CONFIG_BACKUP_PATH || fail "Could not create old config backup folder."; } >&2

if [ -f "$RP_PATH/config.yml" ]; then
{ mv "$RP_PATH/config.yml" "$OLD_CONFIG_BACKUP_PATH" || fail "Could not move config.yml to backup folder."; } >&2
fi
if [ -f "$RP_PATH/settings.yml" ]; then
{ mv "$RP_PATH/settings.yml" "$OLD_CONFIG_BACKUP_PATH" || fail "Could not move settings.yml to backup folder."; } >&2
fi
if [ -f "$RP_PATH/docker-compose.yml" ]; then
{ mv "$RP_PATH/docker-compose.yml" "$OLD_CONFIG_BACKUP_PATH" || fail "Could not move docker-compose.yml to backup folder."; } >&2
fi
if [ -f "$RP_PATH/docker-compose-metrics.yml" ]; then
{ mv "$RP_PATH/docker-compose-metrics.yml" "$OLD_CONFIG_BACKUP_PATH" || fail "Could not move docker-compose-metrics.yml to backup folder."; } >&2
fi
if [ -f "$RP_PATH/docker-compose-fallback.yml" ]; then
{ mv "$RP_PATH/docker-compose-fallback.yml" "$OLD_CONFIG_BACKUP_PATH" || fail "Could not move docker-compose-fallback.yml to backup folder."; } >&2
fi
if [ -f "$RP_PATH/prometheus.tmpl" ]; then
{ mv "$RP_PATH/prometheus.tmpl" "$OLD_CONFIG_BACKUP_PATH" || fail "Could not move prometheus.tmpl to backup folder."; } >&2
fi
if [ -f "$RP_PATH/grafana-prometheus-datasource.yml" ]; then
{ mv "$RP_PATH/grafana-prometheus-datasource.yml" "$OLD_CONFIG_BACKUP_PATH" || fail "Could not move grafana-prometheus-datasource.yml to backup folder."; } >&2
fi
if [ -f "$RP_PATH/grafana-dashboards.yml" ]; then
{ mv "$RP_PATH/grafana-dashboards.yml" "$OLD_CONFIG_BACKUP_PATH" || fail "Could not move grafana-dashboards.yml to backup folder."; } >&2
fi
if [ -d "$RP_PATH/chains" ]; then
{ mv "$RP_PATH/chains" "$OLD_CONFIG_BACKUP_PATH" || fail "Could not move chains directory to backup folder."; } >&2
fi
fi

# Back up existing config file
if [ -f "$RP_PATH/user-settings.yml" ]; then
Expand Down Expand Up @@ -427,6 +393,7 @@ progress 7 "Copying package files to Rocket Pool user data directory..."
progress 8 "Cleaning up obsolete files from previous installs..."
{ rm -rf "$DATA_PATH/fr-default" || echo "NOTE: Could not remove '$DATA_PATH/fr-default' which is no longer needed."; } >&2
{ rm -f "$RP_PATH/images.env" || true; } >&2
{ rm -rf "$RP_PATH/old_config_backup" || true; } >&2

# Install shell completion for rocketpool CLI
progress 9 "Installing shell completion for rocketpool CLI..."
Expand Down
43 changes: 1 addition & 42 deletions shared/services/rocketpool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"math"
"math/big"
"net/http"
Expand Down Expand Up @@ -346,47 +345,7 @@ func (c *Client) runScript(script assets.ScriptWithContext, verbose bool, flags
scriptFile.Close()

// Copy the context to the tmpdir
// If we upgrade to go 1.23+ we can probably use os.CopyFS() instead
err = fs.WalkDir(script.Context, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
dstpath := filepath.Join(tmpdir, path)
if d.IsDir() {
// If d is a directory, create it.
if verbose {
fmt.Printf("Creating directory: %s\n", path)
}
err = os.MkdirAll(dstpath, 0755)
if err != nil {
return err
}
return nil
}

// d is a file, copy it.
if verbose {
fmt.Printf("Copying file: %s\n", path)
}
scriptFile, err := os.Create(dstpath)
if err != nil {
return err
}
content, err := fs.ReadFile(script.Context, path)
if err != nil {
return err
}
_, err = scriptFile.Write(content)
if err != nil {
return err
}
err = scriptFile.Close()
if err != nil {
return err
}
return nil
})
if err != nil {
if err := os.CopyFS(tmpdir, script.Context); err != nil {
return fmt.Errorf("error copying script files: %w", err)
}

Expand Down
Loading