Do not overwrite config on update, minor changes

pull/92/head v2.5.21
Simon Let 6 years ago
parent 21360960aa
commit d10d7099de
  1. 2
      Makefile
  2. 8
      cmd/control/cmd/update.go
  3. 37
      scripts/install.sh
  4. 2
      scripts/rawinstall.sh

@ -11,7 +11,7 @@ build: submodules bin/resh-session-init bin/resh-collect bin/resh-postcollect bi
install: build conf/config-dev.toml install: build conf/config-dev.toml
scripts/install.sh scripts/install.sh
# Dev config # Dev config
cp -f conf/config-dev.toml ~/.config/resh.toml # cp -f conf/config-dev.toml ~/.config/resh.toml
test_go: test_go:
# Running tests # Running tests

@ -3,6 +3,8 @@ package cmd
import ( import (
"os" "os"
"os/exec" "os/exec"
"os/user"
"path/filepath"
"github.com/curusarn/resh/cmd/control/status" "github.com/curusarn/resh/cmd/control/status"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -12,8 +14,10 @@ var updateCmd = &cobra.Command{
Use: "update", Use: "update",
Short: "check for updates and update RESH", Short: "check for updates and update RESH",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
url := "https://raw.githubusercontent.com/curusarn/resh/master/scripts/rawinstall.sh" usr, _ := user.Current()
execCmd := exec.Command("bash", "-c", "curl -fsSL "+url+" | bash") dir := usr.HomeDir
rawinstallPath := filepath.Join(dir, ".resh/rawinstall.sh")
execCmd := exec.Command("bash", rawinstallPath)
execCmd.Stdout = os.Stdout execCmd.Stdout = os.Stdout
execCmd.Stderr = os.Stderr execCmd.Stderr = os.Stderr
err := execCmd.Run() err := execCmd.Run()

@ -114,21 +114,7 @@ cp -f submodules/bash-zsh-compat-widgets/bindfunc.sh ~/.resh/bindfunc.sh
cp -f scripts/shellrc.sh ~/.resh/shellrc cp -f scripts/shellrc.sh ~/.resh/shellrc
cp -f scripts/reshctl.sh scripts/widgets.sh scripts/hooks.sh scripts/util.sh ~/.resh/ cp -f scripts/reshctl.sh scripts/widgets.sh scripts/hooks.sh scripts/util.sh ~/.resh/
cp -f scripts/rawinstall.sh ~/.resh/
# hotfix to not overwrite enabled ctrl+R binding in config
bindcontrolr=0
if [ "$(bin/resh-config -key bindcontrolr)" = true ]; then
# control_R binding is enabled
bindcontrolr=1
fi
cp -f conf/config.toml ~/.config/resh.toml
# hotfix part2 (ctrl+R)
if [ "$bindcontrolr" = 1 ]; then
# reenable ctrl+R binding if it was enabled before
bin/resh-control enable ctrl_r_binding_global >/dev/null 2>/dev/null
fi
echo "Generating completions ..." echo "Generating completions ..."
bin/resh-control completion bash > ~/.resh/bash_completion.d/_reshctl bin/resh-control completion bash > ~/.resh/bash_completion.d/_reshctl
@ -143,6 +129,27 @@ cp -fr data/sanitizer ~/.resh/sanitizer_data
# backward compatibility: We have a new location for resh history file # backward compatibility: We have a new location for resh history file
[ ! -f ~/.resh/history.json ] || mv ~/.resh/history.json ~/.resh_history.json [ ! -f ~/.resh/history.json ] || mv ~/.resh/history.json ~/.resh_history.json
update_config() {
version=$1
key=$2
value=$3
# TODO: create bin/semver-lt
if bin/semver-lt "${__RESH_VERSION:-0.0.0}" "$1" && [ "$(bin/resh-config -key $key)" != "$value" ] ; then
echo " * config option $key was updated to $value"
# TODO: enable resh-config value setting
# resh-config -key "$key" -value "$value"
fi
}
# Do not overwrite if exists
if [ ! -f ~/.config/resh.toml ]; then
cp conf/config.toml ~/.config/resh.toml
# else
# echo "Merging config files ..."
# NOTE: This is where we will merge configs when we make changes to the upstream config
# HINT: check which version are we updating FROM and make changes to config based on that
fi
echo "Finishing up ..." echo "Finishing up ..."
# Adding resh shellrc to .bashrc ... # Adding resh shellrc to .bashrc ...
if [ ! -f ~/.bashrc ]; then if [ ! -f ~/.bashrc ]; then

@ -34,7 +34,7 @@ version="${tag:1}"
echo " * Latest version: $version (git tag: $tag)" echo " * Latest version: $version (git tag: $tag)"
# TODO: compare semanitcally instead of just using equality # TODO: compare semanitcally instead of just using equality
if [ "${__RESH_VERSION-}" == "$version" ]; then if [ "${__RESH_VERSION:-}" == "$version" ]; then
echo " * Resh is up to date - nothing to do - exiting." echo " * Resh is up to date - nothing to do - exiting."
exit 0 exit 0
fi fi

Loading…
Cancel
Save