2015-10-18 00:03:46 +02:00
|
|
|
|
/*
|
2017-02-15 09:31:00 +01:00
|
|
|
|
* Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
|
2015-10-18 00:03:46 +02:00
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-08-19 01:23:42 +02:00
|
|
|
|
package cmd
|
2015-10-18 00:03:46 +02:00
|
|
|
|
|
|
|
|
|
import (
|
2017-06-24 22:17:28 +02:00
|
|
|
|
"bufio"
|
2017-02-15 09:31:00 +01:00
|
|
|
|
"fmt"
|
2015-12-23 02:11:11 +01:00
|
|
|
|
"io/ioutil"
|
2015-10-18 00:03:46 +02:00
|
|
|
|
"net/http"
|
2016-10-13 03:09:08 +02:00
|
|
|
|
"os"
|
2017-02-21 10:32:05 +01:00
|
|
|
|
"os/exec"
|
|
|
|
|
"path/filepath"
|
2015-10-18 00:03:46 +02:00
|
|
|
|
"runtime"
|
2015-12-23 02:11:11 +01:00
|
|
|
|
"strings"
|
2015-10-18 00:03:46 +02:00
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/fatih/color"
|
|
|
|
|
"github.com/minio/cli"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Check for new software updates.
|
|
|
|
|
var updateCmd = cli.Command{
|
|
|
|
|
Name: "update",
|
2015-11-26 06:06:29 +01:00
|
|
|
|
Usage: "Check for a new software update.",
|
2015-10-18 00:03:46 +02:00
|
|
|
|
Action: mainUpdate,
|
2017-02-15 09:31:00 +01:00
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
cli.BoolFlag{
|
|
|
|
|
Name: "quiet",
|
|
|
|
|
Usage: "Disable any update messages.",
|
|
|
|
|
},
|
|
|
|
|
},
|
2015-10-18 00:03:46 +02:00
|
|
|
|
CustomHelpTemplate: `Name:
|
2017-02-16 02:45:08 +01:00
|
|
|
|
{{.HelpName}} - {{.Usage}}
|
2015-10-18 00:03:46 +02:00
|
|
|
|
|
|
|
|
|
USAGE:
|
2017-02-20 05:46:06 +01:00
|
|
|
|
{{.HelpName}}{{if .VisibleFlags}} [FLAGS]{{end}}
|
2017-02-16 02:45:08 +01:00
|
|
|
|
{{if .VisibleFlags}}
|
2015-11-26 06:06:29 +01:00
|
|
|
|
FLAGS:
|
2017-02-15 11:25:38 +01:00
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
2017-02-16 02:45:08 +01:00
|
|
|
|
{{end}}{{end}}
|
2017-02-15 09:31:00 +01:00
|
|
|
|
EXIT STATUS:
|
|
|
|
|
0 - You are already running the most recent version.
|
|
|
|
|
1 - New update is available.
|
|
|
|
|
-1 - Error in getting update information.
|
2015-11-26 06:06:29 +01:00
|
|
|
|
|
2017-02-20 05:46:06 +01:00
|
|
|
|
EXAMPLES:
|
|
|
|
|
1. Check if there is a new update available:
|
|
|
|
|
$ {{.HelpName}}
|
|
|
|
|
`,
|
2015-10-18 00:03:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-21 10:32:05 +01:00
|
|
|
|
const (
|
|
|
|
|
minioReleaseTagTimeLayout = "2006-01-02T15-04-05Z"
|
|
|
|
|
minioReleaseURL = "https://dl.minio.io/server/minio/release/" + runtime.GOOS + "-" + runtime.GOARCH + "/"
|
|
|
|
|
)
|
2017-02-15 09:31:00 +01:00
|
|
|
|
|
|
|
|
|
func getCurrentReleaseTime(minioVersion, minioBinaryPath string) (releaseTime time.Time, err error) {
|
|
|
|
|
if releaseTime, err = time.Parse(time.RFC3339, minioVersion); err == nil {
|
|
|
|
|
return releaseTime, err
|
2015-12-23 02:11:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-21 10:32:05 +01:00
|
|
|
|
if !filepath.IsAbs(minioBinaryPath) {
|
|
|
|
|
// Make sure to look for the absolute path of the binary.
|
|
|
|
|
minioBinaryPath, err = exec.LookPath(minioBinaryPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return releaseTime, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
// Looks like version is minio non-standard, we use minio binary's ModTime as release time.
|
2017-05-02 11:35:27 +02:00
|
|
|
|
fi, err := osStat(minioBinaryPath)
|
2016-04-29 23:24:10 +02:00
|
|
|
|
if err != nil {
|
2017-02-15 09:31:00 +01:00
|
|
|
|
err = fmt.Errorf("Unable to get ModTime of %s. %s", minioBinaryPath, err)
|
|
|
|
|
} else {
|
|
|
|
|
releaseTime = fi.ModTime().UTC()
|
2015-12-23 02:11:11 +01:00
|
|
|
|
}
|
2017-02-15 09:31:00 +01:00
|
|
|
|
|
|
|
|
|
return releaseTime, err
|
2015-12-23 02:11:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
// GetCurrentReleaseTime - returns this process's release time. If it is official minio version,
|
|
|
|
|
// parsed version is returned else minio binary's mod time is returned.
|
|
|
|
|
func GetCurrentReleaseTime() (releaseTime time.Time, err error) {
|
|
|
|
|
return getCurrentReleaseTime(Version, os.Args[0])
|
|
|
|
|
}
|
2016-10-13 03:09:08 +02:00
|
|
|
|
|
2017-06-13 02:33:21 +02:00
|
|
|
|
// Check if we are indeed inside docker.
|
|
|
|
|
// https://github.com/moby/moby/blob/master/daemon/initlayer/setup_unix.go#L25
|
|
|
|
|
//
|
|
|
|
|
// "/.dockerenv": "file",
|
|
|
|
|
//
|
|
|
|
|
func isDocker(dockerEnvFile string) (ok bool, err error) {
|
|
|
|
|
_, err = os.Stat(dockerEnvFile)
|
|
|
|
|
if err != nil {
|
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
|
err = nil
|
|
|
|
|
}
|
|
|
|
|
return false, err
|
2016-10-13 03:09:08 +02:00
|
|
|
|
}
|
2017-06-13 02:33:21 +02:00
|
|
|
|
return true, nil
|
2016-10-13 03:09:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-09 11:42:12 +02:00
|
|
|
|
// IsDocker - returns if the environment minio is running
|
|
|
|
|
// is docker or not.
|
2017-02-15 09:31:00 +01:00
|
|
|
|
func IsDocker() bool {
|
2017-06-13 02:33:21 +02:00
|
|
|
|
found, err := isDocker("/.dockerenv")
|
|
|
|
|
// We don't need to fail for this check, log
|
|
|
|
|
// an error and return false.
|
|
|
|
|
errorIf(err, "Error in docker check.")
|
2017-02-15 09:31:00 +01:00
|
|
|
|
|
|
|
|
|
return found
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-13 02:33:21 +02:00
|
|
|
|
// IsDCOS returns true if minio is running in DCOS.
|
|
|
|
|
func IsDCOS() bool {
|
|
|
|
|
// http://mesos.apache.org/documentation/latest/docker-containerizer/
|
|
|
|
|
// Mesos docker containerizer sets this value
|
|
|
|
|
return os.Getenv("MESOS_CONTAINER_NAME") != ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsKubernetes returns true if minio is running in kubernetes.
|
2017-06-09 11:42:12 +02:00
|
|
|
|
func IsKubernetes() bool {
|
|
|
|
|
// Kubernetes env used to validate if we are
|
|
|
|
|
// indeed running inside a kubernetes pod
|
|
|
|
|
// is KUBERNETES_SERVICE_HOST but in future
|
|
|
|
|
// we might need to enhance this.
|
|
|
|
|
return os.Getenv("KUBERNETES_SERVICE_HOST") != ""
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-24 22:17:28 +02:00
|
|
|
|
// Minio Helm chart uses DownwardAPIFile to write pod label info to /podinfo/labels
|
|
|
|
|
// More info: https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/#store-pod-fields
|
|
|
|
|
// Check if this is Helm package installation and report helm chart version
|
|
|
|
|
func getHelmVersion(helmInfoFilePath string) string {
|
|
|
|
|
// Read the file exists.
|
|
|
|
|
helmInfoFile, err := os.Open(helmInfoFilePath)
|
|
|
|
|
// Log errors and return "" as Minio can be deployed without Helm charts as well.
|
|
|
|
|
if err != nil && !os.IsNotExist(err) {
|
|
|
|
|
errorIf(err, "Unable to read %s", helmInfoFilePath)
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scanner := bufio.NewScanner(helmInfoFile)
|
|
|
|
|
for scanner.Scan() {
|
|
|
|
|
if strings.Contains(scanner.Text(), "chart=") {
|
|
|
|
|
helmChartVersion := strings.TrimPrefix(scanner.Text(), "chart=")
|
|
|
|
|
// remove quotes from the chart version
|
|
|
|
|
return strings.Trim(helmChartVersion, `"`)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
func isSourceBuild(minioVersion string) bool {
|
|
|
|
|
_, err := time.Parse(time.RFC3339, minioVersion)
|
|
|
|
|
return err != nil
|
2016-11-20 08:20:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
// IsSourceBuild - returns if this binary is made from source or not.
|
|
|
|
|
func IsSourceBuild() bool {
|
|
|
|
|
return isSourceBuild(Version)
|
|
|
|
|
}
|
2016-03-25 01:20:49 +01:00
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
// DO NOT CHANGE USER AGENT STYLE.
|
|
|
|
|
// The style should be
|
2017-06-09 11:42:12 +02:00
|
|
|
|
//
|
2017-06-13 02:33:21 +02:00
|
|
|
|
// Minio (<OS>; <ARCH>[; dcos][; kubernetes][; docker][; source]) Minio/<VERSION> Minio/<RELEASE-TAG> Minio/<COMMIT-ID> [Minio/univers-<PACKAGE_NAME>]
|
2017-02-15 09:31:00 +01:00
|
|
|
|
//
|
|
|
|
|
// For any change here should be discussed by openning an issue at https://github.com/minio/minio/issues.
|
2017-03-16 20:21:58 +01:00
|
|
|
|
func getUserAgent(mode string) string {
|
2017-02-15 09:31:00 +01:00
|
|
|
|
userAgent := "Minio (" + runtime.GOOS + "; " + runtime.GOARCH
|
2017-03-16 20:21:58 +01:00
|
|
|
|
if mode != "" {
|
|
|
|
|
userAgent += "; " + mode
|
|
|
|
|
}
|
2017-06-13 02:33:21 +02:00
|
|
|
|
if IsDCOS() {
|
|
|
|
|
userAgent += "; dcos"
|
|
|
|
|
}
|
2017-06-09 11:42:12 +02:00
|
|
|
|
if IsKubernetes() {
|
|
|
|
|
userAgent += "; kubernetes"
|
|
|
|
|
}
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if IsDocker() {
|
|
|
|
|
userAgent += "; docker"
|
|
|
|
|
}
|
|
|
|
|
if IsSourceBuild() {
|
|
|
|
|
userAgent += "; source"
|
2016-03-25 01:20:49 +01:00
|
|
|
|
}
|
2017-02-15 09:31:00 +01:00
|
|
|
|
|
2017-06-13 02:33:21 +02:00
|
|
|
|
userAgent += ") Minio/" + Version + " Minio/" + ReleaseTag + " Minio/" + CommitID
|
|
|
|
|
if IsDCOS() {
|
|
|
|
|
universePkgVersion := os.Getenv("MARATHON_APP_LABEL_DCOS_PACKAGE_VERSION")
|
|
|
|
|
// On DC/OS environment try to the get universe package version.
|
|
|
|
|
if universePkgVersion != "" {
|
|
|
|
|
userAgent += " Minio/" + "universe-" + universePkgVersion
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-24 22:17:28 +02:00
|
|
|
|
|
|
|
|
|
if IsKubernetes() {
|
|
|
|
|
// In Kubernetes environment, try to fetch the helm package version
|
|
|
|
|
helmChartVersion := getHelmVersion("/podinfo/labels")
|
|
|
|
|
if helmChartVersion != "" {
|
|
|
|
|
userAgent += " Minio/" + "helm-" + helmChartVersion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
return userAgent
|
|
|
|
|
}
|
2016-03-25 01:20:49 +01:00
|
|
|
|
|
2017-03-16 20:21:58 +01:00
|
|
|
|
func downloadReleaseData(releaseChecksumURL string, timeout time.Duration, mode string) (data string, err error) {
|
2017-02-15 09:31:00 +01:00
|
|
|
|
req, err := http.NewRequest("GET", releaseChecksumURL, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return data, err
|
2016-03-25 01:20:49 +01:00
|
|
|
|
}
|
2017-03-16 20:21:58 +01:00
|
|
|
|
req.Header.Set("User-Agent", getUserAgent(mode))
|
2016-03-25 01:20:49 +01:00
|
|
|
|
|
|
|
|
|
client := &http.Client{
|
2017-02-15 09:31:00 +01:00
|
|
|
|
Timeout: timeout,
|
2017-03-01 18:18:55 +01:00
|
|
|
|
Transport: &http.Transport{
|
|
|
|
|
// need to close connection after usage.
|
|
|
|
|
DisableKeepAlives: true,
|
|
|
|
|
},
|
2016-03-25 01:20:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
resp, err := client.Do(req)
|
2016-08-19 17:09:05 +02:00
|
|
|
|
if err != nil {
|
2017-02-15 09:31:00 +01:00
|
|
|
|
return data, err
|
|
|
|
|
}
|
|
|
|
|
if resp == nil {
|
|
|
|
|
return data, fmt.Errorf("No response from server to download URL %s", releaseChecksumURL)
|
2016-08-19 17:09:05 +02:00
|
|
|
|
}
|
2017-03-01 18:18:55 +01:00
|
|
|
|
defer resp.Body.Close()
|
2016-08-19 17:09:05 +02:00
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if resp.StatusCode != http.StatusOK {
|
|
|
|
|
return data, fmt.Errorf("Error downloading URL %s. Response: %v", releaseChecksumURL, resp.Status)
|
|
|
|
|
}
|
|
|
|
|
dataBytes, err := ioutil.ReadAll(resp.Body)
|
2016-10-13 03:09:08 +02:00
|
|
|
|
if err != nil {
|
2017-02-15 09:31:00 +01:00
|
|
|
|
return data, fmt.Errorf("Error reading response. %s", err)
|
2016-10-13 03:09:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
data = string(dataBytes)
|
|
|
|
|
return data, err
|
|
|
|
|
}
|
2016-10-24 22:44:15 +02:00
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
// DownloadReleaseData - downloads release data from minio official server.
|
2017-03-16 20:21:58 +01:00
|
|
|
|
func DownloadReleaseData(timeout time.Duration, mode string) (data string, err error) {
|
2017-05-13 06:40:22 +02:00
|
|
|
|
data, err = downloadReleaseData(minioReleaseURL+"minio.shasum", timeout, mode)
|
|
|
|
|
if err == nil {
|
|
|
|
|
return data, nil
|
|
|
|
|
}
|
|
|
|
|
return downloadReleaseData(minioReleaseURL+"minio.sha256sum", timeout, mode)
|
2017-02-15 09:31:00 +01:00
|
|
|
|
}
|
2016-10-13 03:09:08 +02:00
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
func parseReleaseData(data string) (releaseTime time.Time, err error) {
|
|
|
|
|
fields := strings.Fields(data)
|
|
|
|
|
if len(fields) != 2 {
|
|
|
|
|
err = fmt.Errorf("Unknown release data `%s`", data)
|
|
|
|
|
return releaseTime, err
|
2015-10-18 00:03:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
releaseInfo := fields[1]
|
|
|
|
|
if fields = strings.Split(releaseInfo, "."); len(fields) != 3 {
|
|
|
|
|
err = fmt.Errorf("Unknown release information `%s`", releaseInfo)
|
|
|
|
|
return releaseTime, err
|
2016-03-25 01:20:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if !(fields[0] == "minio" && fields[1] == "RELEASE") {
|
|
|
|
|
err = fmt.Errorf("Unknown release '%s'", releaseInfo)
|
|
|
|
|
return releaseTime, err
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-21 10:32:05 +01:00
|
|
|
|
releaseTime, err = time.Parse(minioReleaseTagTimeLayout, fields[2])
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if err != nil {
|
|
|
|
|
err = fmt.Errorf("Unknown release time format. %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return releaseTime, err
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 20:21:58 +01:00
|
|
|
|
func getLatestReleaseTime(timeout time.Duration, mode string) (releaseTime time.Time, err error) {
|
|
|
|
|
data, err := DownloadReleaseData(timeout, mode)
|
2016-08-19 17:09:05 +02:00
|
|
|
|
if err != nil {
|
2017-02-15 09:31:00 +01:00
|
|
|
|
return releaseTime, err
|
2016-03-25 01:20:49 +01:00
|
|
|
|
}
|
2016-08-19 17:09:05 +02:00
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
return parseReleaseData(data)
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-13 02:33:21 +02:00
|
|
|
|
const (
|
|
|
|
|
// Kubernetes deployment doc link.
|
|
|
|
|
kubernetesDeploymentDoc = "https://docs.minio.io/docs/deploy-minio-on-kubernetes"
|
|
|
|
|
|
|
|
|
|
// Mesos deployment doc link.
|
|
|
|
|
mesosDeploymentDoc = "https://docs.minio.io/docs/deploy-minio-on-dc-os"
|
|
|
|
|
)
|
2017-06-09 11:42:12 +02:00
|
|
|
|
|
|
|
|
|
func getDownloadURL(buildDate time.Time) (downloadURL string) {
|
2017-06-13 02:33:21 +02:00
|
|
|
|
// Check if we are in DCOS environment, return
|
|
|
|
|
// deployment guide for update procedures.
|
|
|
|
|
if IsDCOS() {
|
|
|
|
|
return mesosDeploymentDoc
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-09 11:42:12 +02:00
|
|
|
|
// Check if we are in kubernetes environment, return
|
|
|
|
|
// deployment guide for update procedures.
|
|
|
|
|
if IsKubernetes() {
|
|
|
|
|
return kubernetesDeploymentDoc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if we are docker environment, return docker update command
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if IsDocker() {
|
2017-06-09 11:42:12 +02:00
|
|
|
|
// Construct release tag name.
|
|
|
|
|
rTag := "RELEASE." + buildDate.Format(minioReleaseTagTimeLayout)
|
|
|
|
|
return fmt.Sprintf("docker pull minio/minio:%s", rTag)
|
2017-02-15 09:31:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-09 11:42:12 +02:00
|
|
|
|
// For binary only installations, then we just show binary download link.
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
return minioReleaseURL + "minio.exe"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return minioReleaseURL + "minio"
|
|
|
|
|
}
|
2015-10-18 00:03:46 +02:00
|
|
|
|
|
2017-05-31 18:22:00 +02:00
|
|
|
|
func getUpdateInfo(timeout time.Duration, mode string) (older time.Duration,
|
|
|
|
|
downloadURL string, err error) {
|
|
|
|
|
|
|
|
|
|
var currentReleaseTime, latestReleaseTime time.Time
|
|
|
|
|
currentReleaseTime, err = GetCurrentReleaseTime()
|
2016-08-19 17:09:05 +02:00
|
|
|
|
if err != nil {
|
2017-02-15 09:31:00 +01:00
|
|
|
|
return older, downloadURL, err
|
2016-03-25 01:20:49 +01:00
|
|
|
|
}
|
2015-10-18 00:03:46 +02:00
|
|
|
|
|
2017-05-31 18:22:00 +02:00
|
|
|
|
latestReleaseTime, err = getLatestReleaseTime(timeout, mode)
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if err != nil {
|
|
|
|
|
return older, downloadURL, err
|
2015-10-18 00:03:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if latestReleaseTime.After(currentReleaseTime) {
|
|
|
|
|
older = latestReleaseTime.Sub(currentReleaseTime)
|
2017-06-09 11:42:12 +02:00
|
|
|
|
downloadURL = getDownloadURL(latestReleaseTime)
|
2015-10-18 00:03:46 +02:00
|
|
|
|
}
|
2016-03-25 01:20:49 +01:00
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
return older, downloadURL, nil
|
2015-10-18 00:03:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func mainUpdate(ctx *cli.Context) {
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if len(ctx.Args()) != 0 {
|
|
|
|
|
cli.ShowCommandHelpAndExit(ctx, "update", -1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quiet := ctx.Bool("quiet") || ctx.GlobalBool("quiet")
|
2017-03-24 00:36:00 +01:00
|
|
|
|
if quiet {
|
|
|
|
|
log.EnableQuiet()
|
2017-02-15 09:31:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 20:21:58 +01:00
|
|
|
|
minioMode := ""
|
|
|
|
|
older, downloadURL, err := getUpdateInfo(10*time.Second, minioMode)
|
2017-02-15 09:31:00 +01:00
|
|
|
|
if err != nil {
|
2017-03-24 00:36:00 +01:00
|
|
|
|
log.Println(err)
|
2017-02-15 09:31:00 +01:00
|
|
|
|
os.Exit(-1)
|
|
|
|
|
}
|
2016-11-28 21:15:36 +01:00
|
|
|
|
|
2017-05-31 18:22:00 +02:00
|
|
|
|
if updateMsg := computeUpdateMessage(downloadURL, older); updateMsg != "" {
|
|
|
|
|
log.Println(updateMsg)
|
2017-02-15 09:31:00 +01:00
|
|
|
|
os.Exit(1)
|
2016-11-24 00:48:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 09:31:00 +01:00
|
|
|
|
colorSprintf := color.New(color.FgGreen, color.Bold).SprintfFunc()
|
2017-03-24 00:36:00 +01:00
|
|
|
|
log.Println(colorSprintf("You are already running the most recent version of ‘minio’."))
|
2017-02-15 09:31:00 +01:00
|
|
|
|
os.Exit(0)
|
2015-10-18 00:03:46 +02:00
|
|
|
|
}
|