Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #6 from trueos/fix-5
Browse files Browse the repository at this point in the history
Fix an issue with crash on stage2 update
  • Loading branch information
kmoore134 authored Dec 6, 2018
2 parents 2a9b6bb + 273e8f5 commit c3ffd3f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ sysup allows for the possibility of offline updates via an image file containing

### Additional Update Options
These arguments are add-ons for the "-update" argument and are typically not needed for standard use
- **-disablebootstrap**
- Skip the update of SysUp port. This is used for running locally built SysUp and testing.
- **-bename NAME**
- Use "NAME" for the new boot environment that will be created.
- A boot environment with "NAME" must *not* already exist, otherwise sysup will return an error.
Expand Down
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func startupdate() {
Method: "update",
Fullupdate: fullupdateflag,
Bename: benameflag,
Disablebs: disablebsflag,
Updatefile: updatefileflag,
}

Expand Down
3 changes: 3 additions & 0 deletions defines.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var STAGEDIR = "/.updatestage"
var benameflag string
var changetrainflag string
var checkflag bool
var disablebsflag bool
var fullupdateflag bool
var listtrainflag bool
var stage2flag bool
Expand All @@ -67,6 +68,7 @@ var updatekeyflag string
var websocketflag bool
func init() {
flag.BoolVar(&checkflag, "check", false, "Check system status")
flag.BoolVar(&disablebsflag, "disablebootstrap", false, "Disable bootstrap of sysup package on upgrade")
flag.BoolVar(&updateflag, "update", false, "Update to latest packages")
flag.BoolVar(&listtrainflag, "list-trains", false, "List available trains (if configured)")
flag.StringVar(&changetrainflag, "change-train", "", "Change to the specifed new train")
Expand Down Expand Up @@ -162,6 +164,7 @@ type UpdateInfo struct {
type SendReq struct {
Method string `json:"method"`
Bename string `json:"bename"`
Disablebs bool `json:"disablebs"`
Fullupdate bool `json:"fullupdate"`
Train string `json:"train"`
Updatefile string `json:"updatefile"`
Expand Down
5 changes: 4 additions & 1 deletion doupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func doupdate(message []byte) {

fullupdateflag = s.Fullupdate
benameflag = s.Bename
disablebsflag = s.Disablebs
updatefileflag = s.Updatefile
updatekeyflag = s.Updatekey
//log.Println("benameflag: " + benameflag)
Expand Down Expand Up @@ -108,7 +109,9 @@ func doupdate(message []byte) {

// If we have a sysup package we intercept here, do boot-strap and
// Then restart the update with the fresh binary on a new port
if ( details.SysUp) {
//
// Skip if the disablebsflag is set
if ( details.SysUp && disablebsflag != true) {
dosysupbootstrap()
dopassthroughupdate()
return
Expand Down
15 changes: 13 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ func closews() {
}

func checkuid() {
user, _ := user.Current()
user, err := user.Current()
if ( err != nil ) {
fmt.Println(err)
fmt.Println("Failed getting user.Current()")
os.Exit(1)
return
}
if ( user.Uid != "0" ) {
fmt.Println("ERROR: Must be run as root")
os.Exit(1)
Expand All @@ -101,7 +107,12 @@ func checkuid() {

func main() {

checkuid()
// Can skip if doing stage2 of update
// For some reason this fails on some systems when trying to get the current user
// possibly due to / not being writable?
if ( ! stage2flag ) {
checkuid()
}

if len(os.Args) == 1 {
flag.Usage()
Expand Down

0 comments on commit c3ffd3f

Please sign in to comment.