aboutsummaryrefslogtreecommitdiff
path: root/pkgs/install.nix
diff options
context:
space:
mode:
authorChris Wells <chris@mathematicaster.org>2024-09-10 14:51:28 -0500
committerChris Wells <chris@mathematicaster.org>2024-09-10 14:51:28 -0500
commit4f471484b3a1e16230979a8406503a220b9101f4 (patch)
treedc3f5256f275f34d3bcc9573462ed34c7fd97f77 /pkgs/install.nix
parent5cb16c34a8c5b803ec723934c1dc828c0e8e3bad (diff)
downloadkobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar
kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.gz
kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.bz2
kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.lz
kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.xz
kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.zst
kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.zip
I think this is almost working!
Diffstat (limited to 'pkgs/install.nix')
-rw-r--r--pkgs/install.nix110
1 files changed, 0 insertions, 110 deletions
diff --git a/pkgs/install.nix b/pkgs/install.nix
deleted file mode 100644
index e25108d..0000000
--- a/pkgs/install.nix
+++ /dev/null
@@ -1,110 +0,0 @@
-{ writeShellApplication
-, coreutils
-, gnugrep
-, rsync
-, util-linux
-, koboLabel ? "KOBOeReader"
-, ... }: writeShellApplication {
- name = "KoboInstaller";
- runtimeInputs = [
- coreutils
- gnugrep
- rsync
- util-linux
- ];
- text = ''
- INPUT=${1-}
-
- if [[ -z "$INPUT" ]]; then
- echo "Must provide an input directory"
- exit 255
- fi
-
- if [[ ! -d "$INPUT/.kobo" ]] || [[ ! -d "$INPUT/.adds" ]]; then
- echo "Missing one of $INPUT/.kobo or $INPUT/.adds. Are you sure your input directory is correct?"
- exit 255
- fi
-
- KOBO_MOUNTPOINT="$(findmnt -nlo TARGET LABEL="${koboLabel}")"
- if [[ -z "$KOBO_MOUNTPOINT" ]]; then
- echo "Couldn't find a Kobo eReader volume! Is one actually mounted?"
- exit 255
- fi
-
- KOBO_DIR="$KOBO_MOUNTPOINT/.kobo"
- if [[ ! -d "$KOBO_DIR" ]]; then
- echo "It doesn't seem like $KOBO_MOUNTPOINT actually points to a Kobo eReader since it doesn't contain a .kobo directory..."
- exit 255
- fi
-
- # Tiny DRY helper for the failure message...
- recap_failure() {
- echo "* As a result, the device may have been left in an inconsistent state!"
- echo "* Please note that NO automatic cleanup will be done!"
- echo "* As such, before unplugging your device, consider removing:"
- echo "* The following folders:"
- for kfm_folder in .adds/kfmon .adds/koreader .adds/plato ; do
- local current_folder="$KOBO_MOUNTPOINT/$kfm_folder"
- if [[ -d "$current_folder" ]] ; then
- printf "\t%s\n" "$current_folder"
- else
- printf "\t%-96s%32s\n" "$current_folder" "[OK: Already gone]"
- fi
- done
- echo "* As well as the following files:"
- for kfm_file in .kobo/KoboRoot.tgz kfmon.png koreader.png icons/plato.png ; do
- local current_file="$KOBO_MOUNTPOINT/$kfm_file"
- if [[ -f "$current_file" ]] ; then
- printf "\t%s\n" "$current_file"
- else
- printf "\t%-96s%32s\n" "$current_file" "[OK: Already gone]"
- fi
- done
- }
-
- KOBO_CONFIG="$KOBO_DIR/Kobo/Kobo eReader.conf"
- echo "* Preventing Nickel from scanning hidden directories . . ."
- cat >> "${KOBO_CONFIG}" <<-\EoM
-
- [FeatureSettings]
- ExcludeSyncFolders=(\\.(?!kobo|adobe).+|([^.][^/]*/)+\\..+)
- EoM
-
- # Check for a cat failure, as unlikely as it might be (permissions?)...
- ret=$?
- if [[ $ret -ne 0 ]] ; then
- echo "* Installation FAILED: Failed to update Nickel config!"
- echo "* No permanent changes have been made."
- exit $ret
- fi
-
- # Double-check that it was updated, in case of gremlins attack...
- if ! grep -Fq 'ExcludeSyncFolders=(\\.(?!kobo|adobe).+|([^.][^/]*/)+\\..+)' "${KOBO_CONFIG}" ; then
- echo "* Installation FAILED: Nickel config update was ineffective o_O !"
- echo "* No permanent changes have been made."
- exit 255
- fi
-
- echo "* Installing Kobo package"
- rsync -vr "$INPUT/" "$KOBO_MOUNTPOINT"
-
- ret=$?
- if [[ $ret -ne 0 ]]; then
- echo "* Installation FAILED: Failed to copy archive!"
- recap_failure
- exit $ret
- fi
-
- echo "* Sanity check . . ."
- if [[ ! "$KOBO_DIR/KoboRoot.tgz" ]]; then
- echo "* Installation FAILED: Copying was ineffective (no KoboRoot tarball) o_O !"
- recap_failure
- exit 255
- fi
-
- echo "* Installation successful!"
- echo "* Please make sure to eject & unplug your device safely!"
-
- exit 0
- '';
-}