Compare commits

...

3 Commits

Author SHA1 Message Date
Darren Shepherd
066688504f Change volume containers to create only 2015-03-20 11:36:00 -07:00
Darren Shepherd
796580d255 Add dynamic version string 2015-03-20 11:35:21 -07:00
Darren Shepherd
127ca3e465 Add prompting to reboot 2015-03-20 11:34:34 -07:00
7 changed files with 41 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
package control
import (
"bufio"
"fmt"
"io/ioutil"
"net/http"
@@ -137,7 +138,19 @@ func osUpgrade(c *cli.Context) {
startUpgradeContainer(image, c.Bool("stage"), c.Bool("force"))
}
func yes(in *bufio.Reader, question string) bool {
fmt.Printf("%s [y/N]: ", question)
line, err := in.ReadString('\n')
if err != nil {
log.Fatal(err)
}
return strings.ToLower(line[0:1]) == "y"
}
func startUpgradeContainer(image string, stage, force bool) {
in := bufio.NewReader(os.Stdin)
container := docker.NewContainer(config.DOCKER_SYSTEM_HOST, &config.ContainerConfig{
Cmd: "--name=os-upgrade " +
"--rm " +
@@ -152,17 +165,11 @@ func startUpgradeContainer(image string, stage, force bool) {
log.Fatal(container.Err)
}
if !stage {
fmt.Printf("Upgrading to %s : %v\n", image, stage)
if !force {
fmt.Print("Continue [y/N] ")
one := make([]byte, 1, 1)
_, err := os.Stdin.Read(one)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Upgrading to %s\n", image)
if string(one) != "Y" && string(one) != "y" {
if !stage {
if !force {
if !yes(in, "Continue") {
os.Exit(1)
}
}
@@ -198,9 +205,12 @@ func startUpgradeContainer(image string, stage, force bool) {
}
if exit == 0 {
log.Info("Rebooting")
power.Reboot()
if force || yes(in, "Continue with reboot") {
log.Info("Rebooting")
power.Reboot()
}
} else {
log.Error("Upgrade failed")
os.Exit(exit)
}
}

View File

@@ -93,6 +93,7 @@ func NewConfig() *Config {
"-v=/var/run:/var/run " +
"-v=/var/log:/var/log " +
"state",
CreateOnly: true,
},
{
Id: "command-volumes",
@@ -111,6 +112,7 @@ func NewConfig() *Config {
"-v=/lib/modules:/lib/modules:ro " +
"-v=/usr/bin/docker:/usr/bin/docker:ro " +
"state",
CreateOnly: true,
},
{
Id: "user-volumes",
@@ -120,15 +122,18 @@ func NewConfig() *Config {
"-v=/home:/home " +
"-v=/opt:/opt " +
"state",
CreateOnly: true,
},
{
Id: "docker-volumes",
Cmd: "--name=docker-volumes " +
"--net=none " +
"--read-only " +
"-v=/var/lib/rancher:/var/lib/rancher " +
"-v=/var/lib/docker:/var/lib/docker " +
"-v=/var/lib/system-docker:/var/lib/system-docker " +
"state",
CreateOnly: true,
},
{
Id: "all-volumes",
@@ -141,6 +146,7 @@ func NewConfig() *Config {
"--volumes-from=user-volumes " +
"--volumes-from=system-volumes " +
"state",
CreateOnly: true,
},
{
Id: "cloud-init-pre",

View File

@@ -1,7 +1,6 @@
package config
const (
VERSION = "0.2.0"
CONSOLE_CONTAINER = "console"
DOCKER_BIN = "/usr/bin/docker"
DOCKER_SYSTEM_HOME = "/var/lib/system-docker"
@@ -16,6 +15,7 @@ const (
)
var (
VERSION string
CloudConfigFile = "/var/lib/rancher/conf/cloud-config-rancher.yml"
ConfigFile = "/var/lib/rancher/conf/rancher.yml"
PrivateConfigFile = "/var/lib/rancher/conf/rancher-private.yml"
@@ -103,3 +103,9 @@ type StateConfig struct {
type CloudInit struct {
Datasources []string `yaml:"datasources,omitempty"`
}
func init() {
if VERSION == "" {
VERSION = "v0.0.0-dev"
}
}

View File

@@ -3,6 +3,8 @@ set -x
cd $(dirname $0)/..
source scripts/version
if [ "$IN_DOCKER" != "true" ]; then
cat > .dockerfile << "EOF"
FROM rancher/dind:v0.1.0
@@ -39,5 +41,5 @@ fi
echo export GOPATH=$GOPATH
mkdir -p bin
go build -tags netgo -ldflags "-linkmode external -extldflags -static" -o bin/rancheros
go build -tags netgo -ldflags "-X github.com/rancherio/os/config.VERSION ${VERSION:-v0.0.0-dev} -linkmode external -extldflags -static" -o bin/rancheros
strip --strip-all bin/rancheros

View File

@@ -54,6 +54,6 @@ for i in $(ls -d * .* | sort -u | grep -Ev '(\.|\.\.|\.dockerfile|build|dist|.gi
ARGS="${ARGS} $i"
fi
done
run --assets "${ARGS}" ./scripts/build
run --assets ./scripts/version --assets "${ARGS}" ./scripts/build
run --assets ./scripts/install ./scripts/package "$@"
finish

View File

@@ -4,5 +4,5 @@ cd $(dirname $0)/..
source scripts/build-common
download d39f85b5c3ca59be9936627b2c3138bc2868fdfd https://github.com/rancherio/os-base/releases/download/v0.1.0/os-base.tar.xz
download 229f3d43369982b6a7b410795c9762814ade0f56 https://github.com/rancherio/os-base/releases/download/v0.1.1/os-base.tar.xz
download 1acbe869b32869bca5788373e8624a2957cbb380 https://github.com/ibuildthecloud/docker/releases/download/v1.5.0-rancher-2/docker-1.5.0

1
scripts/version Normal file
View File

@@ -0,0 +1 @@
VERSION=v0.2.0