mirror of
https://github.com/rancher/os.git
synced 2025-08-09 18:48:05 +00:00
remove dependency on version string
using rancher.rm_usr kernel param instead
This commit is contained in:
parent
4899ccd89c
commit
c79a64e42e
@ -78,6 +78,7 @@ type RancherConfig struct {
|
|||||||
BootstrapDocker DockerConfig `yaml:"bootstrap_docker,omitempty"`
|
BootstrapDocker DockerConfig `yaml:"bootstrap_docker,omitempty"`
|
||||||
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
||||||
Debug bool `yaml:"debug,omitempty"`
|
Debug bool `yaml:"debug,omitempty"`
|
||||||
|
RmUsr bool `yaml:"rm_usr,omitempty"`
|
||||||
Log bool `yaml:"log,omitempty"`
|
Log bool `yaml:"log,omitempty"`
|
||||||
Disable []string `yaml:"disable,omitempty"`
|
Disable []string `yaml:"disable,omitempty"`
|
||||||
ServicesInclude map[string]bool `yaml:"services_include,omitempty"`
|
ServicesInclude map[string]bool `yaml:"services_include,omitempty"`
|
||||||
|
@ -129,7 +129,7 @@ func tryMountAndBootstrap(cfg *config.CloudConfig) (*config.CloudConfig, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Switching to new root at %s", STATE)
|
log.Debugf("Switching to new root at %s", STATE)
|
||||||
return cfg, switchRoot(STATE)
|
return cfg, switchRoot(STATE, cfg.Rancher.RmUsr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLaunchConfig(cfg *config.CloudConfig, dockerCfg *config.DockerConfig) (*dockerlaunch.Config, []string) {
|
func getLaunchConfig(cfg *config.CloudConfig, dockerCfg *config.DockerConfig) (*dockerlaunch.Config, []string) {
|
||||||
|
24
init/root.go
24
init/root.go
@ -5,7 +5,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
@ -31,15 +30,6 @@ func cleanupTarget(rootfs, targetUsr, usr, usrVer, tmpDir string) (bool, error)
|
|||||||
log.Errorf("Failed to cleanup temp directory %s: %v", tmpDir, err)
|
log.Errorf("Failed to cleanup temp directory %s: %v", tmpDir, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(usrVer, "dev") {
|
|
||||||
log.Debugf("Deleteing old usr: %s", usr)
|
|
||||||
if err := os.RemoveAll(usr); err != nil {
|
|
||||||
// Don't care if this fails
|
|
||||||
log.Errorf("Failed to remove %s: %v", usr, err)
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := os.Stat(usr); err == nil {
|
if _, err := os.Stat(usr); err == nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
@ -47,12 +37,20 @@ func cleanupTarget(rootfs, targetUsr, usr, usrVer, tmpDir string) (bool, error)
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyMoveRoot(rootfs string) error {
|
func copyMoveRoot(rootfs string, rmUsr bool) error {
|
||||||
usrVer := fmt.Sprintf("usr-%s", config.VERSION)
|
usrVer := fmt.Sprintf("usr-%s", config.VERSION)
|
||||||
usr := path.Join(rootfs, usrVer)
|
usr := path.Join(rootfs, usrVer)
|
||||||
targetUsr := path.Join(rootfs, "usr")
|
targetUsr := path.Join(rootfs, "usr")
|
||||||
tmpDir := path.Join(rootfs, "tmp")
|
tmpDir := path.Join(rootfs, "tmp")
|
||||||
|
|
||||||
|
if rmUsr {
|
||||||
|
log.Warnf("Development setup. Removing old usr: %s", usr)
|
||||||
|
if err := os.RemoveAll(usr); err != nil {
|
||||||
|
// Don't care if this fails
|
||||||
|
log.Errorf("Failed to remove %s: %v", usr, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if cont, err := cleanupTarget(rootfs, targetUsr, usr, usrVer, tmpDir); !cont {
|
if cont, err := cleanupTarget(rootfs, targetUsr, usr, usrVer, tmpDir); !cont {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -100,7 +98,7 @@ func copyMoveRoot(rootfs string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func switchRoot(rootfs string) error {
|
func switchRoot(rootfs string, rmUsr bool) error {
|
||||||
for _, i := range []string{"/dev", "/sys", "/proc", "/run"} {
|
for _, i := range []string{"/dev", "/sys", "/proc", "/run"} {
|
||||||
log.Debugf("Moving mount %s to %s", i, path.Join(rootfs, i))
|
log.Debugf("Moving mount %s to %s", i, path.Join(rootfs, i))
|
||||||
if err := os.MkdirAll(path.Join(rootfs, i), 0755); err != nil {
|
if err := os.MkdirAll(path.Join(rootfs, i), 0755); err != nil {
|
||||||
@ -111,7 +109,7 @@ func switchRoot(rootfs string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := copyMoveRoot(rootfs); err != nil {
|
if err := copyMoveRoot(rootfs, rmUsr); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ INITRD=${BASE}/dist/artifacts/initrd
|
|||||||
|
|
||||||
QEMU=1
|
QEMU=1
|
||||||
FORMAT=1
|
FORMAT=1
|
||||||
|
RM_USR=1
|
||||||
REBUILD=1
|
REBUILD=1
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
@ -54,6 +55,9 @@ while [ "$#" -gt 0 ]; do
|
|||||||
--no-format)
|
--no-format)
|
||||||
FORMAT=0
|
FORMAT=0
|
||||||
;;
|
;;
|
||||||
|
--no-rm-usr)
|
||||||
|
RM_USR=0
|
||||||
|
;;
|
||||||
--no-rebuild)
|
--no-rebuild)
|
||||||
REBUILD=0
|
REBUILD=0
|
||||||
;;
|
;;
|
||||||
@ -110,6 +114,9 @@ KERNEL_ARGS="quiet rancher.password=rancher console=ttyS0 ${QEMU_APPEND}"
|
|||||||
if [ "$FORMAT" == "1" ]; then
|
if [ "$FORMAT" == "1" ]; then
|
||||||
KERNEL_ARGS="${KERNEL_ARGS} rancher.state.formatzero=true rancher.state.autoformat=[/dev/sda,/dev/vda]"
|
KERNEL_ARGS="${KERNEL_ARGS} rancher.state.formatzero=true rancher.state.autoformat=[/dev/sda,/dev/vda]"
|
||||||
fi
|
fi
|
||||||
|
if [ "$RM_USR" == "1" ]; then
|
||||||
|
KERNEL_ARGS="${KERNEL_ARGS} rancher.rm_usr"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$KVM" == "" ] && [ -c /dev/kvm ] && [ -r /dev/kvm ] && [ -w /dev/kvm ]; then
|
if [ "$KVM" == "" ] && [ -c /dev/kvm ] && [ -r /dev/kvm ] && [ -w /dev/kvm ]; then
|
||||||
KVM=1
|
KVM=1
|
||||||
|
Loading…
Reference in New Issue
Block a user