Adding latest work
This commit is contained in:
58
rdify
Normal file → Executable file
58
rdify
Normal file → Executable file
@ -1,19 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
#!/usr/bin/env python
|
||||
# Script to ramdiskify things
|
||||
|
||||
Init()
|
||||
{
|
||||
if [[ -L $1 ]] && [[ -e $1 ]]; then
|
||||
#statements
|
||||
fi
|
||||
}
|
||||
import argparse
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
Sync()
|
||||
{
|
||||
def eprint(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
}
|
||||
|
||||
# TODO Optargs block
|
||||
def init(target, persist):
|
||||
ramdisk = Path("/dev/shm/ramdisk")
|
||||
ramdisk.mkdir(parents=True, exist_ok=True)
|
||||
target = Path(target)
|
||||
persist = Path(persist)
|
||||
persist.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def sync(target, persist):
|
||||
pass
|
||||
|
||||
def loop_sync(target, persist):
|
||||
pass
|
||||
|
||||
def cleanup(target, persist):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
# Arguments to specify the action to take
|
||||
action = parser.add_mutually_exclusive_group(required=True)
|
||||
action.add_argument("-i", "--init", action="store_true", help="Initialize the target file/directory into ramdisk")
|
||||
action.add_argument("-s", "--sync", action="store_true", help="Perform a single sync of the target from ramdisk to persistent storage")
|
||||
action.add_argument("-l", "--loop-sync", type=int, help="Starts a repeating sync that loops every LOOP_SYNC seconds")
|
||||
action.add_argument("-c", "--cleanup", action="store_true", help="clean up an existing ramdiskified target")
|
||||
# Arguments to specify what to act on
|
||||
parser.add_argument("target", help="The target file/directory to ramdiskify")
|
||||
parser.add_argument("persist", nargs="?", default=".persist", help="The location to store the persistent copy while ramdiskified, defaults to '.persist'")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if not Path(args.target).exists():
|
||||
eprint(f"Target: {args.target} doesn't exist!")
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Reference in New Issue
Block a user