This repository was archived by the owner on May 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathlauncher_darwin.go
More file actions
78 lines (69 loc) · 2.31 KB
/
launcher_darwin.go
File metadata and controls
78 lines (69 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// Daemon for IVPN Client Desktop
// https://github.com/ivpn/desktop-app-daemon
//
// Created by Stelnykovych Alexandr.
// Copyright (c) 2020 Privatus Limited.
//
// This file is part of the Daemon for IVPN Client Desktop.
//
// The Daemon for IVPN Client Desktop is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any later version.
//
// The Daemon for IVPN Client Desktop is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License
// along with the Daemon for IVPN Client Desktop. If not, see <https://www.gnu.org/licenses/>.
//
package main
import (
"fmt"
"os"
"path"
"github.com/ivpn/desktop-app-daemon/shell"
)
// Prepare to start IVPN daemon for macOS
func doPrepareToRun() error {
// create symlink to 'ivpn' cli client
binFolder := "/usr/local/bin" // "/usr/local/bin"
linkpath := path.Join(binFolder, "ivpn") // "/usr/local/bin/ivpn"
if _, err := os.Stat(linkpath); os.IsNotExist(err) {
// "/usr/local/bin"
if _, err := os.Stat(binFolder); os.IsNotExist(err) {
log.Info(fmt.Sprintf("Folder '%s' not exists. Creating it...", binFolder))
if err = os.Mkdir(binFolder, 0775); err != nil {
log.Error(fmt.Sprintf("Failed to create folder '%s': ", binFolder), err)
}
}
// "/usr/local/bin/ivpn"
log.Info("Creating symlink to IVPN CLI: ", linkpath)
err := shell.Exec(log, "/bin/ln", "-fs", "/Applications/IVPN.app/Contents/MacOS/cli/ivpn", linkpath)
if err != nil {
log.Error("Failed to create symlink to IVPN CLI: ", err)
}
}
return nil
}
// inform OS-specific implementation about listener port
func doStartedOnPort(openedPort int, secret uint64) {
implStartedOnPort(openedPort, secret)
}
// OS-specific service finalizer
func doStopped() {
implStopped()
}
func isNeedToSavePortInFile() bool {
return true
}
// checkIsAdmin - check is application running with root privileges
func doCheckIsAdmin() bool {
uid := os.Geteuid()
if uid != 0 {
return false
}
return true
}