-
-
Notifications
You must be signed in to change notification settings - Fork 127
New custom-persist feature #551
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
Changes from 14 commits
1d16aea
6e7bed0
2ac91d7
91d312a
ec86885
8042e29
e5209c8
e47e285
bfe56a8
e0003fc
c778254
4d12979
ff6742c
385f3fe
55d297b
0a8274b
f18831c
cc84ec6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1260,6 +1260,8 @@ The Qubes core startup configuration for SystemD init. | |
| %defattr(-,root,root,-) | ||
| /etc/systemd/system/xendriverdomain.service | ||
| %_unitdir/dev-xvdc1-swap.service | ||
| %_unitdir/home.mount | ||
| %_unitdir/qubes-bind-dirs.service | ||
| %_unitdir/qubes-misc-post.service | ||
| %_unitdir/qubes-mount-dirs.service | ||
| %_unitdir/qubes-rootfs-resize.service | ||
|
|
@@ -1271,6 +1273,7 @@ The Qubes core startup configuration for SystemD init. | |
| %_unitdir/qubes-sync-time.timer | ||
| %_unitdir/[email protected] | ||
| %_unitdir/qubes-updates-proxy-forwarder.socket | ||
| %_unitdir/usr-local.mount | ||
| %{_unitdir}-preset/%qubes_preset_file | ||
| %_modulesloaddir/qubes-core.conf | ||
| %dir %_unitdir/boot.automount.d | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,8 @@ shopt -s nullglob dotglob | |||||||||||||||||||||||||||||||||||||
| # shellcheck source=init/functions | ||||||||||||||||||||||||||||||||||||||
| source /usr/lib/qubes/init/functions | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| readonly DEFAULT_RW_BIND_DIR="/rw/bind-dirs" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| prerequisite() { | ||||||||||||||||||||||||||||||||||||||
| if is_fully_persistent ; then | ||||||||||||||||||||||||||||||||||||||
| echo "No TemplateBasedVM/DisposableVM detected. Exiting." | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -37,7 +39,7 @@ prerequisite() { | |||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| init() { | ||||||||||||||||||||||||||||||||||||||
| [ -n "$rw_dest_dir" ] || rw_dest_dir="/rw/bind-dirs" | ||||||||||||||||||||||||||||||||||||||
| [ -n "$rw_dest_dir" ] || rw_dest_dir="$DEFAULT_RW_BIND_DIR" | ||||||||||||||||||||||||||||||||||||||
| [ -n "$symlink_level_max" ] || symlink_level_max="10" | ||||||||||||||||||||||||||||||||||||||
| mkdir --parents "$rw_dest_dir" | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -49,6 +51,21 @@ legacy() { | |||||||||||||||||||||||||||||||||||||
| true | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| rw_from_ro() { | ||||||||||||||||||||||||||||||||||||||
| ro="$1" | ||||||||||||||||||||||||||||||||||||||
| # special cases for files/dirs in /home or /usr/local | ||||||||||||||||||||||||||||||||||||||
| if [[ "$ro" =~ ^/home/ ]]; then | ||||||||||||||||||||||||||||||||||||||
| # use /rw/home for /home/... binds | ||||||||||||||||||||||||||||||||||||||
| rw="/rw${ro}" | ||||||||||||||||||||||||||||||||||||||
| elif [[ "$ro" =~ ^/usr/local/ ]]; then | ||||||||||||||||||||||||||||||||||||||
| # use /rw/usrlocal for /usr/local/... binds | ||||||||||||||||||||||||||||||||||||||
| rw="/rw/usrlocal/$(echo "$ro" | cut -d/ -f4-)" | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| [ -z "$rw_dest_dir" ] && rw="${DEFAULT_RW_BIND_DIR}${ro}" || rw="${rw_dest_dir}${ro}" | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
| echo "$rw" | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| bind_dirs() { | ||||||||||||||||||||||||||||||||||||||
| ## legend | ||||||||||||||||||||||||||||||||||||||
| ## fso: file system object | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -77,7 +94,7 @@ bind_dirs() { | |||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| true "fso_ro: $fso_ro" | ||||||||||||||||||||||||||||||||||||||
| fso_rw="${rw_dest_dir}${fso_ro}" | ||||||||||||||||||||||||||||||||||||||
| fso_rw="$(rw_from_ro "$fso_ro")" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Make sure fso_ro is not mounted. | ||||||||||||||||||||||||||||||||||||||
| umount "$fso_ro" 2> /dev/null || true | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -91,13 +108,19 @@ bind_dirs() { | |||||||||||||||||||||||||||||||||||||
| if [ ! -e "$fso_ro" ]; then | ||||||||||||||||||||||||||||||||||||||
| ## Create empty file or directory if path exists in /rw to allow to bind mount none existing files/dirs. | ||||||||||||||||||||||||||||||||||||||
| test -d "$fso_rw" && mkdir --parents "$fso_ro" | ||||||||||||||||||||||||||||||||||||||
| test -f "$fso_rw" && touch "$fso_ro" | ||||||||||||||||||||||||||||||||||||||
| if [ -f "$fso_rw" ]; then | ||||||||||||||||||||||||||||||||||||||
| parent_directory="$(dirname "$fso_ro")" | ||||||||||||||||||||||||||||||||||||||
| test -d "$parent_directory" || mkdir --parents "$parent_directory" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| echo "custom-persist: pre-creating file ${rw_path} with rights ${owner}:${group} ${mode}" | |
| if [ ! -d "$parent_directory" ]; then | |
| if ! mk_parent_dirs "$parent_directory" "$owner" "$group"; then | |
| echo "Unable to create ${rw_path} parent dirs, skipping" | |
| continue | |
| fi | |
| fi | |
| touch "${rw_path}" | |
| elif [ "$resource_type" = "dir" ]; then | |
| echo "custom-persist: pre-creating directory ${rw_path} with rights ${owner}:${group} ${mode}" | |
| if ! mk_parent_dirs "$rw_path" "$owner" "$group"; then | |
| echo "Unable to create ${rw_path} parent dirs, skipping" | |
| continue | |
| fi | |
| else | |
| echo "Invalid entry ${target}, skipping" | |
| continue | |
| fi |
EDIT: no, that would only work the first time when $fso_rw doesn't exist...
Guiiix marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [Mount] | ||
| What=/rw/home | ||
| Where=/home | ||
| Type=none | ||
| Options=noauto,bind,defaults,nosuid,nodev |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [Unit] | ||
| Description=Mount configured bind files and directories | ||
| After=qubes-mount-dirs.service local-fs.target rw.mount home.mount usr-local.mount | ||
| Before=qubes-gui-agent.service | ||
| DefaultDependencies=no | ||
| Requires=qubes-mount-dirs.service home.mount usr-local.mount | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| RemainAfterExit=yes | ||
| ExecStart=/usr/lib/qubes/init/bind-dirs.sh | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ Description=Initialize and mount /rw and /home | |
| After=qubes-sysinit.service dev-xvdb.device | ||
| [email protected] | ||
| DefaultDependencies=no | ||
| Before=local-fs.target rw.mount home.mount qubes-gui-agent.service | ||
| Before=local-fs.target rw.mount usr-local.mount home.mount qubes-gui-agent.service | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [Mount] | ||
| What=/rw/usrlocal | ||
| Where=/usr/local | ||
| Type=none | ||
| Options=noauto,bind,defaults |
Uh oh!
There was an error while loading. Please reload this page.