Update Makefile and cbattery
This commit is contained in:
parent
b379f3bc79
commit
205318dd24
34
Makefile
34
Makefile
|
@ -1,34 +1,36 @@
|
||||||
SUDOERSDIR = /private/etc/sudoers.d
|
|
||||||
INSTALL_PATH_CBATTERY = $(DESTDIR)/cbattery
|
|
||||||
INSTALL_PATH_VISUDO = $(SUDOERSDIR)/cbattery
|
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
DESTDIR = $(PREFIX)/bin
|
DESTDIR = $(PREFIX)/bin
|
||||||
|
INSTALL_PATH = $(DESTDIR)/cbattery
|
||||||
|
|
||||||
all: install
|
all: install
|
||||||
|
|
||||||
install: $(INSTALL_PATH_CBATTERY) $(INSTALL_PATH_VISUDO)
|
install: $(INSTALL_PATH)
|
||||||
|
|
||||||
$(INSTALL_PATH_VISUDO): .visudo
|
$(INSTALL_PATH): cbattery
|
||||||
@echo "Installing visudo file to $(SUDOERSDIR)"
|
|
||||||
@if ! test -d "$(SUDOERSDIR)"; then \
|
|
||||||
sudo mkdir -p "$(SUDOERSDIR)"; \
|
|
||||||
fi
|
|
||||||
@sudo cp $< $(SUDOERSDIR)/cbattery
|
|
||||||
@sudo chmod 440 $(SUDOERSDIR)/cbattery
|
|
||||||
|
|
||||||
$(INSTALL_PATH_CBATTERY): cbattery
|
|
||||||
@echo "Installing cbattery to $(DESTDIR)"
|
@echo "Installing cbattery to $(DESTDIR)"
|
||||||
@install -m 755 $< $(DESTDIR)
|
@install -m 755 $< $(DESTDIR)
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo "Removing cbattery from $(DESTDIR)"
|
@echo "Removing cbattery from $(DESTDIR)"
|
||||||
@cbattery uninstall || (echo "Uninstalling cbattery failed"; exit 1)
|
@$(DESTDIR)/cbattery uninstall || (echo "Uninstalling cbattery failed"; exit 1)
|
||||||
@rm -f $(INSTALL_PATH_CBATTERY) $(INSTALL_PATH_SMC)
|
@rm -f $(INSTALL_PATH)
|
||||||
|
|
||||||
|
SUDOERSDIR = /private/etc/sudoers.d/cbattery
|
||||||
|
|
||||||
|
visudo: .visudo
|
||||||
|
@echo "Installing visudo file to $(SUDOERSDIR)"
|
||||||
|
@if ! test -d "$(SUDOERSDIR)"; then \
|
||||||
|
mkdir -p "$(SUDOERSDIR)"; \
|
||||||
|
fi
|
||||||
|
@cp $< $(SUDOERSDIR)/cbattery
|
||||||
|
@chmod 440 $(SUDOERSDIR)/cbattery
|
||||||
|
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Available targets:"
|
@echo "Available targets:"
|
||||||
@echo " make install - Install cbattery to $(DESTDIR)"
|
@echo " make install - Install cbattery to $(DESTDIR)"
|
||||||
@echo " make uninstall - Remove cbattery from $(DESTDIR)"
|
@echo " make uninstall - Remove cbattery from $(DESTDIR)"
|
||||||
|
@echo " make visudo - Install visudo file to $(SUDOERSDIR)"
|
||||||
@echo " make help - Show this help message"
|
@echo " make help - Show this help message"
|
||||||
|
|
||||||
.PHONY: all install uninstall help
|
.PHONY: all install uninstall visudo help
|
||||||
|
|
4
cbattery
4
cbattery
|
@ -8,7 +8,7 @@ usage: ${0##*/} [command]
|
||||||
charging [on|off] - Toggle charging
|
charging [on|off] - Toggle charging
|
||||||
adapter [on|off] - Toggle adapter connection
|
adapter [on|off] - Toggle adapter connection
|
||||||
status - Get status information
|
status - Get status information
|
||||||
uninstall - Revert to default settings
|
revert - Revert to default settings
|
||||||
help - Display this help message
|
help - Display this help message
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ if [ -z "$action" ] || [[ "$action" == "help" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$action" == "uninstall" ]]; then
|
if [[ "$action" == "revert" ]]; then
|
||||||
enable_charging
|
enable_charging
|
||||||
disable_discharging
|
disable_discharging
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue