mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
🏗 Fix Homebrew Permissions (#86)
This commit is contained in:
@ -1218,7 +1218,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 560;
|
CURRENT_PROJECT_VERSION = 580;
|
||||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = phpmon/Info.plist;
|
INFOPLIST_FILE = phpmon/Info.plist;
|
||||||
@ -1227,8 +1227,8 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||||
MARKETING_VERSION = 5.0;
|
MARKETING_VERSION = 5.1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.beta;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@ -1243,7 +1243,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 560;
|
CURRENT_PROJECT_VERSION = 580;
|
||||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
INFOPLIST_FILE = phpmon/Info.plist;
|
INFOPLIST_FILE = phpmon/Info.plist;
|
||||||
@ -1252,8 +1252,8 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||||
MARKETING_VERSION = 5.0;
|
MARKETING_VERSION = 5.1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.beta;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
|
@ -34,17 +34,42 @@ class Actions {
|
|||||||
brew("services stop dnsmasq", sudo: true)
|
brew("services stop dnsmasq", sudo: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static func fixHomebrewPermissions()
|
||||||
Kindly asks Valet to switch to a specific PHP version.
|
{
|
||||||
*/
|
var servicesCommands = [
|
||||||
public static func switchToPhpVersionUsingValet(
|
"\(Paths.brew) services stop nginx",
|
||||||
version: String,
|
"\(Paths.brew) services stop dnsmasq",
|
||||||
availableVersions: [String],
|
]
|
||||||
completed: @escaping () -> Void
|
var cellarCommands = [
|
||||||
) {
|
"chown -R \(Paths.whoami):staff \(Paths.cellarPath)/nginx",
|
||||||
Log.info("Switching to \(version) using Valet")
|
"chown -R \(Paths.whoami):staff \(Paths.cellarPath)/dnsmasq"
|
||||||
Log.info(valet("use php@\(version)"))
|
]
|
||||||
completed()
|
|
||||||
|
PhpEnv.shared.availablePhpVersions.forEach { version in
|
||||||
|
let formula = version == PhpEnv.brewPhpVersion
|
||||||
|
? "php"
|
||||||
|
: "php@\(version)"
|
||||||
|
servicesCommands.append("\(Paths.brew) services stop \(formula)")
|
||||||
|
cellarCommands.append("chown -R \(Paths.whoami):staff \(Paths.cellarPath)/\(formula)")
|
||||||
|
}
|
||||||
|
|
||||||
|
let script =
|
||||||
|
servicesCommands.joined(separator: " && ")
|
||||||
|
+ " && "
|
||||||
|
+ cellarCommands.joined(separator: " && ")
|
||||||
|
|
||||||
|
let appleScript = NSAppleScript(
|
||||||
|
source: "do shell script \"\(script)\" with administrator privileges"
|
||||||
|
)
|
||||||
|
|
||||||
|
let eventResult: NSAppleEventDescriptor? = appleScript?.executeAndReturnError(nil)
|
||||||
|
|
||||||
|
if (eventResult == nil) {
|
||||||
|
print("Oh no, that didn't work.")
|
||||||
|
} else {
|
||||||
|
NotificationCenter.default.post(name: Events.ServicesUpdated, object: nil)
|
||||||
|
print("Oh, that worked.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Finding Config Files
|
// MARK: - Finding Config Files
|
||||||
|
@ -48,6 +48,10 @@ public class Paths {
|
|||||||
return shared.userName
|
return shared.userName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static var cellarPath: String {
|
||||||
|
return "\(shared.baseDir.rawValue)/Cellar"
|
||||||
|
}
|
||||||
|
|
||||||
public static var binPath: String {
|
public static var binPath: String {
|
||||||
return "\(shared.baseDir.rawValue)/bin"
|
return "\(shared.baseDir.rawValue)/bin"
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,10 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
|
|||||||
|
|
||||||
// MARK: - Actions
|
// MARK: - Actions
|
||||||
|
|
||||||
|
@objc func fixHomebrewPermissions() {
|
||||||
|
Actions.fixHomebrewPermissions()
|
||||||
|
}
|
||||||
|
|
||||||
@objc func restartPhpFpm() {
|
@objc func restartPhpFpm() {
|
||||||
waitAndExecute {
|
waitAndExecute {
|
||||||
Actions.restartPhpFpm()
|
Actions.restartPhpFpm()
|
||||||
|
@ -51,9 +51,13 @@ class StatusMenu : NSMenu {
|
|||||||
} else {
|
} else {
|
||||||
servicesMenu.addItem(NSMenuItem(
|
servicesMenu.addItem(NSMenuItem(
|
||||||
title: "mi_fix_my_valet".localized(PhpEnv.brewPhpVersion),
|
title: "mi_fix_my_valet".localized(PhpEnv.brewPhpVersion),
|
||||||
action: #selector(MainMenu.fixMyValet), keyEquivalent: "f"))
|
action: #selector(MainMenu.fixMyValet), keyEquivalent: ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
servicesMenu.addItem(NSMenuItem(
|
||||||
|
title: "mi_fix_brew_permissions".localized(),
|
||||||
|
action: #selector(MainMenu.fixHomebrewPermissions), keyEquivalent: ""))
|
||||||
|
|
||||||
servicesMenu.addItem(NSMenuItem(title: "mi_services".localized, action: nil, keyEquivalent: ""))
|
servicesMenu.addItem(NSMenuItem(title: "mi_services".localized, action: nil, keyEquivalent: ""))
|
||||||
|
|
||||||
servicesMenu.addItem(NSMenuItem(title: "mi_restart_dnsmasq".localized, action: #selector(MainMenu.restartDnsMasq), keyEquivalent: "d"))
|
servicesMenu.addItem(NSMenuItem(title: "mi_restart_dnsmasq".localized, action: #selector(MainMenu.restartDnsMasq), keyEquivalent: "d"))
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
"mi_stop_all_services" = "Stop All Services";
|
"mi_stop_all_services" = "Stop All Services";
|
||||||
"mi_fix_my_valet" = "Fix My Valet (PHP & Services)";
|
"mi_fix_my_valet" = "Fix My Valet (PHP & Services)";
|
||||||
"mi_fix_my_valet_unavailable" = "Fix My Valet Unavailable";
|
"mi_fix_my_valet_unavailable" = "Fix My Valet Unavailable";
|
||||||
|
"mi_fix_brew_permissions" = "Fix Homebrew Permissions";
|
||||||
"mi_php_refresh" = "Refresh Information";
|
"mi_php_refresh" = "Refresh Information";
|
||||||
|
|
||||||
"mi_configuration" = "PHP Configuration";
|
"mi_configuration" = "PHP Configuration";
|
||||||
|
Reference in New Issue
Block a user