From 30dba04bfeff0606b3139e88e49b5a2d94527f67 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Thu, 9 Jun 2022 23:08:48 +0800 Subject: [PATCH 01/29] Makefile: install: force symlinks. README: logcheck filters. profile-sync-daemon.in and psd.service: no ANSI escapes when logging --- Makefile | 4 ++-- README.md | 10 ++++++++++ common/profile-sync-daemon.in | 21 ++++++++++++++++----- init/psd.service | 1 + 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 9b76b947..9d4652b2 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ install-bin: common/$(PN) $(INSTALL_PROGRAM) common/$(PN) "$(DESTDIR)$(BINDIR)/$(PN)" $(INSTALL_PROGRAM) common/psd-overlay-helper "$(DESTDIR)$(BINDIR)/psd-overlay-helper" $(INSTALL_PROGRAM) common/psd-suspend-sync "$(DESTDIR)$(BINDIR)/psd-suspend-sync" - ln -s $(PN) "$(DESTDIR)$(BINDIR)/psd" + ln -sf $(PN) "$(DESTDIR)$(BINDIR)/psd" $(INSTALL_DIR) "$(DESTDIR)$(ZSHDIR)" $(INSTALL_DATA) common/zsh-completion "$(DESTDIR)/$(ZSHDIR)/_psd" $(INSTALL_DIR) "$(DESTDIR)$(SHAREDIR)/browsers" @@ -43,7 +43,7 @@ install-man: $(INSTALL_DIR) "$(DESTDIR)$(MANDIR)" $(INSTALL_DATA) doc/psd.1 "$(DESTDIR)$(MANDIR)/psd.1" $(INSTALL_DATA) doc/psd-overlay-helper.1 "$(DESTDIR)$(MANDIR)/psd-overlay-helper.1" - ln -s psd.1 "$(DESTDIR)$(MANDIR)/$(PN).1" + ln -sf psd.1 "$(DESTDIR)$(MANDIR)/$(PN).1" install-systemd: $(Q)echo -e '\033[1;32mInstalling systemd files...\033[0m' diff --git a/README.md b/README.md index e447f2f0..43ff7128 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,13 @@ To build from source, see the included INSTALL text document. ### Other Distros If you are interested in packaging psd for your favorite distro, please contact me. + +## logcheck +Using logcheck? Here are some ways to filter out log lines: +>>> +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+]\]: .*(google-chrome|firefox) (re|un)sync successful +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)?\.service: Consumed [0-9\.]+s CPU time\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)\.timer: Succeeded\.$ +>>> diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 8289470b..2735465a 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -10,11 +10,22 @@ # needed for debian >=8.x PATH=$PATH:/sbin -BLD="\e[01m" -RED="\e[01;31m" -GRN="\e[01;32m" -BLU="\e[01;34m" -NRM="\e[00m" +if [[ -n "$LAUNCHED_BY_SYSTEMD" ]] ; then +# This script was invoked by systemd +# Thx to notes-jj: https://serverfault.com/questions/926349/systemd-tell-if-script-was-run-by-systemd-or-by-user +# No 'echo' ANSI escape codes + BLD='' + RED='' + GRN='' + BLU='' + NRM='' +else + BLD="\e[01m" + RED="\e[01;31m" + GRN="\e[01;32m" + BLU="\e[01;34m" + NRM="\e[00m" +fi VERS="@VERSION@" user=$(id -un) diff --git a/init/psd.service b/init/psd.service index d23d1b38..b1c42a00 100644 --- a/init/psd.service +++ b/init/psd.service @@ -11,6 +11,7 @@ Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/profile-sync-daemon startup ExecStop=/usr/bin/profile-sync-daemon unsync +Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target From 5b7018e1ac12fb6d5786fe453e2c0efd041eaba2 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 10 Jun 2022 09:17:21 +0800 Subject: [PATCH 02/29] psd-resync.service: no ANSI escapes when logging --- common/profile-sync-daemon.in | 2 +- init/psd-resync.service | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 2735465a..09a3a701 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -14,7 +14,7 @@ if [[ -n "$LAUNCHED_BY_SYSTEMD" ]] ; then # This script was invoked by systemd # Thx to notes-jj: https://serverfault.com/questions/926349/systemd-tell-if-script-was-run-by-systemd-or-by-user # No 'echo' ANSI escape codes - BLD='' + BLD='' RED='' GRN='' BLU='' diff --git a/init/psd-resync.service b/init/psd-resync.service index 3d13c162..1cca706d 100644 --- a/init/psd-resync.service +++ b/init/psd-resync.service @@ -7,6 +7,7 @@ BindsTo=psd.service [Service] Type=oneshot ExecStart=/usr/bin/profile-sync-daemon resync +Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target From 9662c1b8bca2cdafae8abf5e52acd49ba8189e6b Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 10 Jun 2022 09:36:40 +0800 Subject: [PATCH 03/29] README formatting --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 43ff7128..a2f8d03a 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,10 @@ If you are interested in packaging psd for your favorite distro, please contact ## logcheck Using logcheck? Here are some ways to filter out log lines: ->>> +```Regular Expression ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+]\]: .*(google-chrome|firefox) (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)?\.service: Consumed [0-9\.]+s CPU time\.$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)\.timer: Succeeded\.$ ->>> +``` From 6be9cd1cef50c554f2c85ab77d9fba747a034c45 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 10 Jun 2022 09:37:28 +0800 Subject: [PATCH 04/29] README formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a2f8d03a..86f76f65 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ If you are interested in packaging psd for your favorite distro, please contact ## logcheck Using logcheck? Here are some ways to filter out log lines: -```Regular Expression +```regexp ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+]\]: .*(google-chrome|firefox) (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon From 135e1e0134aa62b90e8287e01d16b0d05a3c9c76 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 10 Jun 2022 09:47:57 +0800 Subject: [PATCH 05/29] README minor fixes --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 86f76f65..7c92d858 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage your browser's profile in tmpfs and to periodically sync it back to your physical disc (HDD/SSD). This is accomplished via a symlinking step and an innovative use of rsync to maintain back-up and synchronization between the two. One of the major design goals of psd is a completely transparent user experience. ## Good Advice -Always backup your browser profile(s) before using psd for the first time. +Before using psd for the first time **stop (quit, exit) your browser then backup its profile(s)**. ## Users of eCryptFS User of eCryptFS are encouraged not to use psd unless willing to help troubleshoot suspected browser corruption. See [#158](https://github.com/graysky2/profile-sync-daemon/issues/158). @@ -39,10 +39,10 @@ To build from source, see the included INSTALL text document. ## Installation from Distro Packages ### Officially Packaged * ![logo](http://www.monitorix.org/imgs/archlinux.png "arch logo")Arch: in the community [repo](https://www.archlinux.org/packages/community/any/profile-sync-daemon/). -* ![logo](http://freedos-32.sourceforge.net/lean/debian_logo.png "debian logo")Debian jesse+: in the official [repos](https://packages.debian.org/unstable/profile-sync-daemon). +* ![logo](http://freedos-32.sourceforge.net/lean/debian_logo.png "debian logo")Debian jessie+: in the official [repos](https://packages.debian.org/unstable/profile-sync-daemon). * ![logo](https://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/Logo_Exherbo.svg/32px-Logo_Exherbo.svg.png "exherbo logo")Exherbo: in the official [repos](http://git.exherbo.org/summer/packages/net-www/profile-sync-daemon). * ![logo](http://www.monitorix.org/imgs/gentoo.png "gentoo logo")Gentoo: in the official [repos](http://packages.gentoo.org/package/www-misc/profile-sync-daemon). -* ![logo](http://www.monitorix.org/imgs/ubuntu.png "ubuntu logo")Ubuntu 16.10+: in the universe [repo](https://packages.ubuntu.com/search?keywords=profile-sync-daemon). +* ![logo](http://www.monitorix.org/imgs/ubuntu.png "ubuntu logo")Ubuntu 16.10+: in Universe [repo](https://packages.ubuntu.com/search?keywords=profile-sync-daemon). * ![logo](https://www.monitorix.org/imgs/fedora.png "fedora logo")Fedora: in the official [repos](https://src.fedoraproject.org/rpms/profile-sync-daemon). ### User Packaged From b0747cb9dcbf1c3d0cd52d571c85af753aaa600a Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Thu, 9 Jun 2022 23:08:48 +0800 Subject: [PATCH 06/29] no ANSI escapes when logging --- Makefile | 4 ++-- README.md | 14 ++++++++++++-- common/profile-sync-daemon.in | 21 ++++++++++++++++----- init/psd-resync.service | 1 + init/psd.service | 1 + 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 9b76b947..9d4652b2 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ install-bin: common/$(PN) $(INSTALL_PROGRAM) common/$(PN) "$(DESTDIR)$(BINDIR)/$(PN)" $(INSTALL_PROGRAM) common/psd-overlay-helper "$(DESTDIR)$(BINDIR)/psd-overlay-helper" $(INSTALL_PROGRAM) common/psd-suspend-sync "$(DESTDIR)$(BINDIR)/psd-suspend-sync" - ln -s $(PN) "$(DESTDIR)$(BINDIR)/psd" + ln -sf $(PN) "$(DESTDIR)$(BINDIR)/psd" $(INSTALL_DIR) "$(DESTDIR)$(ZSHDIR)" $(INSTALL_DATA) common/zsh-completion "$(DESTDIR)/$(ZSHDIR)/_psd" $(INSTALL_DIR) "$(DESTDIR)$(SHAREDIR)/browsers" @@ -43,7 +43,7 @@ install-man: $(INSTALL_DIR) "$(DESTDIR)$(MANDIR)" $(INSTALL_DATA) doc/psd.1 "$(DESTDIR)$(MANDIR)/psd.1" $(INSTALL_DATA) doc/psd-overlay-helper.1 "$(DESTDIR)$(MANDIR)/psd-overlay-helper.1" - ln -s psd.1 "$(DESTDIR)$(MANDIR)/$(PN).1" + ln -sf psd.1 "$(DESTDIR)$(MANDIR)/$(PN).1" install-systemd: $(Q)echo -e '\033[1;32mInstalling systemd files...\033[0m' diff --git a/README.md b/README.md index e447f2f0..1a87b755 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,10 @@ To build from source, see the included INSTALL text document. ## Installation from Distro Packages ### Officially Packaged * ![logo](http://www.monitorix.org/imgs/archlinux.png "arch logo")Arch: in the community [repo](https://www.archlinux.org/packages/community/any/profile-sync-daemon/). -* ![logo](http://freedos-32.sourceforge.net/lean/debian_logo.png "debian logo")Debian jesse+: in the official [repos](https://packages.debian.org/unstable/profile-sync-daemon). +* ![logo](http://freedos-32.sourceforge.net/lean/debian_logo.png "debian logo")Debian jessie+: in the official [repos](https://packages.debian.org/unstable/profile-sync-daemon). * ![logo](https://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/Logo_Exherbo.svg/32px-Logo_Exherbo.svg.png "exherbo logo")Exherbo: in the official [repos](http://git.exherbo.org/summer/packages/net-www/profile-sync-daemon). * ![logo](http://www.monitorix.org/imgs/gentoo.png "gentoo logo")Gentoo: in the official [repos](http://packages.gentoo.org/package/www-misc/profile-sync-daemon). -* ![logo](http://www.monitorix.org/imgs/ubuntu.png "ubuntu logo")Ubuntu 16.10+: in the universe [repo](https://packages.ubuntu.com/search?keywords=profile-sync-daemon). +* ![logo](http://www.monitorix.org/imgs/ubuntu.png "ubuntu logo")Ubuntu 16.10+: in Universe [repo](https://packages.ubuntu.com/search?keywords=profile-sync-daemon). * ![logo](https://www.monitorix.org/imgs/fedora.png "fedora logo")Fedora: in the official [repos](https://src.fedoraproject.org/rpms/profile-sync-daemon). ### User Packaged @@ -51,3 +51,13 @@ To build from source, see the included INSTALL text document. ### Other Distros If you are interested in packaging psd for your favorite distro, please contact me. + +## logcheck +Using logcheck? Here are some ways to filter out log lines: +```regexp +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+]\]: .*(google-chrome|firefox) (re|un)sync successful +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)?\.service: Consumed [0-9\.]+s CPU time\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)\.timer: Succeeded\.$ +``` diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 8289470b..09a3a701 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -10,11 +10,22 @@ # needed for debian >=8.x PATH=$PATH:/sbin -BLD="\e[01m" -RED="\e[01;31m" -GRN="\e[01;32m" -BLU="\e[01;34m" -NRM="\e[00m" +if [[ -n "$LAUNCHED_BY_SYSTEMD" ]] ; then +# This script was invoked by systemd +# Thx to notes-jj: https://serverfault.com/questions/926349/systemd-tell-if-script-was-run-by-systemd-or-by-user +# No 'echo' ANSI escape codes + BLD='' + RED='' + GRN='' + BLU='' + NRM='' +else + BLD="\e[01m" + RED="\e[01;31m" + GRN="\e[01;32m" + BLU="\e[01;34m" + NRM="\e[00m" +fi VERS="@VERSION@" user=$(id -un) diff --git a/init/psd-resync.service b/init/psd-resync.service index 3d13c162..1cca706d 100644 --- a/init/psd-resync.service +++ b/init/psd-resync.service @@ -7,6 +7,7 @@ BindsTo=psd.service [Service] Type=oneshot ExecStart=/usr/bin/profile-sync-daemon resync +Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target diff --git a/init/psd.service b/init/psd.service index d23d1b38..b1c42a00 100644 --- a/init/psd.service +++ b/init/psd.service @@ -11,6 +11,7 @@ Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/profile-sync-daemon startup ExecStop=/usr/bin/profile-sync-daemon unsync +Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target From 2d4fb41c109b41b710010ec376c3e604abc9652d Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 17 Jun 2022 18:10:20 +0800 Subject: [PATCH 07/29] testing --- README.md | 6 +++++- common/profile-sync-daemon.in | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7c92d858..628249bc 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,13 @@ If you are interested in packaging psd for your favorite distro, please contact ## logcheck Using logcheck? Here are some ways to filter out log lines: ```regexp -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+]\]: .*(google-chrome|firefox) (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)?\.service: Consumed [0-9\.]+s CPU time\.$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)\.timer: Succeeded\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: run-user-[0-9]+-[^[:space:]]+: Succeeded\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sudo:[[:space:]]+guest : PWD=/home/guest ; USER=root ; COMMAND=/usr/bin/psd-overlay-helper ``` diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 09a3a701..091db9ac 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -10,8 +10,8 @@ # needed for debian >=8.x PATH=$PATH:/sbin -if [[ -n "$LAUNCHED_BY_SYSTEMD" ]] ; then -# This script was invoked by systemd +if [[ -n "$LAUNCHED_BY_SYSTEMD" || "$1" =~ sync ]] ; then +# This script was invoked by systemd or for sync purposes # Thx to notes-jj: https://serverfault.com/questions/926349/systemd-tell-if-script-was-run-by-systemd-or-by-user # No 'echo' ANSI escape codes BLD='' @@ -496,7 +496,7 @@ do_sync_for() { ln -s /dev/null "$DIR" fi - # sync the tmpfs targets to the disc + # sync the tmpfs target to the non-tmpfs filesystem if [[ -e "$DIR"/.flagged ]]; then REPORT="resync" if [[ $OLFS -eq 1 ]]; then From 0ecb8aaa2c044701b6651292a192096fffde7a4e Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 17 Jun 2022 18:42:52 +0800 Subject: [PATCH 08/29] minor --- doc/psd-overlay-helper.1 | 10 +++++----- doc/psd.1 | 40 +++++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/doc/psd-overlay-helper.1 b/doc/psd-overlay-helper.1 index 4556060e..dadf5a54 100644 --- a/doc/psd-overlay-helper.1 +++ b/doc/psd-overlay-helper.1 @@ -1,17 +1,17 @@ .TH psd-overlay-helper 1 "13 June 2016" "" "" .SH NAME -\fBpsd-overlay-helper \fP- Script to use overlay file system for profile-sync-daemon. +\fBpsd-overlay-helper \fP- Script enabling the "profile-sync-daemon" to use an 'overlay' file system in order to reduce the amount of writing operations. \fB .SH DESCRIPTION -Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile/profiles in tmpfs and to periodically sync back to the physical disc (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a tmpfs copy and media-bound backup of the browser profile/profiles. Additionally, psd features several crash recovery features. +Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile(s) in a 'tmpfs' file system and to periodically sync back to the main file system (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a copy on a tmpfs and media-bound backup of the browser profile(s). Additionally, psd hass several crash-recovery features. -The psd-overlay-helper script is used internally to enable the usage of the overlay file system. It should not be called by the user directly. +The psd-overlay-helper script is used internally to enable the usage of the 'overlay' file system. It should not be called by the user directly. .SH CONTRIBUTE -Users wishing to contribute to this project should fork it and send a pull request. Source is freely available on the project page linked below. +Users wishing to contribute to this project should fork it and send a pull request. The source code is freely available on the project page linked below. .SH ONLINE .IP \(bu 3 Project page: https://github.com/graysky2/profile-sync-daemon .IP \(bu 3 -Wiki page: https://wiki.archlinux.org/index.php/Profile-sync-daemon +Wiki page: https://wiki.archlinux.org/title/Profile-sync-daemon .SH AUTHOR graysky (graysky AT archlinux DOT us) diff --git a/doc/psd.1 b/doc/psd.1 index f122480b..dea933b2 100644 --- a/doc/psd.1 +++ b/doc/psd.1 @@ -1,10 +1,10 @@ .\" Text automatically generated by txt2man .TH profile-sync-daemon "22 September 2020" "" "" .SH NAME -\fBprofile-sync-daemon \fP- Symlinks and syncs browser profiles to RAM (tmpfs) thus reducing HDD/SSD calls and speeding up browsers. +\fBprofile-sync-daemon \fP- Symlinks and syncs browser profile(s) to RAM (thanks to tmpfs), thus reducing HDD/SSD activity and speeding-up browsers. \fB .SH DESCRIPTION -Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile/profiles in tmpfs and to periodically sync back to the physical disc (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a tmpfs copy and media-bound backup of the browser profile/profiles. Additionally, psd features several crash-recovery features. +Profile-sync-daemon (psd) is a tiny pseudo-daemon (a systemd service) designed to manage browser profile(s) in a 'tmpfs' file system and to periodically sync back to the main file system (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a copy on a tmpfs and media-bound backup of the browser profile(s). Additionally, psd hass several crash-recovery features. .PP Design goals of psd: .RS @@ -16,20 +16,22 @@ Reduced wear to physical discs (particularly SSDs). Speed. .RE .PP -Since the profile/profiles, browser cache*, etc. are relocated into tmpfs (RAM disk), the corresponding I/O associated with using the browser is also redirected from the physical disc to the RAM, thus reducing wear to the physical disc and improving browser responsiveness. +Since the profile(s), browser cache*, etc. are relocated into tmpfs (sort-of RAM disk), the I/O corresponding to the browser activity is redirected from the physical disc to the RAM, thus reducing wear to the physical disc and improving responsiveness. .PP -*Note that some browsers such as Chrome/Chromium, Firefox (since v21), Midori, and Rekonq actually keep their cache directories separate from their browser profile directory. It is not within the scope of profile-sync-daemon to modify this behavior; users wishing to relocate this directory, may refer to the following url for several work-arounds: https://wiki.archlinux.org/index.php/Chromium_Tips_and_Tweaks#Cache_in_tmpfs +For the best overall performance using tmpfs along with swap space is recommended. +.PP +*Note that some browsers such as Chrome/Chromium, Firefox (since v21), Midori, and Rekonq actually keep their cache directories separate from their profile directory. Modifying this behavior is outside the scope of profile-sync-daemon ; users wishing to relocate this directory may refer to the following URL for several work-arounds: https://wiki.archlinux.org/title/Chromium#Cache_in_tmpfs .SH SETUP -$XDG_CONFIG_HOME/psd/psd.conf (referred to hereafter as "the config file") contains all user managed settings. +$XDG_CONFIG_HOME/psd/psd.conf (referred to hereafter as "the config file") contains all user-managed settings. .PP NOTE: edits made to the config file while psd is active will be applied only after the service has been restarted. .RS .IP \(bu 3 -Optionally enable the use of overlayfs to improve sync speed and to use a smaller memory footprint. Do this in the USE_OVERLAYFS variable. The user will require no password sudo rights to /usr/bin/psd-overlay-helper to use this option and the kernel must support overlayfs version 22 or higher. See the FAQ below for additional details. +Optionally enable the use of overlayfs to improve sync speed and to use a smaller memory footprint. Do this through the USE_OVERLAYFS variable. The 'sudo' utility must let the user account running the browser invoke /usr/bin/psd-overlay-helper as root without prompting for the password and the kernel must support overlayfs version 22 or higher. See the FAQ below for additional details. .IP \(bu 3 -Optionally have psd resync to the filesystem prior to a sleep call. This can help in the event that the system does not properly wake up. Do this in the USE_SUSPSYNC variable. +Optionally have psd resync to the filesystem prior to a power-management transition (suspend, hibernate...). This can help in the event that the system does not properly wake up. Do this in the USE_SUSPSYNC variable. .IP \(bu 3 -Optionally define which browsers are to be managed in the BROWSERS array. If none are defined, the default is all detected browsers. +Optionally define in the BROWSERS array which browser(s) is/are to be managed. If none is defined, the default is all detected browsers. .IP \(bu 3 Optionally disable the use of crash-recovery snapshots (not recommended). Do this in the USE_BACKUPS variable. .IP \(bu 3 @@ -39,17 +41,17 @@ Optionally define the number of crash-recovery snapshots to keep. Do this in the NOTE: occasionally, updates/changes are made to the default config file (/usr/share/psd/psd.conf) upstream. The user copy ($XDG_CONFIG_HOME/psd/psd.conf) will need to be diffed against it. .SH RUNNING PSD .SS PREVIEW MODE -The preview option can be called to show users exactly what psd will do/is doing based on the entries in the config file. It will also provide useful information such as profile size, paths, and if any recovery snapshots have been created. +The 'preview' option can be used to show exactly what psd will do/is doing based on the entries in the config file. It will also provide useful information such as profile size, paths, and (if any) existing recovery snapshot(s). .PP .nf .fam C $ psd p - Profile-sync-daemon v6.39 +Profile-sync-daemon v6.44 systemd service: active resync-timer: active - sync on sleep: enabled + sync on sleep: disabled use overlayfs: enabled Psd will manage the following per /home/facade/.config/psd/.psd.conf settings: @@ -78,7 +80,7 @@ The preview option can be called to show users exactly what psd will do/is doing .fam T .fi .SS START AND STOP PSD -Psd ships with a systemd user service to start or stop it (psd.service). Additionally, a provided resync-timer will run an hourly resync from tmpfs back to the disk. The resync-timer is started automatically with psd.service so there is no need to start the timer; only start psd.service. +Psd ships with a systemd user service to start or stop it (psd.service). Additionally, a provided resync-timer will run an hourly resync from tmpfs back to the main file system (HDD/SSD). The resync-timer is started automatically with psd.service so there is no need to start the timer: starting psd.service is sufficient. .PP .nf .fam C @@ -98,7 +100,7 @@ The clean mode will delete ALL recovery snapshots that have accumulated. Only ru .fam C $ psd c - Profile-sync-daemon v6.39 + Profile-sync-daemon v6.44 Deleting 2 crashrecovery dirs for profile /home/facade/.config/chromium /home/facade/.config/chromium-backup-crashrecovery-20200423_171359 @@ -193,7 +195,7 @@ Since psd is just a bash script with a systemd service, it should run on any fla .SH FAQ Q1: What is overlayfs mode? .PP -A1: Overlayfs is a simple union filesystem mainlined in the Linux kernel version 3.18.0. When used with psd, a reduced memory footprint and faster sync operations can be realized. The magic is in how the overlay mount only writes out data that has changed rather than the entire profile. The same recovery features psd uses in its default mode are also active when running in overlayfs mode. +A1: Overlayfs is a simple union filesystem type mainlined in the Linux kernel version 3.18.0. When used with psd, a reduced memory footprint and faster sync operations can be realized. The magic is in how the overlay mount only writes out data that has changed rather than the entire profile. The same recovery features psd uses in its default mode are also active when running in overlayfs mode. .PP See the example in the PREVIEW MODE section above which shows a system using overlayfs to illustrate the typical memory savings. Note the "overlayfs size" report compared to the total "profile size" report for each profile. Be aware that these numbers will change depending on just how much new data is written to the profile, but in common use cases, the overlayfs size will always be less than the profile size. .PP @@ -201,7 +203,7 @@ Q2: How do I enable overlayfs mode? .PP A2: First, be sure psd is not active or else any changes to the config file will be ignored until it is restarted. Overlayfs mode is enabled with the USE_OVERLAYFS= variable which should be set to "yes" in the config file. Psd will automatically detect the overlayfs version available to the kernel if it is configured to use one of them. It is recommended to run psd in preview mode to verify that the system can in fact use overlayfs. .PP -Users wanting to use overlayfs mode MUST have sudo rights without password prompt to /usr/bin/psd-overlay-helper or global sudo rights without password prompt. If the user does not have global rights, add the following line to /etc/sudoers after any other lines defining sudo access. It is recommended to use /usr/bin/visudo as root to set this up: +The user account using the browser MUST have sudo rights without password prompt to /usr/bin/psd-overlay-helper or global sudo rights without password prompt. If this account (hereby named 'foo') does not have global rights, add the following line to /etc/sudoers after any other lines defining sudo access. It is recommended to use /usr/bin/visudo as root to set this up: .PP .nf .fam C @@ -211,15 +213,15 @@ Users wanting to use overlayfs mode MUST have sudo rights without password promp .fi Q3: Why do I have another browser profile directory "foo-back-ovfs" when I enable overlayfs? .PP -A3: The way overlayfs works is to mount a read-only base copy (so-called lower dir) of the profile, and manage the new data on top of that. In order to avoid resyncing to the read-only filesystem, a copy is used instead. So using overlayfs is a trade-off: faster initial sync times and less memory usage vs. disk space in the home dir. +A3: The overlayfs works by mounting a read-only base copy (so-called "lower dir") of the profile, and manage the new data on top of that. In order to avoid resyncing to the read-only filesystem, a copy is used instead. So using overlayfs is a trade-off: faster initial sync times and less memory usage vs. disk space in the home dir. .PP -Q4: I need more memory to accommodate my profile/profiles in /run/user/xxxx. How can I allocate more? +Q4: I need more memory to accommodate my profile(s) in /run/user/xxxx. How can I allocate more? .PP -A4: The standard way of controlling the size of /run/user/ is the RuntimeDirectorySize directive in logind.conf (see the man page for logind.conf for more). By default, 10% of physical memory is used but one can increase it safely. Remember that tmpfs only consumes what is actually used; the number specified here is just a maximum allowed. +A4: The standard way of controlling the size of /run/user/ is the RuntimeDirectorySize directive in logind.conf (see the man page for logind.conf). By default, 10% of physical memory is used but one can increase it (beware: if you oversize your tmpfs instances the machine will deadlock, read about this at https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html ). Remember that tmpfs only consumes what is actually used; the number specified here is just a maximum allowed. .PP Q5: My system crashed for some reason and psd didn't sync back. What do I do? .PP -A5: The "last good" backup of the browser profile/profiles should be the filesystem. Upon restarting psd (on a reboot for example), a check is performed to see if the symlink to the tmpfs copy of the profile is invalid. If it is invalid, psd will snapshot the "last good" backup before it rotates it back into place. This is more for a sanity check that psd did no harm and that any data loss was a function of something else. +A5: The "last good" backup of the browser profile/profiles should be on the main file system (HDD/SSD). Upon restarting psd (on a reboot for example), a check is performed to see if the symlink to the tmpfs copy of the profile is invalid. If it is invalid, psd will snapshot the "last good" backup before rotating it back into place. This is more for a sanity check that psd did no harm and that any data loss was a done by something else. .PP Q6: Where can I find this snapshot? .PP From cadcc5767a4ec2f9ee7e8ad6d12dc46771eb109d Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Tue, 21 Jun 2022 18:15:32 +0800 Subject: [PATCH 09/29] testing --- common/profile-sync-daemon.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 091db9ac..c9ddacb5 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -9,10 +9,12 @@ # needed for debian >=8.x PATH=$PATH:/sbin - -if [[ -n "$LAUNCHED_BY_SYSTEMD" || "$1" =~ sync ]] ; then +#|| -n "$LAUNCHED_BY_SYSTEMD" || "$1" =~ sync ]] +#if it works this way suppress the 'LAUNCHED_BY_SYSTEMD' variable +if [[ ! -t 1 ]] ; then # This script was invoked by systemd or for sync purposes # Thx to notes-jj: https://serverfault.com/questions/926349/systemd-tell-if-script-was-run-by-systemd-or-by-user +# and D. Clayton: https://stackoverflow.com/questions/911168/how-can-i-detect-if-my-shell-script-is-running-through-a-pipe # No 'echo' ANSI escape codes BLD='' RED='' From e3712933c082810de0eb592abc29177cc18703d5 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 10 Jun 2022 09:47:57 +0800 Subject: [PATCH 10/29] README minor fixes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a87b755..7c92d858 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage your browser's profile in tmpfs and to periodically sync it back to your physical disc (HDD/SSD). This is accomplished via a symlinking step and an innovative use of rsync to maintain back-up and synchronization between the two. One of the major design goals of psd is a completely transparent user experience. ## Good Advice -Always backup your browser profile(s) before using psd for the first time. +Before using psd for the first time **stop (quit, exit) your browser then backup its profile(s)**. ## Users of eCryptFS User of eCryptFS are encouraged not to use psd unless willing to help troubleshoot suspected browser corruption. See [#158](https://github.com/graysky2/profile-sync-daemon/issues/158). From 93feed9b1702811b2bb7ad227dd6c2b58bd3dcba Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 17 Jun 2022 18:10:20 +0800 Subject: [PATCH 11/29] testing --- README.md | 6 +++++- common/profile-sync-daemon.in | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7c92d858..628249bc 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,13 @@ If you are interested in packaging psd for your favorite distro, please contact ## logcheck Using logcheck? Here are some ways to filter out log lines: ```regexp -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+]\]: .*(google-chrome|firefox) (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)?\.service: Consumed [0-9\.]+s CPU time\.$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)\.timer: Succeeded\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: run-user-[0-9]+-[^[:space:]]+: Succeeded\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sudo:[[:space:]]+guest : PWD=/home/guest ; USER=root ; COMMAND=/usr/bin/psd-overlay-helper ``` diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 09a3a701..091db9ac 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -10,8 +10,8 @@ # needed for debian >=8.x PATH=$PATH:/sbin -if [[ -n "$LAUNCHED_BY_SYSTEMD" ]] ; then -# This script was invoked by systemd +if [[ -n "$LAUNCHED_BY_SYSTEMD" || "$1" =~ sync ]] ; then +# This script was invoked by systemd or for sync purposes # Thx to notes-jj: https://serverfault.com/questions/926349/systemd-tell-if-script-was-run-by-systemd-or-by-user # No 'echo' ANSI escape codes BLD='' @@ -496,7 +496,7 @@ do_sync_for() { ln -s /dev/null "$DIR" fi - # sync the tmpfs targets to the disc + # sync the tmpfs target to the non-tmpfs filesystem if [[ -e "$DIR"/.flagged ]]; then REPORT="resync" if [[ $OLFS -eq 1 ]]; then From 6aefd8947f79eea21e97b315afa6bf70911b8fe8 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Thu, 9 Jun 2022 23:08:48 +0800 Subject: [PATCH 12/29] no ANSI escapes when logging --- common/profile-sync-daemon.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 091db9ac..e529245b 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -10,9 +10,7 @@ # needed for debian >=8.x PATH=$PATH:/sbin -if [[ -n "$LAUNCHED_BY_SYSTEMD" || "$1" =~ sync ]] ; then -# This script was invoked by systemd or for sync purposes -# Thx to notes-jj: https://serverfault.com/questions/926349/systemd-tell-if-script-was-run-by-systemd-or-by-user +if [[ ! -t 1 ]] ; then # No 'echo' ANSI escape codes BLD='' RED='' From cc2b51aac04e7cfab74dfbb7b566c46f4065e46e Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 17 Jun 2022 18:42:52 +0800 Subject: [PATCH 13/29] minor --- doc/psd-overlay-helper.1 | 10 +++++----- doc/psd.1 | 40 +++++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/doc/psd-overlay-helper.1 b/doc/psd-overlay-helper.1 index 4556060e..dadf5a54 100644 --- a/doc/psd-overlay-helper.1 +++ b/doc/psd-overlay-helper.1 @@ -1,17 +1,17 @@ .TH psd-overlay-helper 1 "13 June 2016" "" "" .SH NAME -\fBpsd-overlay-helper \fP- Script to use overlay file system for profile-sync-daemon. +\fBpsd-overlay-helper \fP- Script enabling the "profile-sync-daemon" to use an 'overlay' file system in order to reduce the amount of writing operations. \fB .SH DESCRIPTION -Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile/profiles in tmpfs and to periodically sync back to the physical disc (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a tmpfs copy and media-bound backup of the browser profile/profiles. Additionally, psd features several crash recovery features. +Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile(s) in a 'tmpfs' file system and to periodically sync back to the main file system (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a copy on a tmpfs and media-bound backup of the browser profile(s). Additionally, psd hass several crash-recovery features. -The psd-overlay-helper script is used internally to enable the usage of the overlay file system. It should not be called by the user directly. +The psd-overlay-helper script is used internally to enable the usage of the 'overlay' file system. It should not be called by the user directly. .SH CONTRIBUTE -Users wishing to contribute to this project should fork it and send a pull request. Source is freely available on the project page linked below. +Users wishing to contribute to this project should fork it and send a pull request. The source code is freely available on the project page linked below. .SH ONLINE .IP \(bu 3 Project page: https://github.com/graysky2/profile-sync-daemon .IP \(bu 3 -Wiki page: https://wiki.archlinux.org/index.php/Profile-sync-daemon +Wiki page: https://wiki.archlinux.org/title/Profile-sync-daemon .SH AUTHOR graysky (graysky AT archlinux DOT us) diff --git a/doc/psd.1 b/doc/psd.1 index f122480b..dea933b2 100644 --- a/doc/psd.1 +++ b/doc/psd.1 @@ -1,10 +1,10 @@ .\" Text automatically generated by txt2man .TH profile-sync-daemon "22 September 2020" "" "" .SH NAME -\fBprofile-sync-daemon \fP- Symlinks and syncs browser profiles to RAM (tmpfs) thus reducing HDD/SSD calls and speeding up browsers. +\fBprofile-sync-daemon \fP- Symlinks and syncs browser profile(s) to RAM (thanks to tmpfs), thus reducing HDD/SSD activity and speeding-up browsers. \fB .SH DESCRIPTION -Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile/profiles in tmpfs and to periodically sync back to the physical disc (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a tmpfs copy and media-bound backup of the browser profile/profiles. Additionally, psd features several crash-recovery features. +Profile-sync-daemon (psd) is a tiny pseudo-daemon (a systemd service) designed to manage browser profile(s) in a 'tmpfs' file system and to periodically sync back to the main file system (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a copy on a tmpfs and media-bound backup of the browser profile(s). Additionally, psd hass several crash-recovery features. .PP Design goals of psd: .RS @@ -16,20 +16,22 @@ Reduced wear to physical discs (particularly SSDs). Speed. .RE .PP -Since the profile/profiles, browser cache*, etc. are relocated into tmpfs (RAM disk), the corresponding I/O associated with using the browser is also redirected from the physical disc to the RAM, thus reducing wear to the physical disc and improving browser responsiveness. +Since the profile(s), browser cache*, etc. are relocated into tmpfs (sort-of RAM disk), the I/O corresponding to the browser activity is redirected from the physical disc to the RAM, thus reducing wear to the physical disc and improving responsiveness. .PP -*Note that some browsers such as Chrome/Chromium, Firefox (since v21), Midori, and Rekonq actually keep their cache directories separate from their browser profile directory. It is not within the scope of profile-sync-daemon to modify this behavior; users wishing to relocate this directory, may refer to the following url for several work-arounds: https://wiki.archlinux.org/index.php/Chromium_Tips_and_Tweaks#Cache_in_tmpfs +For the best overall performance using tmpfs along with swap space is recommended. +.PP +*Note that some browsers such as Chrome/Chromium, Firefox (since v21), Midori, and Rekonq actually keep their cache directories separate from their profile directory. Modifying this behavior is outside the scope of profile-sync-daemon ; users wishing to relocate this directory may refer to the following URL for several work-arounds: https://wiki.archlinux.org/title/Chromium#Cache_in_tmpfs .SH SETUP -$XDG_CONFIG_HOME/psd/psd.conf (referred to hereafter as "the config file") contains all user managed settings. +$XDG_CONFIG_HOME/psd/psd.conf (referred to hereafter as "the config file") contains all user-managed settings. .PP NOTE: edits made to the config file while psd is active will be applied only after the service has been restarted. .RS .IP \(bu 3 -Optionally enable the use of overlayfs to improve sync speed and to use a smaller memory footprint. Do this in the USE_OVERLAYFS variable. The user will require no password sudo rights to /usr/bin/psd-overlay-helper to use this option and the kernel must support overlayfs version 22 or higher. See the FAQ below for additional details. +Optionally enable the use of overlayfs to improve sync speed and to use a smaller memory footprint. Do this through the USE_OVERLAYFS variable. The 'sudo' utility must let the user account running the browser invoke /usr/bin/psd-overlay-helper as root without prompting for the password and the kernel must support overlayfs version 22 or higher. See the FAQ below for additional details. .IP \(bu 3 -Optionally have psd resync to the filesystem prior to a sleep call. This can help in the event that the system does not properly wake up. Do this in the USE_SUSPSYNC variable. +Optionally have psd resync to the filesystem prior to a power-management transition (suspend, hibernate...). This can help in the event that the system does not properly wake up. Do this in the USE_SUSPSYNC variable. .IP \(bu 3 -Optionally define which browsers are to be managed in the BROWSERS array. If none are defined, the default is all detected browsers. +Optionally define in the BROWSERS array which browser(s) is/are to be managed. If none is defined, the default is all detected browsers. .IP \(bu 3 Optionally disable the use of crash-recovery snapshots (not recommended). Do this in the USE_BACKUPS variable. .IP \(bu 3 @@ -39,17 +41,17 @@ Optionally define the number of crash-recovery snapshots to keep. Do this in the NOTE: occasionally, updates/changes are made to the default config file (/usr/share/psd/psd.conf) upstream. The user copy ($XDG_CONFIG_HOME/psd/psd.conf) will need to be diffed against it. .SH RUNNING PSD .SS PREVIEW MODE -The preview option can be called to show users exactly what psd will do/is doing based on the entries in the config file. It will also provide useful information such as profile size, paths, and if any recovery snapshots have been created. +The 'preview' option can be used to show exactly what psd will do/is doing based on the entries in the config file. It will also provide useful information such as profile size, paths, and (if any) existing recovery snapshot(s). .PP .nf .fam C $ psd p - Profile-sync-daemon v6.39 +Profile-sync-daemon v6.44 systemd service: active resync-timer: active - sync on sleep: enabled + sync on sleep: disabled use overlayfs: enabled Psd will manage the following per /home/facade/.config/psd/.psd.conf settings: @@ -78,7 +80,7 @@ The preview option can be called to show users exactly what psd will do/is doing .fam T .fi .SS START AND STOP PSD -Psd ships with a systemd user service to start or stop it (psd.service). Additionally, a provided resync-timer will run an hourly resync from tmpfs back to the disk. The resync-timer is started automatically with psd.service so there is no need to start the timer; only start psd.service. +Psd ships with a systemd user service to start or stop it (psd.service). Additionally, a provided resync-timer will run an hourly resync from tmpfs back to the main file system (HDD/SSD). The resync-timer is started automatically with psd.service so there is no need to start the timer: starting psd.service is sufficient. .PP .nf .fam C @@ -98,7 +100,7 @@ The clean mode will delete ALL recovery snapshots that have accumulated. Only ru .fam C $ psd c - Profile-sync-daemon v6.39 + Profile-sync-daemon v6.44 Deleting 2 crashrecovery dirs for profile /home/facade/.config/chromium /home/facade/.config/chromium-backup-crashrecovery-20200423_171359 @@ -193,7 +195,7 @@ Since psd is just a bash script with a systemd service, it should run on any fla .SH FAQ Q1: What is overlayfs mode? .PP -A1: Overlayfs is a simple union filesystem mainlined in the Linux kernel version 3.18.0. When used with psd, a reduced memory footprint and faster sync operations can be realized. The magic is in how the overlay mount only writes out data that has changed rather than the entire profile. The same recovery features psd uses in its default mode are also active when running in overlayfs mode. +A1: Overlayfs is a simple union filesystem type mainlined in the Linux kernel version 3.18.0. When used with psd, a reduced memory footprint and faster sync operations can be realized. The magic is in how the overlay mount only writes out data that has changed rather than the entire profile. The same recovery features psd uses in its default mode are also active when running in overlayfs mode. .PP See the example in the PREVIEW MODE section above which shows a system using overlayfs to illustrate the typical memory savings. Note the "overlayfs size" report compared to the total "profile size" report for each profile. Be aware that these numbers will change depending on just how much new data is written to the profile, but in common use cases, the overlayfs size will always be less than the profile size. .PP @@ -201,7 +203,7 @@ Q2: How do I enable overlayfs mode? .PP A2: First, be sure psd is not active or else any changes to the config file will be ignored until it is restarted. Overlayfs mode is enabled with the USE_OVERLAYFS= variable which should be set to "yes" in the config file. Psd will automatically detect the overlayfs version available to the kernel if it is configured to use one of them. It is recommended to run psd in preview mode to verify that the system can in fact use overlayfs. .PP -Users wanting to use overlayfs mode MUST have sudo rights without password prompt to /usr/bin/psd-overlay-helper or global sudo rights without password prompt. If the user does not have global rights, add the following line to /etc/sudoers after any other lines defining sudo access. It is recommended to use /usr/bin/visudo as root to set this up: +The user account using the browser MUST have sudo rights without password prompt to /usr/bin/psd-overlay-helper or global sudo rights without password prompt. If this account (hereby named 'foo') does not have global rights, add the following line to /etc/sudoers after any other lines defining sudo access. It is recommended to use /usr/bin/visudo as root to set this up: .PP .nf .fam C @@ -211,15 +213,15 @@ Users wanting to use overlayfs mode MUST have sudo rights without password promp .fi Q3: Why do I have another browser profile directory "foo-back-ovfs" when I enable overlayfs? .PP -A3: The way overlayfs works is to mount a read-only base copy (so-called lower dir) of the profile, and manage the new data on top of that. In order to avoid resyncing to the read-only filesystem, a copy is used instead. So using overlayfs is a trade-off: faster initial sync times and less memory usage vs. disk space in the home dir. +A3: The overlayfs works by mounting a read-only base copy (so-called "lower dir") of the profile, and manage the new data on top of that. In order to avoid resyncing to the read-only filesystem, a copy is used instead. So using overlayfs is a trade-off: faster initial sync times and less memory usage vs. disk space in the home dir. .PP -Q4: I need more memory to accommodate my profile/profiles in /run/user/xxxx. How can I allocate more? +Q4: I need more memory to accommodate my profile(s) in /run/user/xxxx. How can I allocate more? .PP -A4: The standard way of controlling the size of /run/user/ is the RuntimeDirectorySize directive in logind.conf (see the man page for logind.conf for more). By default, 10% of physical memory is used but one can increase it safely. Remember that tmpfs only consumes what is actually used; the number specified here is just a maximum allowed. +A4: The standard way of controlling the size of /run/user/ is the RuntimeDirectorySize directive in logind.conf (see the man page for logind.conf). By default, 10% of physical memory is used but one can increase it (beware: if you oversize your tmpfs instances the machine will deadlock, read about this at https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html ). Remember that tmpfs only consumes what is actually used; the number specified here is just a maximum allowed. .PP Q5: My system crashed for some reason and psd didn't sync back. What do I do? .PP -A5: The "last good" backup of the browser profile/profiles should be the filesystem. Upon restarting psd (on a reboot for example), a check is performed to see if the symlink to the tmpfs copy of the profile is invalid. If it is invalid, psd will snapshot the "last good" backup before it rotates it back into place. This is more for a sanity check that psd did no harm and that any data loss was a function of something else. +A5: The "last good" backup of the browser profile/profiles should be on the main file system (HDD/SSD). Upon restarting psd (on a reboot for example), a check is performed to see if the symlink to the tmpfs copy of the profile is invalid. If it is invalid, psd will snapshot the "last good" backup before rotating it back into place. This is more for a sanity check that psd did no harm and that any data loss was a done by something else. .PP Q6: Where can I find this snapshot? .PP From 1af88bea5bccb351c18a25af9792ef2e087e7ce5 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Tue, 21 Jun 2022 18:15:32 +0800 Subject: [PATCH 14/29] testing --- common/profile-sync-daemon.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index e529245b..005bda9a 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -9,8 +9,8 @@ # needed for debian >=8.x PATH=$PATH:/sbin - if [[ ! -t 1 ]] ; then +# Thx D. Clayton: https://stackoverflow.com/questions/911168/how-can-i-detect-if-my-shell-script-is-running-through-a-pipe # No 'echo' ANSI escape codes BLD='' RED='' From 2edabab27c1b1dea779111acd7caf5ca5e84cf26 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Sat, 25 Jun 2022 11:26:04 +0800 Subject: [PATCH 15/29] testing --- init/psd-resync.service | 1 - init/psd.service | 1 - 2 files changed, 2 deletions(-) diff --git a/init/psd-resync.service b/init/psd-resync.service index 1cca706d..3d13c162 100644 --- a/init/psd-resync.service +++ b/init/psd-resync.service @@ -7,7 +7,6 @@ BindsTo=psd.service [Service] Type=oneshot ExecStart=/usr/bin/profile-sync-daemon resync -Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target diff --git a/init/psd.service b/init/psd.service index b1c42a00..d23d1b38 100644 --- a/init/psd.service +++ b/init/psd.service @@ -11,7 +11,6 @@ Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/profile-sync-daemon startup ExecStop=/usr/bin/profile-sync-daemon unsync -Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target From d748b6fe98ecdddb9ca740d20d0b9996cbb570e1 Mon Sep 17 00:00:00 2001 From: graysky Date: Fri, 11 Dec 2020 06:03:09 -0500 Subject: [PATCH 16/29] psd-overlay-helper deletes workdir on umount Users cannot delete a root-owned index directory unless it's empty/fixes #285 --- MIT | 2 +- Makefile | 16 +++++------ README.md | 22 +++++++++++--- common/browsers/epiphany | 2 +- common/browsers/google-chrome | 6 +++- common/browsers/google-chrome-beta | 6 +++- common/browsers/google-chrome-unstable | 6 +++- common/profile-sync-daemon.in | 31 +++++++++++++------- common/psd-overlay-helper | 2 +- common/psd-suspend-sync | 29 +++++++++++++++---- common/psd.conf | 4 +-- doc/psd-overlay-helper.1 | 10 +++---- doc/psd.1 | 40 ++++++++++++++------------ init/psd-resync.service | 1 + init/psd.service | 1 + 15 files changed, 118 insertions(+), 60 deletions(-) diff --git a/MIT b/MIT index 37fcf3ce..ad491691 100644 --- a/MIT +++ b/MIT @@ -1,4 +1,4 @@ -Copyright (c) 2013-2020 graysky +Copyright (c) 2013-2021 graysky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/Makefile b/Makefile index 6652fff8..7781c2da 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 6.42 +VERSION = 6.45 PN = profile-sync-daemon PREFIX ?= /usr @@ -29,21 +29,21 @@ install-bin: common/$(PN) $(INSTALL_PROGRAM) common/$(PN) "$(DESTDIR)$(BINDIR)/$(PN)" $(INSTALL_PROGRAM) common/psd-overlay-helper "$(DESTDIR)$(BINDIR)/psd-overlay-helper" $(INSTALL_PROGRAM) common/psd-suspend-sync "$(DESTDIR)$(BINDIR)/psd-suspend-sync" - ln -s $(PN) "$(DESTDIR)$(BINDIR)/psd" + ln -sf $(PN) "$(DESTDIR)$(BINDIR)/psd" $(INSTALL_DIR) "$(DESTDIR)$(ZSHDIR)" $(INSTALL_DATA) common/zsh-completion "$(DESTDIR)/$(ZSHDIR)/_psd" $(INSTALL_DIR) "$(DESTDIR)$(SHAREDIR)/browsers" $(INSTALL_DATA) common/psd.conf "$(DESTDIR)$(SHAREDIR)/psd.conf" - cp common/browsers/* "$(DESTDIR)$(SHAREDIR)/browsers" + $(INSTALL_DATA) common/browsers/* "$(DESTDIR)$(SHAREDIR)/browsers" $(INSTALL_DIR) "$(DESTDIR)$(SHAREDIR)/contrib" - cp contrib/* "$(DESTDIR)$(SHAREDIR)/contrib" + $(INSTALL_DATA) contrib/* "$(DESTDIR)$(SHAREDIR)/contrib" install-man: $(Q)echo -e '\033[1;32mInstalling manpage...\033[0m' $(INSTALL_DIR) "$(DESTDIR)$(MANDIR)" $(INSTALL_DATA) doc/psd.1 "$(DESTDIR)$(MANDIR)/psd.1" $(INSTALL_DATA) doc/psd-overlay-helper.1 "$(DESTDIR)$(MANDIR)/psd-overlay-helper.1" - ln -s psd.1 "$(DESTDIR)$(MANDIR)/$(PN).1" + ln -sf psd.1 "$(DESTDIR)$(MANDIR)/$(PN).1" install-systemd: $(Q)echo -e '\033[1;32mInstalling systemd files...\033[0m' @@ -66,9 +66,9 @@ uninstall-bin: rmdir "$(DESTDIR)$(SHAREDIR)" uninstall-man: - $(RM) -f "$(DESTDIR)$(MANDIR)/$(PN).1.gz" - $(RM) -f "$(DESTDIR)$(MANDIR)/psd.1.gz" - $(RM) -f "$(DESTDIR)$(MANDIR)/psd-overlay-helper.1.gz" + $(RM) -f "$(DESTDIR)$(MANDIR)/$(PN).1" + $(RM) -f "$(DESTDIR)$(MANDIR)/psd.1" + $(RM) -f "$(DESTDIR)$(MANDIR)/psd-overlay-helper.1" uninstall-systemd: $(RM) "$(DESTDIR)$(INITDIR_SYSTEMD)/psd.service" diff --git a/README.md b/README.md index 8a226bf1..628249bc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage your browser's profile in tmpfs and to periodically sync it back to your physical disc (HDD/SSD). This is accomplished via a symlinking step and an innovative use of rsync to maintain back-up and synchronization between the two. One of the major design goals of psd is a completely transparent user experience. ## Good Advice -Always backup your browser profile(s) before using psd for the first time. +Before using psd for the first time **stop (quit, exit) your browser then backup its profile(s)**. ## Users of eCryptFS User of eCryptFS are encouraged not to use psd unless willing to help troubleshoot suspected browser corruption. See [#158](https://github.com/graysky2/profile-sync-daemon/issues/158). @@ -39,15 +39,29 @@ To build from source, see the included INSTALL text document. ## Installation from Distro Packages ### Officially Packaged * ![logo](http://www.monitorix.org/imgs/archlinux.png "arch logo")Arch: in the community [repo](https://www.archlinux.org/packages/community/any/profile-sync-daemon/). -* ![logo](http://freedos-32.sourceforge.net/lean/debian_logo.png "debian logo")Debian jesse+: in the official [repos](https://packages.debian.org/unstable/profile-sync-daemon). +* ![logo](http://freedos-32.sourceforge.net/lean/debian_logo.png "debian logo")Debian jessie+: in the official [repos](https://packages.debian.org/unstable/profile-sync-daemon). * ![logo](https://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/Logo_Exherbo.svg/32px-Logo_Exherbo.svg.png "exherbo logo")Exherbo: in the official [repos](http://git.exherbo.org/summer/packages/net-www/profile-sync-daemon). * ![logo](http://www.monitorix.org/imgs/gentoo.png "gentoo logo")Gentoo: in the official [repos](http://packages.gentoo.org/package/www-misc/profile-sync-daemon). -* ![logo](http://www.monitorix.org/imgs/ubuntu.png "ubuntu logo")Ubuntu 16.10+: in the universe [repo](https://packages.ubuntu.com/search?keywords=profile-sync-daemon). +* ![logo](http://www.monitorix.org/imgs/ubuntu.png "ubuntu logo")Ubuntu 16.10+: in Universe [repo](https://packages.ubuntu.com/search?keywords=profile-sync-daemon). +* ![logo](https://www.monitorix.org/imgs/fedora.png "fedora logo")Fedora: in the official [repos](https://src.fedoraproject.org/rpms/profile-sync-daemon). ### User Packaged * ![logo](https://i.postimg.cc/4x1Wtnkr/Chakra-shiny.png "chakra logo")Chakra: in the [CCR](https://ccr.chakralinux.org/packages.php?O=0&K=profile-sync-daemon). -* ![logo](https://www.monitorix.org/imgs/fedora.png "fedora logo")Fedora: in [Copr](https://copr.fedorainfracloud.org/coprs/szasza/Profile-sync-daemon/). * ![logo](http://wiki.codeblocks.org/images/8/8b/Slackware-logo_32.png "slack logo")Slackware: on [slackbuilds](http://slackbuilds.org/apps/profile-sync-daemon/). ### Other Distros If you are interested in packaging psd for your favorite distro, please contact me. + +## logcheck +Using logcheck? Here are some ways to filter out log lines: +```regexp +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)?\.service: Consumed [0-9\.]+s CPU time\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)\.timer: Succeeded\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: run-user-[0-9]+-[^[:space:]]+: Succeeded\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sudo:[[:space:]]+guest : PWD=/home/guest ; USER=root ; COMMAND=/usr/bin/psd-overlay-helper +``` diff --git a/common/browsers/epiphany b/common/browsers/epiphany index a9915223..35889af4 100644 --- a/common/browsers/epiphany +++ b/common/browsers/epiphany @@ -1,2 +1,2 @@ -DIRArr[0]="$XDG_CONFIG_HOME/$browser" +DIRArr[0]="$XDG_DATA_HOME/$browser" PSNAME="$browser" diff --git a/common/browsers/google-chrome b/common/browsers/google-chrome index 641c8fbf..637bdd0d 100644 --- a/common/browsers/google-chrome +++ b/common/browsers/google-chrome @@ -1,2 +1,6 @@ -DIRArr[0]="$XDG_CONFIG_HOME/$browser" +if [[ -n "$CHROME_CONFIG_HOME" ]]; then + DIRArr[0]="$CHROME_CONFIG_HOME/$browser" +else + DIRArr[0]="$XDG_CONFIG_HOME/$browser" +fi PSNAME="chrome" diff --git a/common/browsers/google-chrome-beta b/common/browsers/google-chrome-beta index 641c8fbf..637bdd0d 100644 --- a/common/browsers/google-chrome-beta +++ b/common/browsers/google-chrome-beta @@ -1,2 +1,6 @@ -DIRArr[0]="$XDG_CONFIG_HOME/$browser" +if [[ -n "$CHROME_CONFIG_HOME" ]]; then + DIRArr[0]="$CHROME_CONFIG_HOME/$browser" +else + DIRArr[0]="$XDG_CONFIG_HOME/$browser" +fi PSNAME="chrome" diff --git a/common/browsers/google-chrome-unstable b/common/browsers/google-chrome-unstable index 641c8fbf..637bdd0d 100644 --- a/common/browsers/google-chrome-unstable +++ b/common/browsers/google-chrome-unstable @@ -1,2 +1,6 @@ -DIRArr[0]="$XDG_CONFIG_HOME/$browser" +if [[ -n "$CHROME_CONFIG_HOME" ]]; then + DIRArr[0]="$CHROME_CONFIG_HOME/$browser" +else + DIRArr[0]="$XDG_CONFIG_HOME/$browser" +fi PSNAME="chrome" diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 7afc7648..005bda9a 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -9,17 +9,27 @@ # needed for debian >=8.x PATH=$PATH:/sbin - -BLD="\e[01m" -RED="\e[01;31m" -GRN="\e[01;32m" -BLU="\e[01;34m" -NRM="\e[00m" +if [[ ! -t 1 ]] ; then +# Thx D. Clayton: https://stackoverflow.com/questions/911168/how-can-i-detect-if-my-shell-script-is-running-through-a-pipe +# No 'echo' ANSI escape codes + BLD='' + RED='' + GRN='' + BLU='' + NRM='' +else + BLD="\e[01m" + RED="\e[01;31m" + GRN="\e[01;32m" + BLU="\e[01;34m" + NRM="\e[00m" +fi VERS="@VERSION@" user=$(id -un) HOME="$(getent passwd "$user" | cut -d: -f6)" XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" PSDCONFDIR="$XDG_CONFIG_HOME/psd" PSDCONF="$PSDCONFDIR/psd.conf" SHAREDIR="/usr/share/psd" @@ -117,7 +127,7 @@ if [[ -z "$BROWSERS" ]]; then else if ! declare -p BROWSERS | grep -q 'declare \-a'; then # did not setup as array so redefine it here - IFS=' ' read -r -a BROWSERS <<< "${BROWSERS[$@]}" + IFS=' ' read -r -a BROWSERS <<< "${BROWSERS[@]}" fi fi @@ -484,7 +494,7 @@ do_sync_for() { ln -s /dev/null "$DIR" fi - # sync the tmpfs targets to the disc + # sync the tmpfs target to the non-tmpfs filesystem if [[ -e "$DIR"/.flagged ]]; then REPORT="resync" if [[ $OLFS -eq 1 ]]; then @@ -595,8 +605,7 @@ do_unsync() { [[ -d "$BACKUP" ]] && mv --no-target-directory "$BACKUP" "$DIR" if [[ $OLFS -eq 1 ]] && mountpoint -q "$TMP"; then rsync -aX --delete-after --inplace --no-whole-file --exclude .flagged "$BACK_OVFS/" "$DIR/" - sudo psd-overlay-helper -d "$TMP" mountdown && - rm -rf "$TMP" "$UPPER" "$WORK" + sudo psd-overlay-helper -d "$TMP" -w "$WORK" mountdown && rm -rf "$TMP" "$UPPER" fi [[ -d "$TMP" ]] && rm -rf "$TMP" echo -e "${BLD}$browser unsync successful${NRM}" @@ -715,7 +724,7 @@ take_inhibit_lock() { release_inhibit_lock # background this to avoid hanging on startup - systemd-inhibit --mode="delay" --what="sleep" --who="profile-sync-daemon" --why="psd resync on suspend" /usr/bin/psd-suspend-sync & + /usr/bin/psd-suspend-sync & } release_inhibit_lock() { diff --git a/common/psd-overlay-helper b/common/psd-overlay-helper index 348dc123..e023d103 100644 --- a/common/psd-overlay-helper +++ b/common/psd-overlay-helper @@ -49,7 +49,7 @@ case "$1" in fi ;; mountdown) - umount -l "$TMP" + umount "$TMP" && rm -rf "$WORK" ;; *) echo "Do not call this script directly; psd will do so for you. Thank you, come again." diff --git a/common/psd-suspend-sync b/common/psd-suspend-sync index 81aaae1d..d44c0d52 100644 --- a/common/psd-suspend-sync +++ b/common/psd-suspend-sync @@ -7,20 +7,39 @@ dbus_member="PrepareForSleep" # ... /org/freedesktop/login1: org.freedesktop.login1.Manager.PrepareForSleep (true,) ... # system resumes when 'PrepareForSleep' signal is 'false' # ... /org/freedesktop/login1: org.freedesktop.login1.Manager.PrepareForSleep (false,) ... -gdbus monitor --system --dest "$dbus_interface" | \ +dbus_process_sleep() { + local line while read -r line; do if [[ "$line" =~ $dbus_member ]]; then - if [[ "$line" =~ "true" ]]; then + if [[ "$line" =~ 'true' ]]; then ### SUSPEND ### - logger "[psd-suspend-sync] Issueing suspend-sync request..." + logger '[psd-suspend-sync] Issuing suspend-sync request...' /usr/bin/profile-sync-daemon suspend-sync # the lock will be released now - elif [[ "$line" =~ "false" ]]; then + break + elif [[ "$line" =~ 'false' ]]; then ### RESUME ### - logger "[psd-suspend-sync] re-taking inhibit lock..." + logger '[psd-suspend-sync] re-taking inhibit lock...' /usr/bin/profile-sync-daemon recycle-inhibit-lock + break fi fi done +} + +coproc bus ( + systemd-inhibit --mode="delay" --what="sleep" \ + --who="profile-sync-daemon" --why="psd resync on suspend" \ + gdbus monitor --system --dest "$dbus_interface" +) + +# keeps the inhibitor running until the system is about to sleep +dbus_process_sleep <& "${bus[0]}" + +# starts running before the system goes to sleep +dbus_process_sleep < <(gdbus monitor --system --dest "$dbus_interface") & + +# kill the inhibitor so that the system can sleep +[ -n "$bus_PID" ] && kill "$bus_PID" # vim:set ts=2 sw=2 et: diff --git a/common/psd.conf b/common/psd.conf index 6cbade77..41520687 100644 --- a/common/psd.conf +++ b/common/psd.conf @@ -10,7 +10,7 @@ # Uncomment and set to "yes" to use overlayfs instead of a full copy to reduce # the memory costs and to improve sync/unsync operations. Note that your kernel -# MUST have this module available in order to use this mode +# MUST have this module available in order to use this mode. # #USE_OVERLAYFS="no" @@ -64,7 +64,7 @@ #USE_BACKUPS="yes" # Uncomment and set to an integer that is the maximum number of crash recovery -# snapshots to keep (the oldest ones are delete first). +# snapshots to keep (the oldest ones are deleted first). # # The default is to save the most recent 5 crash recovery snapshots. #BACKUP_LIMIT=5 diff --git a/doc/psd-overlay-helper.1 b/doc/psd-overlay-helper.1 index 4556060e..dadf5a54 100644 --- a/doc/psd-overlay-helper.1 +++ b/doc/psd-overlay-helper.1 @@ -1,17 +1,17 @@ .TH psd-overlay-helper 1 "13 June 2016" "" "" .SH NAME -\fBpsd-overlay-helper \fP- Script to use overlay file system for profile-sync-daemon. +\fBpsd-overlay-helper \fP- Script enabling the "profile-sync-daemon" to use an 'overlay' file system in order to reduce the amount of writing operations. \fB .SH DESCRIPTION -Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile/profiles in tmpfs and to periodically sync back to the physical disc (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a tmpfs copy and media-bound backup of the browser profile/profiles. Additionally, psd features several crash recovery features. +Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile(s) in a 'tmpfs' file system and to periodically sync back to the main file system (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a copy on a tmpfs and media-bound backup of the browser profile(s). Additionally, psd hass several crash-recovery features. -The psd-overlay-helper script is used internally to enable the usage of the overlay file system. It should not be called by the user directly. +The psd-overlay-helper script is used internally to enable the usage of the 'overlay' file system. It should not be called by the user directly. .SH CONTRIBUTE -Users wishing to contribute to this project should fork it and send a pull request. Source is freely available on the project page linked below. +Users wishing to contribute to this project should fork it and send a pull request. The source code is freely available on the project page linked below. .SH ONLINE .IP \(bu 3 Project page: https://github.com/graysky2/profile-sync-daemon .IP \(bu 3 -Wiki page: https://wiki.archlinux.org/index.php/Profile-sync-daemon +Wiki page: https://wiki.archlinux.org/title/Profile-sync-daemon .SH AUTHOR graysky (graysky AT archlinux DOT us) diff --git a/doc/psd.1 b/doc/psd.1 index f122480b..dea933b2 100644 --- a/doc/psd.1 +++ b/doc/psd.1 @@ -1,10 +1,10 @@ .\" Text automatically generated by txt2man .TH profile-sync-daemon "22 September 2020" "" "" .SH NAME -\fBprofile-sync-daemon \fP- Symlinks and syncs browser profiles to RAM (tmpfs) thus reducing HDD/SSD calls and speeding up browsers. +\fBprofile-sync-daemon \fP- Symlinks and syncs browser profile(s) to RAM (thanks to tmpfs), thus reducing HDD/SSD activity and speeding-up browsers. \fB .SH DESCRIPTION -Profile-sync-daemon (psd) is a tiny pseudo-daemon designed to manage browser profile/profiles in tmpfs and to periodically sync back to the physical disc (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a tmpfs copy and media-bound backup of the browser profile/profiles. Additionally, psd features several crash-recovery features. +Profile-sync-daemon (psd) is a tiny pseudo-daemon (a systemd service) designed to manage browser profile(s) in a 'tmpfs' file system and to periodically sync back to the main file system (HDD/SSD). This is accomplished by an innovative use of rsync to maintain synchronization between a copy on a tmpfs and media-bound backup of the browser profile(s). Additionally, psd hass several crash-recovery features. .PP Design goals of psd: .RS @@ -16,20 +16,22 @@ Reduced wear to physical discs (particularly SSDs). Speed. .RE .PP -Since the profile/profiles, browser cache*, etc. are relocated into tmpfs (RAM disk), the corresponding I/O associated with using the browser is also redirected from the physical disc to the RAM, thus reducing wear to the physical disc and improving browser responsiveness. +Since the profile(s), browser cache*, etc. are relocated into tmpfs (sort-of RAM disk), the I/O corresponding to the browser activity is redirected from the physical disc to the RAM, thus reducing wear to the physical disc and improving responsiveness. .PP -*Note that some browsers such as Chrome/Chromium, Firefox (since v21), Midori, and Rekonq actually keep their cache directories separate from their browser profile directory. It is not within the scope of profile-sync-daemon to modify this behavior; users wishing to relocate this directory, may refer to the following url for several work-arounds: https://wiki.archlinux.org/index.php/Chromium_Tips_and_Tweaks#Cache_in_tmpfs +For the best overall performance using tmpfs along with swap space is recommended. +.PP +*Note that some browsers such as Chrome/Chromium, Firefox (since v21), Midori, and Rekonq actually keep their cache directories separate from their profile directory. Modifying this behavior is outside the scope of profile-sync-daemon ; users wishing to relocate this directory may refer to the following URL for several work-arounds: https://wiki.archlinux.org/title/Chromium#Cache_in_tmpfs .SH SETUP -$XDG_CONFIG_HOME/psd/psd.conf (referred to hereafter as "the config file") contains all user managed settings. +$XDG_CONFIG_HOME/psd/psd.conf (referred to hereafter as "the config file") contains all user-managed settings. .PP NOTE: edits made to the config file while psd is active will be applied only after the service has been restarted. .RS .IP \(bu 3 -Optionally enable the use of overlayfs to improve sync speed and to use a smaller memory footprint. Do this in the USE_OVERLAYFS variable. The user will require no password sudo rights to /usr/bin/psd-overlay-helper to use this option and the kernel must support overlayfs version 22 or higher. See the FAQ below for additional details. +Optionally enable the use of overlayfs to improve sync speed and to use a smaller memory footprint. Do this through the USE_OVERLAYFS variable. The 'sudo' utility must let the user account running the browser invoke /usr/bin/psd-overlay-helper as root without prompting for the password and the kernel must support overlayfs version 22 or higher. See the FAQ below for additional details. .IP \(bu 3 -Optionally have psd resync to the filesystem prior to a sleep call. This can help in the event that the system does not properly wake up. Do this in the USE_SUSPSYNC variable. +Optionally have psd resync to the filesystem prior to a power-management transition (suspend, hibernate...). This can help in the event that the system does not properly wake up. Do this in the USE_SUSPSYNC variable. .IP \(bu 3 -Optionally define which browsers are to be managed in the BROWSERS array. If none are defined, the default is all detected browsers. +Optionally define in the BROWSERS array which browser(s) is/are to be managed. If none is defined, the default is all detected browsers. .IP \(bu 3 Optionally disable the use of crash-recovery snapshots (not recommended). Do this in the USE_BACKUPS variable. .IP \(bu 3 @@ -39,17 +41,17 @@ Optionally define the number of crash-recovery snapshots to keep. Do this in the NOTE: occasionally, updates/changes are made to the default config file (/usr/share/psd/psd.conf) upstream. The user copy ($XDG_CONFIG_HOME/psd/psd.conf) will need to be diffed against it. .SH RUNNING PSD .SS PREVIEW MODE -The preview option can be called to show users exactly what psd will do/is doing based on the entries in the config file. It will also provide useful information such as profile size, paths, and if any recovery snapshots have been created. +The 'preview' option can be used to show exactly what psd will do/is doing based on the entries in the config file. It will also provide useful information such as profile size, paths, and (if any) existing recovery snapshot(s). .PP .nf .fam C $ psd p - Profile-sync-daemon v6.39 +Profile-sync-daemon v6.44 systemd service: active resync-timer: active - sync on sleep: enabled + sync on sleep: disabled use overlayfs: enabled Psd will manage the following per /home/facade/.config/psd/.psd.conf settings: @@ -78,7 +80,7 @@ The preview option can be called to show users exactly what psd will do/is doing .fam T .fi .SS START AND STOP PSD -Psd ships with a systemd user service to start or stop it (psd.service). Additionally, a provided resync-timer will run an hourly resync from tmpfs back to the disk. The resync-timer is started automatically with psd.service so there is no need to start the timer; only start psd.service. +Psd ships with a systemd user service to start or stop it (psd.service). Additionally, a provided resync-timer will run an hourly resync from tmpfs back to the main file system (HDD/SSD). The resync-timer is started automatically with psd.service so there is no need to start the timer: starting psd.service is sufficient. .PP .nf .fam C @@ -98,7 +100,7 @@ The clean mode will delete ALL recovery snapshots that have accumulated. Only ru .fam C $ psd c - Profile-sync-daemon v6.39 + Profile-sync-daemon v6.44 Deleting 2 crashrecovery dirs for profile /home/facade/.config/chromium /home/facade/.config/chromium-backup-crashrecovery-20200423_171359 @@ -193,7 +195,7 @@ Since psd is just a bash script with a systemd service, it should run on any fla .SH FAQ Q1: What is overlayfs mode? .PP -A1: Overlayfs is a simple union filesystem mainlined in the Linux kernel version 3.18.0. When used with psd, a reduced memory footprint and faster sync operations can be realized. The magic is in how the overlay mount only writes out data that has changed rather than the entire profile. The same recovery features psd uses in its default mode are also active when running in overlayfs mode. +A1: Overlayfs is a simple union filesystem type mainlined in the Linux kernel version 3.18.0. When used with psd, a reduced memory footprint and faster sync operations can be realized. The magic is in how the overlay mount only writes out data that has changed rather than the entire profile. The same recovery features psd uses in its default mode are also active when running in overlayfs mode. .PP See the example in the PREVIEW MODE section above which shows a system using overlayfs to illustrate the typical memory savings. Note the "overlayfs size" report compared to the total "profile size" report for each profile. Be aware that these numbers will change depending on just how much new data is written to the profile, but in common use cases, the overlayfs size will always be less than the profile size. .PP @@ -201,7 +203,7 @@ Q2: How do I enable overlayfs mode? .PP A2: First, be sure psd is not active or else any changes to the config file will be ignored until it is restarted. Overlayfs mode is enabled with the USE_OVERLAYFS= variable which should be set to "yes" in the config file. Psd will automatically detect the overlayfs version available to the kernel if it is configured to use one of them. It is recommended to run psd in preview mode to verify that the system can in fact use overlayfs. .PP -Users wanting to use overlayfs mode MUST have sudo rights without password prompt to /usr/bin/psd-overlay-helper or global sudo rights without password prompt. If the user does not have global rights, add the following line to /etc/sudoers after any other lines defining sudo access. It is recommended to use /usr/bin/visudo as root to set this up: +The user account using the browser MUST have sudo rights without password prompt to /usr/bin/psd-overlay-helper or global sudo rights without password prompt. If this account (hereby named 'foo') does not have global rights, add the following line to /etc/sudoers after any other lines defining sudo access. It is recommended to use /usr/bin/visudo as root to set this up: .PP .nf .fam C @@ -211,15 +213,15 @@ Users wanting to use overlayfs mode MUST have sudo rights without password promp .fi Q3: Why do I have another browser profile directory "foo-back-ovfs" when I enable overlayfs? .PP -A3: The way overlayfs works is to mount a read-only base copy (so-called lower dir) of the profile, and manage the new data on top of that. In order to avoid resyncing to the read-only filesystem, a copy is used instead. So using overlayfs is a trade-off: faster initial sync times and less memory usage vs. disk space in the home dir. +A3: The overlayfs works by mounting a read-only base copy (so-called "lower dir") of the profile, and manage the new data on top of that. In order to avoid resyncing to the read-only filesystem, a copy is used instead. So using overlayfs is a trade-off: faster initial sync times and less memory usage vs. disk space in the home dir. .PP -Q4: I need more memory to accommodate my profile/profiles in /run/user/xxxx. How can I allocate more? +Q4: I need more memory to accommodate my profile(s) in /run/user/xxxx. How can I allocate more? .PP -A4: The standard way of controlling the size of /run/user/ is the RuntimeDirectorySize directive in logind.conf (see the man page for logind.conf for more). By default, 10% of physical memory is used but one can increase it safely. Remember that tmpfs only consumes what is actually used; the number specified here is just a maximum allowed. +A4: The standard way of controlling the size of /run/user/ is the RuntimeDirectorySize directive in logind.conf (see the man page for logind.conf). By default, 10% of physical memory is used but one can increase it (beware: if you oversize your tmpfs instances the machine will deadlock, read about this at https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html ). Remember that tmpfs only consumes what is actually used; the number specified here is just a maximum allowed. .PP Q5: My system crashed for some reason and psd didn't sync back. What do I do? .PP -A5: The "last good" backup of the browser profile/profiles should be the filesystem. Upon restarting psd (on a reboot for example), a check is performed to see if the symlink to the tmpfs copy of the profile is invalid. If it is invalid, psd will snapshot the "last good" backup before it rotates it back into place. This is more for a sanity check that psd did no harm and that any data loss was a function of something else. +A5: The "last good" backup of the browser profile/profiles should be on the main file system (HDD/SSD). Upon restarting psd (on a reboot for example), a check is performed to see if the symlink to the tmpfs copy of the profile is invalid. If it is invalid, psd will snapshot the "last good" backup before rotating it back into place. This is more for a sanity check that psd did no harm and that any data loss was a done by something else. .PP Q6: Where can I find this snapshot? .PP diff --git a/init/psd-resync.service b/init/psd-resync.service index 3d13c162..1cca706d 100644 --- a/init/psd-resync.service +++ b/init/psd-resync.service @@ -7,6 +7,7 @@ BindsTo=psd.service [Service] Type=oneshot ExecStart=/usr/bin/profile-sync-daemon resync +Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target diff --git a/init/psd.service b/init/psd.service index d23d1b38..b1c42a00 100644 --- a/init/psd.service +++ b/init/psd.service @@ -11,6 +11,7 @@ Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/profile-sync-daemon startup ExecStop=/usr/bin/profile-sync-daemon unsync +Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target From e3b894504db00443f7b18a7c0c1966760ab7cfb5 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 10 Jun 2022 09:36:40 +0800 Subject: [PATCH 17/29] README formatting --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 628249bc..bcd91374 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,10 @@ If you are interested in packaging psd for your favorite distro, please contact ## logcheck Using logcheck? Here are some ways to filter out log lines: ```regexp +======= +```Regular Expression +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+]\]: .*(google-chrome|firefox) (re|un)sync successful +>>>>>>> 9662c1b (README formatting) ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon @@ -62,6 +66,4 @@ Using logcheck? Here are some ways to filter out log lines: ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)?\.service: Consumed [0-9\.]+s CPU time\.$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)\.timer: Succeeded\.$ -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: run-user-[0-9]+-[^[:space:]]+: Succeeded\.$ -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sudo:[[:space:]]+guest : PWD=/home/guest ; USER=root ; COMMAND=/usr/bin/psd-overlay-helper ``` From f87e9e9ec9ca5c50d4bcfb4b1403e9acc54e40ed Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 10 Jun 2022 09:37:28 +0800 Subject: [PATCH 18/29] README formatting --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index bcd91374..de699141 100644 --- a/README.md +++ b/README.md @@ -55,10 +55,7 @@ If you are interested in packaging psd for your favorite distro, please contact ## logcheck Using logcheck? Here are some ways to filter out log lines: ```regexp -======= -```Regular Expression ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+]\]: .*(google-chrome|firefox) (re|un)sync successful ->>>>>>> 9662c1b (README formatting) ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon From 80898534033c06baa11128d649178e7003befe99 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 10 Jun 2022 09:47:57 +0800 Subject: [PATCH 19/29] README minor fixes From 142f56b1de8e3585aa71755a5c2f509f11cd08b9 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 17 Jun 2022 18:10:20 +0800 Subject: [PATCH 20/29] testing --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index de699141..628249bc 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,6 @@ If you are interested in packaging psd for your favorite distro, please contact ## logcheck Using logcheck? Here are some ways to filter out log lines: ```regexp -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+]\]: .*(google-chrome|firefox) (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]: psd startup check successful$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: Started Timer for profile-sync-daemon @@ -63,4 +62,6 @@ Using logcheck? Here are some ways to filter out log lines: ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ profile-sync-daemon\[[0-9]+\]:[[:space:]]+[^[:space:]]+ (re|un)sync successful ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)?\.service: Consumed [0-9\.]+s CPU time\.$ ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: psd(-resync)\.timer: Succeeded\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[[0-9]+\]: run-user-[0-9]+-[^[:space:]]+: Succeeded\.$ +^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sudo:[[:space:]]+guest : PWD=/home/guest ; USER=root ; COMMAND=/usr/bin/psd-overlay-helper ``` From e9b4b09116ec9277c7b4fc6be67a2668d6a37301 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Fri, 17 Jun 2022 18:42:52 +0800 Subject: [PATCH 21/29] minor From b9053e1fd474847d3471811b038b2c8a1b5b8979 Mon Sep 17 00:00:00 2001 From: Nat Makarevitch Date: Sat, 25 Jun 2022 11:26:04 +0800 Subject: [PATCH 22/29] testing --- init/psd-resync.service | 1 - init/psd.service | 1 - 2 files changed, 2 deletions(-) diff --git a/init/psd-resync.service b/init/psd-resync.service index 1cca706d..3d13c162 100644 --- a/init/psd-resync.service +++ b/init/psd-resync.service @@ -7,7 +7,6 @@ BindsTo=psd.service [Service] Type=oneshot ExecStart=/usr/bin/profile-sync-daemon resync -Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target diff --git a/init/psd.service b/init/psd.service index b1c42a00..d23d1b38 100644 --- a/init/psd.service +++ b/init/psd.service @@ -11,7 +11,6 @@ Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/profile-sync-daemon startup ExecStop=/usr/bin/profile-sync-daemon unsync -Environment=LAUNCHED_BY_SYSTEMD=1 [Install] WantedBy=default.target From dd0fe212730d86631cce03603738f55832e63f2d Mon Sep 17 00:00:00 2001 From: Ranieri Althoff <1993083+ranisalt@users.noreply.github.com> Date: Fri, 26 Aug 2022 03:54:34 +0200 Subject: [PATCH 23/29] Move $VOLATILE to dedicated dir in $XDG_RUNTIME_DIR This is required to share the synced profiles with flatpak executables. $XDG_RUNTIME_DIR can't be shared, but specified directories inside it can, allowing flatpak-ed browsers to use psd. Keeps $PID_FILE in the same location for compatibility purposes. --- common/profile-sync-daemon.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 005bda9a..72ac79b4 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -33,8 +33,8 @@ XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" PSDCONFDIR="$XDG_CONFIG_HOME/psd" PSDCONF="$PSDCONFDIR/psd.conf" SHAREDIR="/usr/share/psd" -VOLATILE="$XDG_RUNTIME_DIR" -PID_FILE="$VOLATILE/psd.pid" +VOLATILE="$XDG_RUNTIME_DIR/psd" +PID_FILE="$XDG_RUNTIME_DIR/psd.pid" if [[ ! -d "$SHAREDIR" ]]; then echo -e " ${RED}ERROR:${NRM}${BLD} Missing ${BLU}$SHAREDIR${NRM}${BLD} - reinstall the package to use profile-sync-daemon.${NRM}" From c6a488c91aeb73e7cbed16a4f9ad84f1f0cb4212 Mon Sep 17 00:00:00 2001 From: graysky Date: Sun, 28 Aug 2022 16:10:34 -0400 Subject: [PATCH 24/29] VOLATILE at the end of the sync must match new value --- common/profile-sync-daemon.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 72ac79b4..432cb5ea 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -103,7 +103,7 @@ if [[ -f "$PID_FILE" ]]; then unset USE_OVERLAYFS USE_SUSPSYNC BROWSERS USE_BACKUPS BACKUP_LIMIT . "$PSDCONF" # defining VOLATILE in the config is deprecated since v6.16 - VOLATILE="$XDG_RUNTIME_DIR" + VOLATILE="$XDG_RUNTIME_DIR/psd" fi fi From 2a3f577779b351eadf3f4232de17541cbe8d05b4 Mon Sep 17 00:00:00 2001 From: graysky Date: Sat, 10 Sep 2022 05:42:29 -0400 Subject: [PATCH 25/29] psd.in: fix grep statement and VERSION closes #338 --- Makefile | 2 +- common/profile-sync-daemon.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7781c2da..4e66365e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 6.45 +VERSION = 6.48 PN = profile-sync-daemon PREFIX ?= /usr diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index 432cb5ea..c3256dc1 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -125,7 +125,7 @@ fi if [[ -z "$BROWSERS" ]]; then mapfile -t BROWSERS < <(find "$SHAREDIR/browsers" -type f -printf "%f\n") else - if ! declare -p BROWSERS | grep -q 'declare \-a'; then + if ! declare -p BROWSERS | grep -q 'declare -a'; then # did not setup as array so redefine it here IFS=' ' read -r -a BROWSERS <<< "${BROWSERS[@]}" fi From 1dfebd2279b3237e68556014227861db9ac77c84 Mon Sep 17 00:00:00 2001 From: Morgan Aldridge Date: Sat, 31 Dec 2022 22:51:46 -0500 Subject: [PATCH 26/29] Per XDG Base Directory Specification, create XDG_RUNTIME_DIR in /tmp if not set. Issue #343 --- common/profile-sync-daemon.in | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/common/profile-sync-daemon.in b/common/profile-sync-daemon.in index c3256dc1..082c6fee 100644 --- a/common/profile-sync-daemon.in +++ b/common/profile-sync-daemon.in @@ -28,13 +28,12 @@ VERS="@VERSION@" user=$(id -un) HOME="$(getent passwd "$user" | cut -d: -f6)" +TMPDIR="${TMPDIR:-/tmp}" XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" PSDCONFDIR="$XDG_CONFIG_HOME/psd" PSDCONF="$PSDCONFDIR/psd.conf" SHAREDIR="/usr/share/psd" -VOLATILE="$XDG_RUNTIME_DIR/psd" -PID_FILE="$XDG_RUNTIME_DIR/psd.pid" if [[ ! -d "$SHAREDIR" ]]; then echo -e " ${RED}ERROR:${NRM}${BLD} Missing ${BLU}$SHAREDIR${NRM}${BLD} - reinstall the package to use profile-sync-daemon.${NRM}" @@ -51,11 +50,31 @@ if [[ $EUID -eq 0 ]]; then exit 1 fi -if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then +# Create an XDG_RUNTIME_DIR if not given one (i.e. running without DE) +# See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html +if [[ -z "$XDG_RUNTIME_DIR" ]]; then + XDG_RUNTIME_DIR="${TMPDIR}/runtime-${user}" + echo -e " ${RED}WARNING:${NRM}${BLD} XDG_RUNTIME_DIR not set, defaulting to '${XDG_RUNTIME_DIR}'.${NRM}" + if [[ ! -d "$XDG_RUNTIME_DIR" ]] && ! mkdir "$XDG_RUNTIME_DIR"; then + echo -e " ${RED}ERROR:${NRM}${BLD} Unable to create runtime directory '${XDG_RUNTIME_DIR}'.${NRM}" + exit 1 + fi + if ! chown "${user}" "${XDG_RUNTIME_DIR}"; then + echo -e " ${RED}ERROR:${NRM}${BLD} Unable to make user '${user}' owner of runtime directory '${XDG_RUNTIME_DIR}'.${NRM}" + exit 1 + fi + if ! chmod 0700 "${XDG_RUNTIME_DIR}"; then + echo -e " ${RED}ERROR:${NRM}${BLD} Uname to make runtime directory '${XDG_RUNTIME_DIR}' only accessible to user '$user'.${NRM}" + exit 1 + fi +elif [[ ! -d "$XDG_RUNTIME_DIR" ]]; then echo -e " ${RED}ERROR:${NRM}${BLD} Cannot find XDG_RUNTIME_DIR which should be set by systemd.${NRM}" exit 1 fi +VOLATILE="$XDG_RUNTIME_DIR/psd" +PID_FILE="$XDG_RUNTIME_DIR/psd.pid" + # Setup check for config file if [[ -f "$PSDCONF" ]]; then if [[ ! -f "$PID_FILE" ]]; then From f2ca01cdf19653959a432d8815f42f2a4de9a7ff Mon Sep 17 00:00:00 2001 From: graysky Date: Sun, 1 Jan 2023 09:01:48 -0500 Subject: [PATCH 27/29] README and MIT: update --- MIT | 2 +- README.md | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MIT b/MIT index ad491691..80ff8e81 100644 --- a/MIT +++ b/MIT @@ -1,4 +1,4 @@ -Copyright (c) 2013-2021 graysky +Copyright (c) 2013-2023 graysky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 628249bc..40188942 100644 --- a/README.md +++ b/README.md @@ -38,16 +38,16 @@ To build from source, see the included INSTALL text document. ## Installation from Distro Packages ### Officially Packaged -* ![logo](http://www.monitorix.org/imgs/archlinux.png "arch logo")Arch: in the community [repo](https://www.archlinux.org/packages/community/any/profile-sync-daemon/). -* ![logo](http://freedos-32.sourceforge.net/lean/debian_logo.png "debian logo")Debian jessie+: in the official [repos](https://packages.debian.org/unstable/profile-sync-daemon). -* ![logo](https://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/Logo_Exherbo.svg/32px-Logo_Exherbo.svg.png "exherbo logo")Exherbo: in the official [repos](http://git.exherbo.org/summer/packages/net-www/profile-sync-daemon). -* ![logo](http://www.monitorix.org/imgs/gentoo.png "gentoo logo")Gentoo: in the official [repos](http://packages.gentoo.org/package/www-misc/profile-sync-daemon). -* ![logo](http://www.monitorix.org/imgs/ubuntu.png "ubuntu logo")Ubuntu 16.10+: in Universe [repo](https://packages.ubuntu.com/search?keywords=profile-sync-daemon). -* ![logo](https://www.monitorix.org/imgs/fedora.png "fedora logo")Fedora: in the official [repos](https://src.fedoraproject.org/rpms/profile-sync-daemon). +* Arch: in the community [repo](https://www.archlinux.org/packages/community/any/profile-sync-daemon/). +* Debian: in the official [repos](https://packages.debian.org/unstable/profile-sync-daemon). +* Exherbo: in the official [repos](http://git.exherbo.org/summer/packages/net-www/profile-sync-daemon). +* Fedora: in the official [repos](https://src.fedoraproject.org/rpms/profile-sync-daemon). +* Gentoo: in the official [repos](http://packages.gentoo.org/package/www-misc/profile-sync-daemon). +* NixOS: in the official [repo](https://search.nixos.org/packages?channel=22.11&from=0&size=50&sort=relevance&type=packages&query=profile-sync). +* Ubuntu: in Universe [repo](https://packages.ubuntu.com/search?keywords=profile-sync-daemon). ### User Packaged -* ![logo](https://i.postimg.cc/4x1Wtnkr/Chakra-shiny.png "chakra logo")Chakra: in the [CCR](https://ccr.chakralinux.org/packages.php?O=0&K=profile-sync-daemon). -* ![logo](http://wiki.codeblocks.org/images/8/8b/Slackware-logo_32.png "slack logo")Slackware: on [slackbuilds](http://slackbuilds.org/apps/profile-sync-daemon/). +* Slackware: on [slackbuilds](http://slackbuilds.org/apps/profile-sync-daemon/). ### Other Distros If you are interested in packaging psd for your favorite distro, please contact me. From 3dd2fe1057469d67ed9d6a614853d2cee4c78814 Mon Sep 17 00:00:00 2001 From: al-mission-2016 Date: Fri, 6 May 2022 02:05:04 +0300 Subject: [PATCH 28/29] Fix `surf` support (rm wrong '/') This trailing slash prevents `psd` to form a proper dir-name for backup/overlay, so `psd` does not work properly with `surf`, issuing the message: `stat: cannot statx '~/.surf/-backup': No such file or directory`. `surf` keeps its config in "~/.surf". Before this fix, the resulting backup dir is "~/.surf/-backup", not "~/.surf-backup" as it should be. This means that `psd` tries to create a backup inside the dir which it supposed to make backup of. :) After removing this unfortunate '/', `psd` works with `surf` correctly, making proper dirs: '~/.surf-backup' and '~/.surf-back-ovfs'. | sync target: /home/elf/.surf | tmpfs dir: /run/user/1000/elf-surf Note, that none of other browser's configs (in "/usr/share/psd/browsers/*") contains such trailing '/'. Thanks for you work on this Daemon! : ) --- common/browsers/surf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/browsers/surf b/common/browsers/surf index 6d91efee..be0e2260 100644 --- a/common/browsers/surf +++ b/common/browsers/surf @@ -1,2 +1,2 @@ -DIRArr[0]="$HOME/.$browser/" +DIRArr[0]="$HOME/.$browser" PSNAME="$browser" From 9cbc9f63b2b7c8f035c9dba1d8189522624195e4 Mon Sep 17 00:00:00 2001 From: Michael McCulloch Date: Fri, 29 Apr 2022 16:05:16 -0600 Subject: [PATCH 29/29] Add vscode dir --- contrib/vscode | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 contrib/vscode diff --git a/contrib/vscode b/contrib/vscode new file mode 100644 index 00000000..4ade9c5b --- /dev/null +++ b/contrib/vscode @@ -0,0 +1,2 @@ +DIRArr[0]="$XDG_CONFIG_HOME/Code" +PSNAME="vscode"