A desktop backup program focusing on ease-of-use and simplicity, as well as quality, low resource usage, and performance.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
EZ-Bkup/shared.nim

83 lines
2.9 KiB

#[Copyright 2023 ITwrx.
This file is part of EZ-Bkup.
EZ-Bkup is released under the General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]#
import logging, times, os, distros
#import "models/routine"
#store the RoutineIds of ea. Routine selected for the current Bkup run.
#[type SelectedRoutine* = object
id*: RoutineId
name*: string
sources*: seq[string]
destinations*: seq[string]
type CurrentRun* = object
status*: string]#
let appPath* = getHomeDir() & ".ez-bkup"
if not dirExists(appPath):
createDir(appPath)
var logger = newFileLogger(appPath & "/errors.log")
let dt = now()
let nowDT = dt.format("M-d-YYYY h:mm:ss tt")
var logMsg: string
proc writeErrorToLog*(logMsg: string) =
logger.log(lvlError, logMsg)
proc writeInfoToLog*(logMsg: string) =
logger.log(lvlInfo, logMsg)
proc hasCommas*(filename: string):bool =
',' in filename
proc getAskPassPath*(): string =
var askPassPath: string
if detectOs(Fedora):
if fileExists("/usr/libexec/openssh/ssh-askpass"):
askPassPath = "/usr/libexec/openssh/ssh-askpass"
else:
writeErrorToLog("No ssh-askpass binary found. Please run 'dnf install openssh-askpass'")
askPassPath = ""
elif detectOs(Ubuntu):
if fileExists("/usr/lib/openssh/gnome-ssh-askpass"):
askPassPath = "/usr/lib/openssh/gnome-ssh-askpass"
else:
writeErrorToLog("No ssh-askpass binary found. Please run 'sudo apt install ssh-askpass-gnome'.")
askPassPath = ""
#save this for a musl build.
#[elif detectOs(Alpine):
if fileExists("/usr/lib/ssh/gtk-ssh-askpass"):
askPassPath = "/usr/lib/ssh/gtk-ssh-askpass"
else:
writeErrorToLog("No ssh-askpass binary found. Please run 'apk add gtk-ssh-askpass'.")
askPassPath = ""]#
elif detectOs(ArchLinux):
if fileExists("/usr/lib/ssh/ssh-askpass"):
askPassPath = "/usr/lib/ssh/ssh-askpass"
else:
writeErrorToLog("No ssh-askpass binary found. Please run 'pacman -S x11-ssh-askpass', or similar.")
askPassPath = ""
elif detectOs(Linux):
if fileExists("/usr/libexec/openssh/ssh-askpass"):
askPassPath = "/usr/libexec/openssh/ssh-askpass"
elif fileExists("/usr/lib/openssh/gnome-ssh-askpass"):
askPassPath = "/usr/lib/openssh/gnome-ssh-askpass"
elif fileExists("/usr/lib/ssh/gtk-ssh-askpass"):
askPassPath = "/usr/lib/ssh/gtk-ssh-askpass"
elif fileExists("/usr/lib/ssh/ssh-askpass"):
askPassPath = "/usr/lib/ssh/ssh-askpass"
else:
writeErrorToLog("No ssh-askpass binary found. Please install an ssh-askpass package for your distro, and let us know if EZ-Bkup still can't detect it's location.")
askPassPath = ""
else:
writeErrorToLog("Your OS does not appear to be supported at this time. If you are getting this error and you are using a x86_64 gnu libc-based linux distribution please report this issue. Please include the path to your ssh-askpass binary, as well.")
askPassPath = ""
return askPassPath