Commit Graph

302 Commits

Author SHA1 Message Date
Antynea
9d436adf95 Reworks many things (#174)
#### Script:
* Snapper:
  - Now, the information is retrieved from the info.xml file.

* Timeshift:
  * Now, the information is retrieved from the info.json file.

* Probe informations from device:
  * Add the UUID of the root and boot subvolumes

* Show full path snapshot or only name:
  * Remove, this feature never worked correctly

* Grub-menu:
  * Now displays the following information in separate columns:
    - Date of snapshot
    - Path of snapshot
    - Type/Tags of snapshot if available (snapper/timeshift)
    - Description/Comments of snapshot if available (snapper/timeshift)
  * Possibility to display only the desired information(s) (see config file)
  *  Adds a header for the column title
  * GRUB_BTRFS_PREFIXENTRY is remove

  * Boot partition detection:
    * grub-btrfs is now able to detect if the boot folder/partition is a subvolume
    * GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION should no longer be needed for this case

  * Variables:
    * Rename some variables

  * Header:
    * Update the header to reflect the changes.

#### Config:
* GRUB_BTRFS_PREFIXENTRY:
  * Remove, no longer use

* GRUB_BTRFS_DISPLAY_PATH_SNAPSHOT:
  * Remove, no longer use

* GRUB_BTRFS_TITLE_FORMAT:
  * Shows/Hides "date" "snapshot" "type" "description" in the Grub menu, custom order available.
    Default: ("date" "snapshot" "type" "description")

* GRUB_BTRFS_IGNORE_SNAPPER_TYPE:
  * Rename to GRUB_BTRFS_IGNORE_SNAPSHOT_TYPE
    - Supports both timeshift and snapper tags/type

* GRUB_BTRFS_IGNORE_SNAPPER_DESCRIPTION:
  * Rename to GRUB_BTRFS_IGNORE_SNAPSHOT_DESCRIPTION
    - Supports both snapper and timeshift description/comments

* GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION:
  * grub-btrfs is now able to detect if the boot folder/partition is a subvolume.
  Activating this parameter should no longer be necessary for this case.

* GRUB_BTRFS_SNAPPER_CONFIG:
  * Remove, no longer use

#### Readme:
* Update "What does grub-btrfs v4.xx do" section
  * Adds support for timeshift
2021-10-25 15:47:26 +02:00
Antynea
301752f300 Update count_limit_snap arithmetic
* Update count_limit_snap arithmetic:
  * "$" isn't required in an arithmetic function
2021-10-21 16:59:08 +02:00
Antynea
3b857348cb Update wait_max arithmetic
* Update wait_max arithmetic:
  * "$" isn't required in an arithmetic function
2021-10-21 16:54:11 +02:00
Antynea
f3d8e99cb8 Update count_warning_menuentries arithmetic
* Update count_warning_menuentries arithmetic:
  * "$" isn't required in an arithmetic function
2021-10-21 16:50:51 +02:00
Antynea
af80fe7993 Comments unused variables
* Comments unused variables:
  * This "$prefix_i" and "$suffix_i" are for information purposes only, and aren't used.
2021-10-21 16:44:59 +02:00
Antynea
c7f403d2a2 Update "GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU"
* Update "GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU":
  * Remove default parameter (false), not needed
  * adds automatic conversion of the value to lower case
2021-10-21 16:39:17 +02:00
Antynea
e6898c0de8 Update disable_script function
* Update disable_script function:
  * A function is no longer required since the commands have been moved to the beginning of the script.
2021-10-21 16:36:12 +02:00
Antynea
a790ff054e "disable_script" function breaks "grub-mkconfig"
* "disable_script" function breaks "grub-mkconfig":
  * Replace "return 1" by "exit 0".
v4.10.2
2021-10-07 17:31:45 +02:00
Antynea
df643361cc Add Gentoo and OpenRC instructions
* Add Gentoo instructions in "Installation :" section.
* Add OpenRC instructions in "Automatically update grub :" section
2021-10-07 16:52:44 +02:00
Antynea
b0408225c1 Fix bug Create entries with matching version (#170)
* Fix #169 
  * Create entries with matching version doesn't work properly:
  Adds missing "else continue;"
v4.10.1
2021-09-26 19:05:02 +02:00
Antynea
8142691be1 Adds missing newline
* Adds missing newline:
  "\n" was missing.
v4.10
2021-09-24 15:54:04 +02:00
Antynea
bab78d4ed8 Write-protect user data
* Write-protect user data
  * The script does not need write access to the data.
  Adds "ro" flags to provide protection against accidental writing.
2021-09-24 12:24:15 +02:00
Antynea
544d2e84ac Adds security if a false positive is detected
* Adds security if a false positive is detected:
  * if the command "grep -qs "$gbgmp" /proc/mounts;" returns a false positive.
  "rm -d" will return an error if the directory is not empty.
2021-09-24 12:12:43 +02:00
Antynea
b346727219 Deletes unused code
* Deletes unused code:
  * Limit generation of menuentries if exceeds 250 has never been used.
  Uses "GRUB_BTRFS_LIMIT" (default 50) instead
2021-09-23 15:28:28 +02:00
Antynea
f1ca0db36d Update header installation section
* Update header installation section:
  * Remove instructions
  (Refet to the project website, installation section)
2021-09-23 14:54:59 +02:00
Antynea
c4d0df3a97 Rework the creation of the "grub-btrfs.cfg" file.
* Rework the creation of the "grub-btrfs.cfg" file:
  * Before, the "grub-btrfs.cfg" file was deleted and then the new configuration was written.
  No backup was made.
  * Now, the new configuration will be written in a temporary file "grub-btrfs.new" and then analysed with the "grub_script_check" command before being finally written in the "grub-btrfs.cfg" file.
  If an error is detected, the "grub-btrfs.new" file will coexist with the old "grub-btrfs.cfg" file, if it exists.
2021-09-23 14:49:56 +02:00
Antynea
c1cadccd1f Adds trap command on EXIT signal
* Adds trap command on EXIT signal:
  * Now umount command will launch on EXIT signal. 
  * Adds a function called by the trap on EXIT signal to unmount and delete the temporary folder. 
  (That should be the end of multiple tmp.xxxxxxxxxx in /tmp)
    - If the command fails, retry every 2 seconds. After 10 attempts, it will stop and display a warning.
    - If the command is successful, "Succes" will be displayed.
  * Adds "grub-btrfs" as a prefix to the temporarie mount folder.
  (before = tmp.xxxxxxxxx , now = grub-btrfs.xxxxxxxxxx)
2021-09-23 11:49:21 +02:00
Antynea
8cc214fd0e Corrects printf format string
* Corrects printf format string:
  * printf interprets escape sequences and format specifiers in the format string. If variables are included, any escape sequences or format specifiers in the data will be interpreted too, when you most likely wanted to treat it as data.
2021-09-22 19:08:55 +02:00
Antynea
81bde02b03 Update "Installation section"
* Update "Installation section":
  * Adds required dependencies
  * Indicates that the command "update-grub", is an alias to "grub-mkconfig" on Debian-like distributions.
2021-09-22 17:07:44 +02:00
Antynea
14bf041ba6 Deactivate the script as soon as possible
* With these changes, the script will be disabled as soon as possible, if :
  * "GRUB_BTRFS_DISABLE" If this variable is set to "true"
  * "btrfs-progs isn't installed" This package is required to retrieve information from the btrfs filesystem.
  * "grub-mkconfig_lib couldn't be found" This library is required because the script depends on it.
  * "Root filesystem isn't btrfs" grub-btrfs currently checks only the btrfs snapshots present on the root partition.
2021-09-22 15:49:02 +02:00
Antynea
863107588c Remove redundant check
Running a command and then checking its exit status $? against 0 is redundant.
Instead of just checking the exit code of a command, it checks the exit code of a command that checks the exit code of a command.
2021-09-22 15:40:05 +02:00
Antynea
2851ecd72b Removes double negation in file test operators
* Removes double negation in file test operators:
  * Replaces the "! -z" operator with "-n".
2021-09-22 15:31:03 +02:00
Antynea
679d000446 Add possibility to boot without init (#164)
* Add possibility to boot without init(rd,ramfs):
  - For a snapshot to be valid, it must contain a boot folder and a kernel from the official list (or have been added to the custom kernel list)
  - if a snapshot doesn't contain an init(rd,ramfs), it will be detected as valid.
  - Suppress script stop when an init is not found
  - If init isn't found, add the letter "x" to the init list. (hoping this doesn't break the support for custom init names)
  - The microcode support is still present, despite the absence of init(rd,ramfs), is it really relevant ?
2021-09-17 15:39:23 +02:00
Antynea
981777d745 Add filter snapper's snapshot (#158)
- Add filter to ignore snapper's snapshot "type or description" during run "grub-mkconfig"

- Two new variables available in the config file:
# Ignore specific type of snapper's snapshot during run "grub-mkconfig".
# Type = single, pre or post.
# Default: ("")
GRUB_BTRFS_IGNORE_SNAPPER_TYPE=("")

# Ignore specific description of snapper's snapshot during run "grub-mkconfig".
# Default: ("")
GRUB_BTRFS_IGNORE_SNAPPER_DESCRIPTION=("")
2021-07-14 12:48:20 +02:00
Björn Daase
3433754c69 Makefile: Make sure make is invoked with appropriate permissions (#146) v4.9 2021-03-01 13:35:44 +01:00
Antynea
db753a9ac8 41_snapshots: update header
* 41_snapshots: update header
  * Update "Automatically update Grub" section.
  * Update "Purpose" section.
  * Update "What this script does" section
2021-02-21 15:37:43 +01:00
Antynea
83bf1da01e Improves systemd.path unit (#139)
* grub-btrfs.path : improves unit

#### Remember to modify your configuration accordingly.  
Allows the unit to start and stop automatically when the mount point is detected.  
If the mount point is already mounted when the unit is activated `systemctl enable grub-btrfs.path`,  
it will be necessary to start the unit for monitoring to begin `systemctl start grub-btrfs.path`.

- `DefaultDependencies=no`
Prevents systemd from automatically generating `Wants= or Requires= or After=`.
- `Requires=\x2esnapshots.mount`
Ensures unit is started if mount point exists.
- `After=\x2esnapshots.mount`
Unit start after the mounting point exists.
- `BindsTo=\x2esnapshots.mount`
If the mount point is removed, the unit will stop.
- `PathModified=\x2esnapshots.mount`
The monitored folder containing the snapshots.
- `WantedBy=\x2esnapshots.mount`
If the mount point exists, unit start automatically. (only if unit is activated before the mount point is mounted)

* Readme: Update "Automatically update grub" section

Update section following the recent change in the `grub-btrfs.path` unit.  
Add information to be able to update the `grub-btrfs` menu every time the system is restart/shutdown.
2021-02-21 05:26:39 +01:00
Kriss
2f22fd8630 [make help] mention INITCPIO switch (#137)
This commit is an expansion to :
87b816345b

Since a new `make` parameter has been introduced, it should be mentioned
in the output of the `help` target.

Also, the table is being expanded by a new column describing the type of
data that each parameter may be assigned, like paths or boolean values.
v4.8.1
2021-01-23 20:46:14 +01:00
Antynea
88a0320d62 [Makefile] remove mkinitcpio dependency (#136)
Errata commit:
This commit has no substantive code change.
This commit is provided only to document a correction to a previous commit message.
This pertains to commit object 87b816345b

Due to improper handling, the aforementioned commit message is incorrect.
Correct message is :

[Makefile] remove `mkinitcpio` dependency

The mkinitcpio binary is not available even on Arch,  when building in a
clean environment (e.g. building distro packages in a clean chroot).

This causes the mkinitcpio hook  to not be present in the final package,
which is resolved by this commit, by adding a `make` switch. This switch
allows users to explicitely turn on inclusion of the hook.

[uninstall:] don't remove non-existent folders

This prevents some warnings being output when on a non-Archlinux system,
without a previously installed initcpio hook, a `make uninstall` is per-
formed.

These three folders should _only_ be deleted if they had been mistakenly
created during `make install`.

Co-authored-by: Kriss <kr1ss.x@yandex.com>
2021-01-23 12:02:11 +01:00
Kriss
87b816345b [Makefile] remove mkinitcpio dependency (#136)
[Makefile] remove `mkinitcpio` dependency
2021-01-17 22:25:10 +01:00
Kriss
d68fdf5fff Adds a new config variable "GRUB_BTRFS_ROOTFLAGS" (#133)
Script:

Improves the rootflags option in the kernel command line:
- Remove "rw" flag.
- Parse fstab mountoptions and add them to rootflags:
Adds functionality to read in  snapshot specific mount flags
from the respective fstab and uses them in combination with the new 
config option, while the latter is prioritized.
Both places can, but don't need to define mount flags. If either of them
doesn't, it will simply not be taken into account.

Config file:

Adds a new config variable "GRUB_BTRFS_ROOTFLAGS":
- The new variable is used to include user-defined rootflags in the 
kernel command line of generated snapshot bootmenu entries.
See config file for more infos.
v4.8
2021-01-11 13:37:40 +01:00
Kriss
87168d2d50 [Makefile] Modifies install/uninstall target. Adds help target (#135)
Makefile:

Install target:
- Added "uninstall" and "help" target to ".phony".
- Hook initcpio will be installed only on Arch Linux like distributions.

Uninstall target:
- All commands are in silent mode.
- "rmdir" command will not interrupt the uninstallation if the folder does not exist.
- Remove "-r" option to "rm" command.
- Fix a mistake in deleting the "readme" file.
- Uninstalling the "grub-btrfs.cfg" file uses the "GRUB_BTRFS_GRUB_DIRNAME" variable.
- Delete initcpio folder if not on Arch.
- Delete "grub-btrfs" docs and licenses folders.

help target:
- Add "help" target.
2021-01-11 13:04:09 +01:00
Antynea
a437b80a35 improves systemd service (#131)
grub-btrfs.service: remove unnecessary path for bash and grub-mkconfig command

readme.md: add warning section to systemd service section

config file: Improves the description of the variable GRUB_BTRFS_MKCONFIG
2021-01-03 14:50:34 +01:00
Antynea
9408231ecc Corrects an erroneous variable (#128)
Fix #127
Replaces "GRUB_BTRFS_DIRNAME" variable to match with new variable "GRUB_BTRFS_GRUB_DIRNAME" in config file.
v4.7.2
2020-12-30 15:31:28 +01:00
Antynea
9722f6732c Corrects a mistake
Corrects the duplicate that appeared
Line16 should be :
`@install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-hook" "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"		# Arch Linux only`
v4.7.1
2020-10-22 21:19:54 +02:00
Antynea
0ed5adaf32 Fix indentation
My IDE was set up incorrectly.
Convert all tab indentation to space.
v4.7
2020-10-22 07:07:30 +02:00
Antynea
d4b97415b0 Fix #116 (#118)
* Fix #116 (#118)
  * Renames variable GRUB_BTRFS_DIRNAME to GRUB_BTRFS_GRUB_DIRNAME and improves its description

  * Adds variable GRUB_BTRFS_BOOT_DIRNAME, used to detect the boot partition and the location of kernels/initrafms/microcodes
2020-10-21 19:14:05 +02:00
Antynea
da36aa8847 Update header
* Update header about read-only snapshots.
2020-10-15 16:27:32 +02:00
Antynea
d8df766554 Update README.md
* Update link to /initramfs/readme
2020-10-14 15:29:50 +02:00
Antynea
9adce629f7 Boot on read-only snapshot (#115)
* Create a initramfs folder & configuration files
  * create a initramfs folder
  * create Arch Linux folder
  * Add `HOOK/INSTALL` files to generate a custom initrafms for boot on read-only snapshot for Arch Linux.
  * Add readme file to initramfs folder

* Makefile changes
  * Add readme file
  * Add readme file of initramfs-overlayfs
  * Add HOOK/INSTALL files for Arch Linux

* Readme changes
  * Updates the documentation to be able to boot on a read-only snapshot.
  * Redesign readme again.
2020-10-14 15:17:07 +02:00
Antynea
3c5e741641 Modify "grub btrfs dirname" variable. (#113)
* Modify "GRUB_BTRFS_DIRNAME"
  * Full path to Grub folder is now configurable (/boot is no longer hard coded).
  * Detection of the boot partition is now based on the location of the Grub folder.
  * Warning [see](https://github.com/Antynea/grub-btrfs/pull/113#issuecomment-705916729)
2020-10-09 15:50:02 +02:00
Antynea
fa65c3d6d9 move rmdir to end of uninstall section
If rmdir fails, other commands are not executed, so
move rmdir to end of uninstall section
2020-10-09 02:32:25 +02:00
Antynea
4493bdc6e4 Clean code
Remove commented commands that are no longer needed.
2020-10-07 02:00:23 +02:00
Antynea
a7289b182a Remove several variables not necessary
For easier maintenance,
remove several variables already present in the config file.
2020-10-07 00:36:06 +02:00
Antynea
0fe512776a Modify the function which is used to ignore a path. (#112)
Modify the function which is used to ignore a path.
@ shouldn't be hardcoded.
Create 2 separate functions to ignore a specific path or prefix path.
In specific path, only exact paths are ignored.
In prefix path, any path starting with the specified string will be ignored.
e.g :
if specific path = @, only @ snapshot will be ignored.
if prefix path = @, all snapshots beginning with "@/..." will be ignored.
2020-10-06 23:19:41 +02:00
Antynea
6af193c47a Add new path to ignore docker subvolume
Many distributions now use "@" as the default subvolume.
Add the following path "@/var/lib/docker" to ignore the docker subvolume.
Fix: #110
2020-10-03 12:51:51 +02:00
Antynea
9a771d9842 Stop script if root partition isn't btrfs filesystem
Add filesystem check on the root partition.
If the filesystem isn't btrfs, stop execution.
Update error message for btrfs-prog.
2020-10-01 19:37:43 +02:00
Antynea
64c08a0807 Update header
Update header to reflect change on [Automatically update grub](https://github.com/Antynea/grub-btrfs#automatically-update-grub) section
Remove many `#` characters
2020-10-01 19:28:45 +02:00
Antynea
c9b605153b Redesign readme (#109)
* Add more information

Add more information.
Due to the redesign of the "Customization" section of the readme file.

* Redesign  customization section

Move information of customization section to config file
2020-09-29 13:39:20 +02:00
Antynea
7e922abefb Update "Automatically update grub" section
Update "Automatically update grub" section.
Correct a mistake.
2020-09-28 00:58:21 +02:00