1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 12:00:09 +02:00

🐛 Fix generated script (#231)

This commit is contained in:
2023-02-06 19:09:14 +01:00
parent 147407666d
commit 412b7bad5c
2 changed files with 15 additions and 10 deletions

View File

@ -13,21 +13,21 @@ class Actions {
// MARK: - Services // MARK: - Services
public static func restartPhpFpm() async { public static func restartPhpFpm() async {
await brew("services restart \(Homebrew.Formulae.php.name)", sudo: Homebrew.Formulae.php.elevated) await brew("services restart \(Homebrew.Formulae.php)", sudo: Homebrew.Formulae.php.elevated)
} }
public static func restartNginx() async { public static func restartNginx() async {
await brew("services restart \(Homebrew.Formulae.nginx.name)", sudo: Homebrew.Formulae.nginx.elevated) await brew("services restart \(Homebrew.Formulae.nginx)", sudo: Homebrew.Formulae.nginx.elevated)
} }
public static func restartDnsMasq() async { public static func restartDnsMasq() async {
await brew("services restart \(Homebrew.Formulae.dnsmasq.name)", sudo: Homebrew.Formulae.dnsmasq.elevated) await brew("services restart \(Homebrew.Formulae.dnsmasq)", sudo: Homebrew.Formulae.dnsmasq.elevated)
} }
public static func stopValetServices() async { public static func stopValetServices() async {
await brew("services stop \(Homebrew.Formulae.php.name)", sudo: Homebrew.Formulae.php.elevated) await brew("services stop \(Homebrew.Formulae.php)", sudo: Homebrew.Formulae.php.elevated)
await brew("services stop \(Homebrew.Formulae.nginx.name)", sudo: Homebrew.Formulae.nginx.elevated) await brew("services stop \(Homebrew.Formulae.nginx)", sudo: Homebrew.Formulae.nginx.elevated)
await brew("services stop \(Homebrew.Formulae.dnsmasq.name)", sudo: Homebrew.Formulae.dnsmasq.elevated) await brew("services stop \(Homebrew.Formulae.dnsmasq)", sudo: Homebrew.Formulae.dnsmasq.elevated)
} }
public static func fixHomebrewPermissions() throws { public static func fixHomebrewPermissions() throws {
@ -54,9 +54,10 @@ class Actions {
+ " && " + " && "
+ cellarCommands.joined(separator: " && ") + cellarCommands.joined(separator: " && ")
let appleScript = NSAppleScript( let source = "do shell script \"\(script)\" with administrator privileges"
source: "do shell script \"\(script)\" with administrator privileges"
) Log.perf(source)
let appleScript = NSAppleScript(source: source)
let eventResult: NSAppleEventDescriptor? = appleScript?.executeAndReturnError(nil) let eventResult: NSAppleEventDescriptor? = appleScript?.executeAndReturnError(nil)

View File

@ -36,10 +36,14 @@ class Homebrew {
} }
} }
class HomebrewFormula: Equatable, Hashable { class HomebrewFormula: Equatable, Hashable, CustomStringConvertible {
let name: String let name: String
let elevated: Bool let elevated: Bool
var description: String {
return name
}
init(_ name: String, elevated: Bool = true) { init(_ name: String, elevated: Bool = true) {
self.name = name self.name = name
self.elevated = elevated self.elevated = elevated