Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2615)

Side by Side Diff: upgrades/dotprofile.go

Issue 78660043: Add upgrade job for ~ubuntu/.profile
Patch Set: Add upgrade job for ~ubuntu/.profile Created 11 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « [revision details] ('k') | upgrades/dotprofile_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details.
3
4 package upgrades
5
6 import (
7 "fmt"
8
9 "launchpad.net/juju-core/utils/exec"
10 )
11
12 // As of the middle of the 1.17 cycle, the proxy settings are written out to
13 // /home/ubuntu/.juju-proxy both by cloud-init and the machine environ worker.
14 // An older version of juju that has been upgraded will get the proxy settings
15 // written out to the .juju-proxy file, but the .profile for the ubuntu user
16 // wouldn't have been updated to source this file.
17 //
18 // This upgrade step is to add the line to source the file if it is missing
19 // from the file.
20 func ensureUbuntuDotProfileSourcesProxyFile(context Context) error {
21 // We look to see if the proxy line is there already as the manual
22 // provider may have had it aleady. The ubuntu user may not exist
23 // (local provider only).
24 command := fmt.Sprintf(""+
25 `([ ! -e %s/.profile ] || grep -q '.juju-proxy' %s/.profile) || `+
26 `printf '\n# Added by juju\n[ -f "$HOME/.juju-proxy" ] && . "$HO ME/.juju-proxy"\n' >> %s/.profile`,
27 ubuntuHome, ubuntuHome, ubuntuHome)
28 logger.Tracef("command: %s", command)
29 result, err := exec.RunCommands(exec.RunParams{
30 Commands: command,
31 })
32 if err != nil {
33 return err
34 }
35 logger.Tracef("stdout: %s", result.Stdout)
36 return nil
37 }
OLDNEW
« no previous file with comments | « [revision details] ('k') | upgrades/dotprofile_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b