Keep mc specific at '.minio/mc', avoid sudo and root installs

This commit is contained in:
Harshavardhana
2015-03-05 02:27:19 -08:00
parent ef9b98b17c
commit 593ef59999
12 changed files with 39 additions and 36 deletions
+5 -1
View File
@@ -9,7 +9,6 @@ createsymlink:
getdeps: checkdeps
@go get github.com/tools/godep && echo "Installed godep"
@go get golang.org/x/tools/cmd/cover && echo "Installed cover"
build-all: getdeps createsymlink
@echo "Building Libraries"
@@ -25,3 +24,8 @@ docs-deploy:
install: test-all
@godep go install github.com/minio-io/mc && echo "Installed mc"
@mkdir -p $(HOME)/.minio/mc
@cp mc.completion $(HOME)/.minio/mc && echo "Installing mc bash completion"
uninstall:
@echo "Uninstalling mc bash completion" && rm -f $(HOME)/.minio/mc/mc.completion
+9 -2
View File
@@ -41,6 +41,13 @@ GLOBAL OPTIONS:
[Contribute to mc](./CONTRIBUTING.md)
### Bash Completion
### Enable bash completion
[Enable bash completion](./command-completion/README.md)
Edit your ``${HOME}/.bashrc`` file
```
source ${HOME}/.minio/mc/mc.completion
$ mc <TAB><TAB>
configure cp h help ls mb sync
```
-6
View File
@@ -1,6 +0,0 @@
install:
mkdir -p /etc/bash_completion.d
cp mc.bash /etc/bash_completion.d/mc
uninstall:
rm -f /etc/bash_completion.d/mc
-13
View File
@@ -1,13 +0,0 @@
This file is not moved to ``/etc/bash_completion.d/`` with the source installation.
Please execute following explicity from here to move this file to ``/etc/bash_completion.d``
```
$ sudo make install
```
Similarly, execute following to remove it from /etc/bash_completion.d
```
$ sudo make uninstall
```
+8 -2
View File
@@ -26,12 +26,18 @@ import (
"github.com/minio-io/mc/pkg/s3"
)
// Common authentication file
const (
auth = "auth.json"
mcDir = "/.minio/mc/"
)
func getAuthFilePath() (string, error) {
u, err := user.Current()
if err != nil {
return "", err
}
return path.Join(u.HomeDir, Auth), nil
return path.Join(u.HomeDir+mcDir, auth), nil
}
func getNewClient(auth *s3.Auth) (*s3.Client, error) {
@@ -41,7 +47,7 @@ func getNewClient(auth *s3.Auth) (*s3.Client, error) {
}, nil
}
func getAWSEnvironment() (auth *s3.Auth, err error) {
func getEnvironment() (auth *s3.Auth, err error) {
var s3Auth *os.File
var accessKey, secretKey, endpoint string
+13 -3
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"os/user"
"path"
"github.com/codegangsta/cli"
@@ -52,8 +53,17 @@ func doConfigure(c *cli.Context) {
}
var s3File *os.File
home := os.Getenv("HOME")
s3File, err = os.OpenFile(path.Join(home, Auth), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
u, _ := user.Current()
err = os.MkdirAll(path.Join(u.HomeDir, mcDir), 0755)
if err != nil {
log.Fatal(err)
}
var authFile string
authFile, err = getAuthFilePath()
if err != nil {
log.Fatal(err)
}
s3File, err = os.OpenFile(authFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
defer s3File.Close()
if err != nil {
log.Fatal(err)
@@ -63,5 +73,5 @@ func doConfigure(c *cli.Context) {
log.Fatal(err)
}
fmt.Println("")
fmt.Println("Configuration written to", path.Join(home, Auth))
fmt.Println("Configuration written to", authFile)
}
+1 -1
View File
@@ -91,7 +91,7 @@ func doFsCopy(c *cli.Context) {
var s3c *s3.Client
var err error
var bodyFile *os.File
auth, err = getAWSEnvironment()
auth, err = getEnvironment()
if err != nil {
log.Fatal(err)
}
+1 -1
View File
@@ -97,7 +97,7 @@ func doFsList(c *cli.Context) {
var items []*s3.Item
var prefixes []*s3.Prefix
auth, err = getAWSEnvironment()
auth, err = getEnvironment()
if err != nil {
log.Fatal(err)
}
+1 -1
View File
@@ -36,7 +36,7 @@ func doFsMb(c *cli.Context) {
var err error
var auth *s3.Auth
var s3c *s3.Client
auth, err = getAWSEnvironment()
auth, err = getEnvironment()
if err != nil {
log.Fatal(err)
}
-5
View File
@@ -95,8 +95,3 @@ var options = []cli.Command{
sync,
configure,
}
// Common authentication file
const (
Auth = ".minio/auth.json"
)
+1 -1
View File
@@ -69,7 +69,7 @@ func doFsSync(c *cli.Context) {
var auth *s3.Auth
var s3c *s3.Client
var err error
auth, err = getAWSEnvironment()
auth, err = getEnvironment()
if err != nil {
log.Fatal(err)
}