mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
cmd: upgrade: resolve symlink of the executable (#5891)
This commit is contained in:
parent
1f60328e17
commit
d70608b656
1 changed files with 10 additions and 0 deletions
|
@ -22,6 +22,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
@ -103,6 +104,15 @@ func upgradeBuild(pluginPkgs map[string]struct{}, fl Flags) (int, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return caddy.ExitCodeFailedStartup, fmt.Errorf("retrieving current executable permission bits: %v", err)
|
return caddy.ExitCodeFailedStartup, fmt.Errorf("retrieving current executable permission bits: %v", err)
|
||||||
}
|
}
|
||||||
|
if thisExecStat.Mode()&os.ModeSymlink == os.ModeSymlink {
|
||||||
|
symSource := thisExecPath
|
||||||
|
// we are a symlink; resolve it
|
||||||
|
thisExecPath, err = filepath.EvalSymlinks(thisExecPath)
|
||||||
|
if err != nil {
|
||||||
|
return caddy.ExitCodeFailedStartup, fmt.Errorf("resolving current executable symlink: %v", err)
|
||||||
|
}
|
||||||
|
l.Info("this executable is a symlink", zap.String("source", symSource), zap.String("target", thisExecPath))
|
||||||
|
}
|
||||||
l.Info("this executable will be replaced", zap.String("path", thisExecPath))
|
l.Info("this executable will be replaced", zap.String("path", thisExecPath))
|
||||||
|
|
||||||
// build the request URL to download this custom build
|
// build the request URL to download this custom build
|
||||||
|
|
Loading…
Reference in a new issue