Split fedora and manjaro playbooks
Split playbooks to better accomodate development of both.
This commit is contained in:
65
tools/btrfs_backup/btrfs_backup.py
Executable file
65
tools/btrfs_backup/btrfs_backup.py
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import subprocess
|
||||
import pathlib
|
||||
import os
|
||||
import logging
|
||||
import asyncio
|
||||
|
||||
|
||||
async def notify(level, message):
|
||||
# notify = desktop_notify.aio.Notify(level, message)
|
||||
# await notify.show()
|
||||
notify_cmd = ["backup/notify.sh", level, message]
|
||||
notify = subprocess.run(notify_cmd, capture_output=True)
|
||||
|
||||
def is_mountpoint(path):
|
||||
mountpoint_cmd = ["mountpoint", str(path)]
|
||||
logging.info(' '.join(mountpoint_cmd))
|
||||
check = subprocess.run(mountpoint_cmd, capture_output=True)
|
||||
if check.returncode != 0: # not a mountpoint
|
||||
logging.error(check.stdout.decode().strip())
|
||||
return False
|
||||
else:
|
||||
logging.info(check.stdout.decode().strip())
|
||||
return True
|
||||
|
||||
|
||||
async def main():
|
||||
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.DEBUG)
|
||||
|
||||
subvolumes_to_backup = ["home", "root"]
|
||||
logging.info(f"Backing up {', '.join(subvolumes_to_backup)}")
|
||||
btrfs_subvolume = "/btrfs"
|
||||
snapshot_subvolume = f"{btrfs_subvolume}/snapshots"
|
||||
snapshot_path = pathlib.Path(snapshot_subvolume)
|
||||
old_snapshots = os.listdir(snapshot_path)
|
||||
|
||||
for snapshot in old_snapshots:
|
||||
delete_cmd = ["btrfs", "sub", "del", f"{snapshot_path}/{snapshot}"]
|
||||
logging.info(' '.join(delete_cmd))
|
||||
delete = subprocess.run(delete_cmd, capture_output=True)
|
||||
|
||||
for subvolume in subvolumes_to_backup:
|
||||
snapshot_cmd = [
|
||||
"btrfs", "sub", "snap", "-r", f"{btrfs_subvolume}/{subvolume}", f"{snapshot_path}"]
|
||||
logging.info(' '.join(snapshot_cmd))
|
||||
create_new_snap = subprocess.run(snapshot_cmd, capture_output=True)
|
||||
|
||||
backup_mountpoint = pathlib.Path("/mnt/53de8433-6394-408c-a856-5f3b9908f21f")
|
||||
snapshots = os.listdir(snapshot_path)
|
||||
|
||||
if is_mountpoint(backup_mountpoint):
|
||||
for new_snapshot in snapshots:
|
||||
backup_cmd = ["rsync", "-av", "--delete",
|
||||
f"{snapshot_path}/{new_snapshot}/",
|
||||
f"{backup_mountpoint}/{new_snapshot}/"]
|
||||
logging.info(' '.join(backup_cmd))
|
||||
rsync = subprocess.run(backup_cmd, capture_output=True)
|
||||
await notify(f"{new_snapshot} backup successful", ' '.join(backup_cmd))
|
||||
else:
|
||||
await notify(f"{new_snapshot} backup failed", f"{backup_mountpoint} is not mounted")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
8
tools/btrfs_backup/notify.sh
Executable file
8
tools/btrfs_backup/notify.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
|
||||
export USER=ducoterra
|
||||
|
||||
LEVEL=$1
|
||||
MESSAGE=$2
|
||||
sudo -E -u $USER notify-send "$LEVEL" "$MESSAGE" --expire-time 10
|
||||
20
tools/framework_fingerprint/clear_storage.py
Normal file
20
tools/framework_fingerprint/clear_storage.py
Normal file
@@ -0,0 +1,20 @@
|
||||
#! /usr/bin/python3
|
||||
|
||||
import gi
|
||||
gi.require_version('FPrint', '2.0')
|
||||
from gi.repository import FPrint
|
||||
|
||||
ctx = FPrint.Context()
|
||||
|
||||
for dev in ctx.get_devices():
|
||||
print(dev)
|
||||
print(dev.get_driver())
|
||||
print(dev.props.device_id);
|
||||
|
||||
dev.open_sync()
|
||||
|
||||
dev.clear_storage_sync()
|
||||
print("All prints deleted.")
|
||||
|
||||
dev.close_sync()
|
||||
|
||||
1
tools/framework_fingerprint/libfprint
Submodule
1
tools/framework_fingerprint/libfprint
Submodule
Submodule tools/framework_fingerprint/libfprint added at 5e4bb26801
@@ -0,0 +1,54 @@
|
||||
# Import PyGObject
|
||||
# PyGObject is a Python package which provides bindings for GObject based libraries such as GTK, GStreamer, WebKitGTK, GLib, GIO and many more.
|
||||
from gi import require_version
|
||||
|
||||
# for arguments
|
||||
from sys import argv
|
||||
from os import geteuid
|
||||
|
||||
if geteuid() != 0:
|
||||
exit("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting.")
|
||||
|
||||
# Load FPrint gi module
|
||||
require_version('FPrint', '2.0')
|
||||
|
||||
# Import FPrint
|
||||
from gi.repository import FPrint
|
||||
|
||||
# Get FPrint Context
|
||||
fprint_context = FPrint.Context()
|
||||
|
||||
# Loop over FPrint devices
|
||||
for fprint_device in fprint_context.get_devices():
|
||||
|
||||
# Print device info
|
||||
print(fprint_device)
|
||||
print(fprint_device.get_driver())
|
||||
print(fprint_device.props.device_id)
|
||||
|
||||
# Open the device synchronously.
|
||||
fprint_device.open_sync()
|
||||
|
||||
# Get list of enrolled prints
|
||||
enrolled_fingerprints = fprint_device.list_prints_sync()
|
||||
print("Device has %d enrolled fingerprints." % len(enrolled_fingerprints))
|
||||
|
||||
# Loop through enrolled fingerprints
|
||||
for fingerprint in enrolled_fingerprints:
|
||||
|
||||
# Print fingerprint info
|
||||
date = fingerprint.props.enroll_date
|
||||
print(' %04d-%02d-%02d valid: %d' % (date.get_year(), date.get_month(), date.get_day(), date.valid()))
|
||||
print(' ' + str(fingerprint.props.finger))
|
||||
print(' ' + str(fingerprint.props.username))
|
||||
print(' ' + str(fingerprint.props.description))
|
||||
|
||||
# check for delete flag
|
||||
if (len(argv) > 1 and argv[1] == "-d"):
|
||||
# Delete print
|
||||
print('Deleting print:')
|
||||
fprint_device.delete_print_sync(fingerprint)
|
||||
print('Deleted')
|
||||
|
||||
# Close the device synchronously.
|
||||
fprint_device.close_sync()
|
||||
Reference in New Issue
Block a user