update
This commit is contained in:
parent
667b057a19
commit
f4635a5463
2 changed files with 7 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
|
@ -21,16 +22,7 @@ func checkExists(path string) (bool, error) {
|
|||
}
|
||||
|
||||
func Info() {
|
||||
// A SAMPLE COMMAND FOR LOGGING OS INFORMATION TO A DEDICATED FILE
|
||||
userhome, err := os.UserHomeDir() // TODO $HOME is not defined while running as daemon !!!
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// userhome := "/home/asandikci" // TEMPORARY
|
||||
configDir := userhome + "/.config/" + ProgramName + "/"
|
||||
// TODO Will be replaced with a Go Config Library
|
||||
log.Print(configDir)
|
||||
configDir := "/etc/godaemon1/"
|
||||
if flag, err := checkExists(configDir); flag {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -44,6 +36,10 @@ func Info() {
|
|||
}{
|
||||
{"OS", runtime.GOOS},
|
||||
{"Time", time.Now().Format("2006.01.02 15:04:05")},
|
||||
{"Go Root", runtime.GOROOT()},
|
||||
{"Go Version", runtime.Version()},
|
||||
{"Go Arch", runtime.GOARCH},
|
||||
{"CPU Num", fmt.Sprintf("%v", runtime.NumCPU())},
|
||||
}
|
||||
|
||||
f, err := os.Create(configDir + "godaemon1.conf")
|
||||
|
|
|
@ -23,7 +23,7 @@ sudo touch /etc/godaemon1/userdata.conf
|
|||
sudo cat << EOF | sudo tee -a /etc/godaemon1/userdata.conf > /dev/null
|
||||
The current working directory is: $PWD
|
||||
You are logged in as $(whoami)
|
||||
$HOME | $USER | $SUDO_USER
|
||||
$HOME $USER $SUDO_USER
|
||||
EOF
|
||||
sudo chown root:root /etc/godaemon1/userdata.conf
|
||||
sudo chmod 640 /etc/godaemon1/userdata.conf
|
||||
|
|
Loading…
Reference in a new issue