Skip to content

Commit

Permalink
feat: Add compatibility with moonraker update manager (#54)
Browse files Browse the repository at this point in the history
Co-authored-by: Ayrton Ricardo <[email protected]>
  • Loading branch information
AyrtonRicardo and Ayrton Ricardo authored Jul 6, 2023
1 parent 05f384e commit 9ffd7e7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
28 changes: 22 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
USER = $(shell whoami)
SYSTEMD = /etc/systemd/system
BIN_PATH = /usr/local/bin
CONF_PATH = /home/$(USER)/printer_data/config
PRINTER_DATA_PATH = /home/$(USER)/printer_data
CONF_PATH = $(PRINTER_DATA_PATH)/config

all:
$(MAKE) help
Expand All @@ -20,28 +21,43 @@ install: ## Install Spyglass as service
@printf "\nCopying systemd service file ...\n"
@sudo cp -f "${PWD}/resources/spyglass.service" $(SYSTEMD)
@sudo sed -i "s/%USER%/$(USER)/g" $(SYSTEMD)/spyglass.service
@printf "\nCopying spyglass launch script ...\n"
@printf "\nCopying Spyglass launch script ...\n"
@sudo ln -sf "${PWD}/scripts/spyglass" $(BIN_PATH)
@printf "\nCopying basic configuration file ...\n"
@cp -f "${PWD}/resources/spyglass.conf" $(CONF_PATH)
@printf "\nPopulate new service file ... \n"
@sudo systemctl daemon-reload
@printf "\nEnable spyglass service ... \n"
@sudo echo "spyglass" >> $(PRINTER_DATA_PATH)/moonraker.asvc
@printf "\nEnable Spyglass service ... \n"
@sudo systemctl enable spyglass
@printf "\nTo be sure, everything is setup please reboot ...\n"
@printf "Thanks for choosing spyglass ...\n"
@printf "Thanks for choosing Spyglass ...\n"

uninstall: ## Uninstall Spyglass
@printf "\nDisable spyglass service ... \n"
@printf "\nDisable Spyglass service ... \n"
@sudo systemctl disable spyglass
@printf "\nRemove systemd service file ...\n"
@sudo rm -f $(SYSTEMD)/spyglass.service
@printf "\nRemoving spyglass launch script ...\n"
@printf "\nRemoving Spyglass launch script ...\n"
@sudo rm -f $(BIN_PATH)/spyglass
@sudo sed '/spyglass/d' $(PRINTER_DATA_PATH)/moonraker.asvc > $(PRINTER_DATA_PATH)/moonraker.asvc

update: ## Update Spyglass (via git Repository)
@git fetch && git pull

upgrade-moonraker: ## In case of old version of Spyglass being upgraded to newer version with Moonraker update manager compatibility
@printf "Upgrading systemctl ...\n"
@sudo cp -f "${PWD}/resources/spyglass.service" $(SYSTEMD)
@sudo sed -i "s/%USER%/$(USER)/g" $(SYSTEMD)/spyglass.service
@printf "Saving backup of moonraker.asvc file as %s ...\n" $(PRINTER_DATA_PATH)/moonraker.asvc.bak
@sudo cp -f $(PRINTER_DATA_PATH)/moonraker.asvc $(PRINTER_DATA_PATH)/moonraker.asvc.bak
@printf "Upgrading Moonraker update manager authorization ...\n"
@sudo sed -i '/spyglass/d' $(PRINTER_DATA_PATH)/moonraker.asvc
@sudo echo "spyglass" >> $(PRINTER_DATA_PATH)/moonraker.asvc
@printf "You can now include the configuration in moonraker.conf to manage Spyglass updates ...\n"
@printf "Upgrade completed ...\n"
@printf "Thanks for choosing Spyglass ...\n"

help: ## Show this help
@printf "\nSpyglass Install Helper:\n"
@grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ cd ~/spyglass
make uninstall
```

#### Using Moonraker Update Manager

To be able to use Moonraker update manager, add the following lines to moonraker.conf:

```conf
[update_manager spyglass]
type: git_repo
channel: beta
path: ~/spyglass
origin: https://github.com/roamingthings/spyglass.git
managed_services: spyglass
```
> Make sure moonraker.asvc contains `spyglass` in the list: `cat ~/printer_data/moonraker.asvc | grep spyglass`.
>
> If not there execute: `make upgrade-moonraker`
### Configuration

You should find a configuration file in `~/printer_data/config/spyglass.conf`.
Expand Down

0 comments on commit 9ffd7e7

Please sign in to comment.