Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: run system updates as root, run user updates for each user #62

Merged
merged 72 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
0557d80
refactor: split up hardware checks, added memory c
gerblesh Sep 4, 2023
3248580
fix: formatting and errors
gerblesh Sep 4, 2023
85de3b3
fix(hardware.py): fixed memory check
gerblesh Sep 4, 2023
35a1c4f
fix: change default max_mem_percent to 90.0
gerblesh Sep 4, 2023
44af2b9
chore(deps): bump sigstore/cosign-installer from 3.1.1 to 3.1.2
dependabot[bot] Sep 4, 2023
1cdc0f3
chore(main): release 1.2.1
github-actions[bot] Sep 4, 2023
e8f590e
docs: update README
gerblesh Sep 5, 2023
72bd8ca
docs: fix typo in README
gerblesh Sep 5, 2023
54d92a8
fix: remove typo in arguments for notify-send
gerblesh Sep 5, 2023
8d683ad
feat: initial work for running system updates as root, and updates fo…
gerblesh Sep 7, 2023
0b54496
fix: add root requirement for running updates
gerblesh Sep 7, 2023
03a70eb
fix: remove home directory configuration, ublue-update is now system-…
gerblesh Sep 7, 2023
936db3f
chore: move to system service, update spec file and config
gerblesh Sep 7, 2023
ab866af
chore: remove debug print statements
gerblesh Sep 7, 2023
697a986
feat: added --user and --system flags
gerblesh Sep 7, 2023
7856d98
fix: reformat to please the formatting gods
gerblesh Sep 7, 2023
3fcefb1
fix: update shellcheck path in RPM spec
gerblesh Sep 8, 2023
e99bb03
chore: remove unneeded python deps
gerblesh Sep 8, 2023
ac6cf00
fix: added sudo as a dependency
gerblesh Sep 8, 2023
5a97220
docs: add note about rpm-ostreed config from ublue-os/config
gerblesh Sep 8, 2023
bdc19c5
fix: use less sudo, clean up process ee
gerblesh Sep 8, 2023
0dcd2e9
chore: remove useless --user flag
gerblesh Sep 8, 2023
5a28f1f
fix: don't run sudo for each script, fixed string formatting
gerblesh Sep 8, 2023
451e33c
fix: fix python errors
gerblesh Sep 11, 2023
5b54c9a
style: fix formatting issues
gerblesh Sep 11, 2023
8d8ef28
fix: properly initialize env vars for notifications
gerblesh Sep 12, 2023
cb41a15
chore: add polkit rule to allow passwordless access (#65)
akdev1l Sep 12, 2023
5d77d74
fix: change environment variables when running ublue-update as user
gerblesh Sep 12, 2023
0e22e49
fix: reformat to please flake8
gerblesh Sep 12, 2023
2f38bf8
fix: update cli args for `sudo` to be in the correct order
gerblesh Sep 12, 2023
ef5d4e7
fix: use user_uid instead of process_uid, fixes user updates
gerblesh Sep 12, 2023
7fae539
fix: added { to please formatter
gerblesh Sep 12, 2023
e799b0a
fix: notify outside of for loop
gerblesh Sep 12, 2023
b40ed7a
fix: fixed user prompts when running as root
gerblesh Sep 12, 2023
2907793
fix: get active sessions with logind, use capture_output=True for sub…
gerblesh Sep 13, 2023
96586ee
fix: get xdg_runtime_dir through loginctl
gerblesh Sep 13, 2023
609e05c
docs(README): document user and system updates
gerblesh Sep 13, 2023
6f4a073
docs(README): document running from systemd
gerblesh Sep 13, 2023
6c167d0
fix: add proper error handling
gerblesh Sep 13, 2023
96ebf97
chore: log errors to console, switch to splitlines()
gerblesh Sep 13, 2023
75f2dd0
chore: improve error handling with `try:` statements
gerblesh Sep 13, 2023
439c80b
style: format to please flake8 checks
gerblesh Sep 13, 2023
b4c88db
docs(README): clear up documentation around system vs user updates
gerblesh Sep 13, 2023
442275b
docs:style: fix code block formatting, clear up wording
gerblesh Sep 13, 2023
ddffeef
docs(README): clear up wording
gerblesh Sep 13, 2023
bcf1167
docs(README): remove section about systemd-inhibit
gerblesh Sep 13, 2023
d9ca0fc
chore: add copr build so we are packaged in COPR
akdev1l Sep 8, 2023
7ef783c
fix: skip copr-build on PRs
akdev1l Sep 8, 2023
ff74a78
fix: make systemd service more robust
gerblesh Sep 13, 2023
c2f16ae
fix: revert systemd service changes
gerblesh Sep 13, 2023
9592dec
fix: make subprocess.run() statements not rely on $PATH
gerblesh Sep 13, 2023
5b9702a
feat: add pidlock, only run updates for active sessions
gerblesh Sep 14, 2023
729f656
chore: reformat
gerblesh Sep 14, 2023
28a6e9a
feat: add filelocking to make updates not run at the same time for sa…
gerblesh Sep 14, 2023
3300803
chore: make filelocking use logger
gerblesh Sep 14, 2023
8931502
chore: remove filelock from pyproject.toml
gerblesh Sep 14, 2023
3287b64
fix: format to please flake8
gerblesh Sep 14, 2023
b84e2e3
fix: use user['Name'] instead of user.pw_name
gerblesh Sep 15, 2023
19a97ed
docs(README): add troubleshooting section
gerblesh Sep 15, 2023
a5ce221
fix: formatted code, used f-strings for cmd args
gerblesh Sep 15, 2023
4fb47e9
chore: add debug print statements
gerblesh Sep 15, 2023
3ee6d7b
chore: add more debug print statements
gerblesh Sep 15, 2023
c0f0856
chore: remove error handling for debugging
gerblesh Sep 15, 2023
53d4b13
fix(session): Ensure session type exists before appending active session
EyeCantCU Sep 15, 2023
039f104
chore: remove check for key
gerblesh Sep 15, 2023
96bf4d3
chore: add more debug code
gerblesh Sep 15, 2023
086e027
fix: remove debug code, fixed crash because of keyerror with temporar…
gerblesh Sep 15, 2023
cad419a
chore: reformat with black
gerblesh Sep 15, 2023
652a29c
feat(systemd): timing changes
gerblesh Sep 15, 2023
37475fa
Merge branch 'main' into user-system-update
gerblesh Sep 15, 2023
bebeae4
chore: remove merge artifact
gerblesh Sep 15, 2023
53095c7
style: reformat with black
gerblesh Sep 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 53 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,82 @@ COPY --from=ghcr.io/ublue-os/ublue-update:latest /rpms/ublue-update.noarch.rpm /
RUN rpm-ostree override remove ublue-os-update-services && rpm-ostree install /tmp/rpms/ublue-update.noarch.rpm
```

> **Note**
> If you are on an image derived from uBlue main, you will need to remove or disable automatic updates with rpm-ostreed, to do this, you need to remove or change this line in the config file: `AutomaticUpdatePolicy=stage` (set to `none` if you don't want to remove the line)


## Command Line

To run a complete system update, it's recommended to use systemd:

```
$ systemctl start ublue-update.service
```

This allows for passwordless system updates (user must be in `wheel` group)


### Run updates from command line (not recommended)

Only run user updates (rootless):
```
$ ublue-update
```
usage: ublue-update [-h] [-f] [-c] [-u]

Only run system updates (requires root):
```
$ pkexec ublue-update --system
```

```
usage: ublue-update [-h] [-f] [-c] [-u] [-w] [--system]

options:
-h, --help show this help message and exit
-f, --force force manual update, skipping update checks
-c, --check run update checks and exit
-u, --updatecheck check for updates and exit
-w, --wait wait for transactions to complete and exit
--system only run system updates (requires root)
```

## Troubleshooting

You can check the ublue-update logs by running this command:
```
$ journalctl -exu 'ublue-update.service'
```

# Configuration

## Update Scripts
Update scripts are separated into two directories inside of `/etc/ublue-update.d`

### `/etc/ublue-update.d/user`

Update scripts are ran as user. Scripts included:
- per-user flatpak update scripts (uninstalling unused deps and repairing flatpak install for maintenence)
- distrobox update script
- fleek update script

### `/etc/ublue-update.d/system`

Update scripts are ran as root, these updates are meant to be system-wide. Scripts included:
- OS update script (depends on [`rpm-ostree`](https://github.com/coreos/rpm-ostree))
- system-wide flatpak update scripts (uninstalling unused deps and repairing flatpak install for maintenence)


## Location
valid config paths (in order of priority)

```"$HOME"/.config/ublue-update/ublue-update.toml```
### Valid config paths (in order of priority):

```/etc/ublue-update/ublue-update.toml```

```/usr/etc/ublue-update/ublue-update.toml```


## Config Variables
section: `checks`
Section: `checks`

`min_battery_percent`: checks if battery is above specified percent

Expand All @@ -62,7 +110,7 @@ section: `checks`
`max_mem_percent`: checks if memory usage is below specified the percent


section: `notify`
Section: `notify`

`dbus_notify`: enable graphical notifications via dbus

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/bash
#!/usr/bin/env bash

/usr/bin/rpm-ostree update
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/bash
#!/usr/bin/env bash

/usr/bin/flatpak --system update -y --noninteractive
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/bash

#!/usr/bin/env bash

/usr/bin/flatpak uninstall --system --unused -y --noninteractive
/usr/bin/flatpak repair --system
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/bash
#!/usr/bin/env bash

/usr/bin/flatpak --user update -y --noninteractive
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash


/usr/bin/flatpak uninstall --user --unused -y --noninteractive
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash

if [ -x /usr/bin/distrobox ]; then
/usr/bin/distrobox upgrade -a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash

if [ -x /var/usrlocal/bin/fleek ]; then
/var/usrlocal/bin/fleek update -a
Expand Down
8 changes: 8 additions & 0 deletions files/usr/etc/polkit-1/rules.d/ublue-update.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
polkit.addRule(function(action, subject) {
if (subject.isInGroup("wheel") &&
action.id == "org.freedesktop.systemd1.manage-units" &&
action.lookup("unit") == "ublue-update.service")
{
return polkit.Result.YES;
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
Description=Universal Blue Update Oneshot Service

[Service]
Restart=on-failure
RestartSec=1h
Type=oneshot
ExecStart=/usr/bin/ublue-update


Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ Description=Auto Update System Timer For Universal Blue
Wants=network-online.target

[Timer]
RandomizedDelaySec=10m
OnBootSec=2m
OnCalendar=*-*-* 4:00:00
OnBootSec=20min
OnUnitInactiveSec=6h
Persistent=true

[Install]
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ classifiers = [
]
dependencies = [
"psutil",
"pygobject",
"dbus-python",
]
dynamic = ["version"]

Expand Down
Loading