Skip to content

Commit

Permalink
fix: apply required changes due to introduction of PolicyKit and Pack…
Browse files Browse the repository at this point in the history
…ageKit in Moonraker
  • Loading branch information
dw-0 committed Jan 29, 2022
1 parent 1682642 commit a14e321
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

This document covers possible important changes to KIAUH.

### 2022-01-29
* Starting from the 28th of January, Moonraker can make use of PackageKit and PolicyKit.\
More details on that can be found [here](
https://github.com/Arksine/moonraker/issues/349) and [here](https://github.com/Arksine/moonraker/pull/346)
* KIAUH will install Moonrakers PolicyKit rules by default when __installing__ Moonraker
* KIAUH will also install Moonrakers PolicyKit rules when __updating__ Moonraker __via KIAUH__ as of now

### 2021-12-30
* Updated the doc for the usage of the [G-Code Shell Command Extension](docs/gcode_shell_command.md)
* It became apparent, that some user groups are missing on some systems. A missing video group \
Expand Down
1 change: 1 addition & 0 deletions resources/moonraker.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ WantedBy=multi-user.target

[Service]
Type=simple
SupplementaryGroups=moonraker-admin
User=%USER%
RemainAfterExit=yes
ExecStart=%MR_ENV%/bin/python %MR_DIR%/moonraker/moonraker.py -l %MR_LOG% -c %MR_CONF%
Expand Down
22 changes: 22 additions & 0 deletions scripts/install_moonraker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ moonraker_setup(){
### step 4: create final moonraker instances
create_moonraker_service

### step 5: create polkit rules for moonraker
moonraker_polkit

### confirm message
if [[ $INSTANCE_COUNT -eq 1 ]]; then
CONFIRM_MSG="Moonraker has been set up!"
Expand Down Expand Up @@ -297,3 +300,22 @@ print_mr_ip_list(){
i=$((i + 1))
done
}

### introduced due to
### https://github.com/Arksine/moonraker/issues/349
### https://github.com/Arksine/moonraker/pull/346
moonraker_polkit(){
SYSTEMDDIR="/etc/systemd/system"
MOONRAKER_SERVICES=$(find "$SYSTEMDDIR" -regextype posix-extended -regex "$SYSTEMDDIR/moonraker(-[^0])?[0-9]*.service")
for service in $MOONRAKER_SERVICES; do
HAS_SUPP="$( grep -cm1 "SupplementaryGroups=moonraker-admin" "$service" || true )"
if [ "$HAS_SUPP" -eq 0 ]; then
status_msg "Adding moonraker-admin supplementary group to $service ..."
sudo sed -i "/^Type=simple$/a SupplementaryGroups=moonraker-admin" "$service" \
&& ok_msg "Adding moonraker-admin supplementary group successfull!"
fi
done
### execute moonrakers policykit-rules script
"${HOME}"/moonraker/scripts/set-policykit-rules.sh
sudo systemctl daemon-reload
}
8 changes: 6 additions & 2 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,17 @@ update_moonraker(){
bb4u "moonraker"
status_msg "Updating Moonraker ..."
### pull latest files from github
cd $MOONRAKER_DIR && git pull
cd "$MOONRAKER_DIR" && git pull
### read PKGLIST and install possible new dependencies
install_moonraker_packages
### install possible new python dependencies
MR_REQ_TXT="$MOONRAKER_DIR/scripts/moonraker-requirements.txt"
$MOONRAKER_ENV/bin/pip install -r $MR_REQ_TXT
"$MOONRAKER_ENV"/bin/pip install -r "$MR_REQ_TXT"
update_log_paths "moonraker"

### required due to https://github.com/Arksine/moonraker/issues/349
moonraker_polkit

ok_msg "Update complete!"
do_action_service "restart" "moonraker"
}
Expand Down

0 comments on commit a14e321

Please sign in to comment.