mirror of
https://github.com/boltgolt/howdy.git
synced 2024-09-19 09:51:19 +02:00
move config.ini and /models to /etc/howdy for better compatibility with immutable OSs
This commit is contained in:
parent
96767fe58e
commit
6151217466
19 changed files with 41 additions and 31 deletions
|
@ -17,7 +17,7 @@ def on_page_switch(self, notebook, page, page_num):
|
|||
|
||||
try:
|
||||
self.config = configparser.ConfigParser()
|
||||
self.config.read("/lib/security/howdy/config.ini")
|
||||
self.config.read("/etc/howdy/config.ini")
|
||||
except Exception:
|
||||
print(_("Can't open camera"))
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class MainWindow(gtk.Window):
|
|||
# Add the treeview
|
||||
self.modellistbox.add(self.treeview)
|
||||
|
||||
filelist = os.listdir("/lib/security/howdy/models")
|
||||
filelist = os.listdir("/etc/howdy/models")
|
||||
self.active_user = ""
|
||||
|
||||
self.userlist.items = 0
|
||||
|
@ -117,7 +117,7 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|||
elevate.elevate()
|
||||
|
||||
# If no models have been created yet or when it is forced, start the onboarding
|
||||
if "--force-onboarding" in sys.argv or not os.path.exists("/lib/security/howdy/models"):
|
||||
if "--force-onboarding" in sys.argv or not os.path.exists("/etc/howdy/models"):
|
||||
import onboarding
|
||||
onboarding.OnboardingWindow()
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ pkgbase = howdy
|
|||
depends = python3
|
||||
depends = python-dlib
|
||||
depends = python-numpy
|
||||
backup = usr/lib/security/howdy/config.ini
|
||||
backup = etc/howdy/config.ini
|
||||
source = howdy-2.6.1.tar.gz::https://github.com/boltgolt/howdy/archive/v2.6.1.tar.gz
|
||||
source = https://github.com/davisking/dlib-models/raw/master/dlib_face_recognition_resnet_model_v1.dat.bz2
|
||||
source = https://github.com/davisking/dlib-models/raw/master/mmod_human_face_detector.dat.bz2
|
||||
|
|
|
@ -22,7 +22,7 @@ makedepends=(
|
|||
'cmake'
|
||||
'pkgfile'
|
||||
)
|
||||
backup=('usr/lib/security/howdy/config.ini')
|
||||
backup=('etc/howdy/config.ini')
|
||||
source=(
|
||||
"$pkgname-$pkgver.tar.gz::https://github.com/boltgolt/howdy/archive/v${pkgver}.tar.gz"
|
||||
"https://github.com/davisking/dlib-models/raw/master/dlib_face_recognition_resnet_model_v1.dat.bz2"
|
||||
|
@ -39,7 +39,9 @@ package() {
|
|||
cd howdy-$pkgver
|
||||
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
mkdir -p "$pkgdir/usr/lib/security/howdy"
|
||||
mkdir -p "$pkgdir/etc/howdy"
|
||||
cp -r src/* "$pkgdir/usr/lib/security/howdy"
|
||||
cp -r src/config.ini "$pkgdir/etc/howdy"
|
||||
cp "${srcdir}/dlib_face_recognition_resnet_model_v1.dat" "$pkgdir/usr/lib/security/howdy/dlib-data/"
|
||||
cp "${srcdir}/mmod_human_face_detector.dat" "$pkgdir/usr/lib/security/howdy/dlib-data/"
|
||||
cp "${srcdir}/shape_predictor_5_face_landmarks.dat" "$pkgdir/usr/lib/security/howdy/dlib-data/"
|
||||
|
|
|
@ -52,7 +52,7 @@ if not os.path.exists("/tmp/howdy_picked_device"):
|
|||
oldConf = configparser.ConfigParser()
|
||||
oldConf.read("/tmp/howdy_config_backup_v" + sys.argv[2] + ".ini")
|
||||
newConf = configparser.ConfigParser()
|
||||
newConf.read("/lib/security/howdy/config.ini")
|
||||
newConf.read("/etc/howdy/config.ini")
|
||||
|
||||
# Go through every setting in the old config and apply it to the new file
|
||||
for section in oldConf.sections():
|
||||
|
@ -98,7 +98,7 @@ if not os.path.exists("/tmp/howdy_picked_device"):
|
|||
newConf.set(section, key, value)
|
||||
|
||||
# Write it all to file
|
||||
with open("/lib/security/howdy/config.ini", "w") as configfile:
|
||||
with open("/etc/howdy/config.ini", "w") as configfile:
|
||||
newConf.write(configfile)
|
||||
|
||||
# Install dlib data files if needed
|
||||
|
@ -200,7 +200,7 @@ handleStatus(subprocess.call(["pip3", "install", "--no-cache-dir", "opencv-pytho
|
|||
log("Configuring howdy")
|
||||
|
||||
# Manually change the camera id to the one picked
|
||||
for line in fileinput.input(["/lib/security/howdy/config.ini"], inplace=1):
|
||||
for line in fileinput.input(["/etc/howdy/config.ini"], inplace=1):
|
||||
line = line.replace("use_cnn = false", "use_cnn = " + str(cuda_used).lower())
|
||||
print(line, end="")
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@ if "upgrade" in sys.argv:
|
|||
try:
|
||||
subprocess.call(["cp /lib/security/howdy/config.ini /tmp/howdy_config_backup_v" + sys.argv[2] + ".ini"], shell=True)
|
||||
|
||||
# Let the user know so he knows where to look on a failed install
|
||||
print("Backup of Howdy config file created in /tmp/howdy_config_backup_v" + sys.argv[2] + ".ini")
|
||||
except subprocess.CalledProcessError:
|
||||
try:
|
||||
subprocess.call(["cp /etc/howdy/config.ini /tmp/howdy_config_backup_v" + sys.argv[2] + ".ini"], shell=True)
|
||||
|
||||
# Let the user know so he knows where to look on a failed install
|
||||
print("Backup of Howdy config file created in /tmp/howdy_config_backup_v" + sys.argv[2] + ".ini")
|
||||
except subprocess.CalledProcessError:
|
||||
|
|
|
@ -20,7 +20,7 @@ _howdy() {
|
|||
;;
|
||||
# For disable, grab the current "disabled" config option and give the reverse
|
||||
"disable")
|
||||
local status=$(cut -d'=' -f2 <<< $(cat /lib/security/howdy/config.ini | grep 'disabled =') | xargs echo -n)
|
||||
local status=$(cut -d'=' -f2 <<< $(cat /etc/howdy/config.ini | grep 'disabled =') | xargs echo -n)
|
||||
|
||||
[ "$status" == "false" ] && COMPREPLY="true" || COMPREPLY="false"
|
||||
return 0
|
||||
|
|
|
@ -28,6 +28,8 @@ import cv2
|
|||
|
||||
# Get the absolute path to the current directory
|
||||
path = os.path.abspath(__file__ + "/..")
|
||||
config_path = "/etc/howdy"
|
||||
models_path = "/etc/howdy/models"
|
||||
|
||||
# Test if at lest 1 of the data files is there and abort if it's not
|
||||
if not os.path.isfile(path + "/../dlib-data/shape_predictor_5_face_landmarks.dat"):
|
||||
|
@ -38,7 +40,7 @@ if not os.path.isfile(path + "/../dlib-data/shape_predictor_5_face_landmarks.dat
|
|||
|
||||
# Read config from disk
|
||||
config = configparser.ConfigParser()
|
||||
config.read(path + "/../config.ini")
|
||||
config.read(config_path + "/config.ini")
|
||||
|
||||
use_cnn = config.getboolean("core", "use_cnn", fallback=False)
|
||||
if use_cnn:
|
||||
|
@ -51,14 +53,14 @@ face_encoder = dlib.face_recognition_model_v1(path + "/../dlib-data/dlib_face_re
|
|||
|
||||
user = builtins.howdy_user
|
||||
# The permanent file to store the encoded model in
|
||||
enc_file = path + "/../models/" + user + ".dat"
|
||||
enc_file = models_path + "/" + user + ".dat"
|
||||
# Known encodings
|
||||
encodings = []
|
||||
|
||||
# Make the ./models folder if it doesn't already exist
|
||||
if not os.path.exists(path + "/../models"):
|
||||
if not os.path.exists(models_path):
|
||||
print(_("No face model folder found, creating one"))
|
||||
os.makedirs(path + "/../models")
|
||||
os.makedirs(models_path)
|
||||
|
||||
# To try read a premade encodings file if it exists
|
||||
try:
|
||||
|
|
|
@ -8,17 +8,17 @@ import builtins
|
|||
from i18n import _
|
||||
|
||||
# Get the full path to this file
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
path = "/etc/howdy/models"
|
||||
# Get the passed user
|
||||
user = builtins.howdy_user
|
||||
|
||||
# Check if the models folder is there
|
||||
if not os.path.exists(path + "/../models"):
|
||||
if not os.path.exists(path):
|
||||
print(_("No models created yet, can't clear them if they don't exist"))
|
||||
sys.exit(1)
|
||||
|
||||
# Check if the user has a models file to delete
|
||||
if not os.path.isfile(path + "/../models/" + user + ".dat"):
|
||||
if not os.path.isfile(path + "/" + user + ".dat"):
|
||||
print(_("{} has no models or they have been cleared already").format(user))
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -34,5 +34,5 @@ if not builtins.howdy_args.y:
|
|||
sys.exit(1)
|
||||
|
||||
# Delete otherwise
|
||||
os.remove(path + "/../models/" + user + ".dat")
|
||||
os.remove(path + "/" + user + ".dat")
|
||||
print(_("\nModels cleared"))
|
||||
|
|
|
@ -18,5 +18,6 @@ if "EDITOR" in os.environ:
|
|||
elif os.path.isfile("/etc/alternatives/editor"):
|
||||
editor = "/etc/alternatives/editor"
|
||||
|
||||
config_path = "/etc/howdy"
|
||||
# Open the editor as a subprocess and fork it
|
||||
subprocess.call([editor, os.path.dirname(os.path.realpath(__file__)) + "/../config.ini"])
|
||||
subprocess.call([editor, os.path.dirname(config_path) + "/config.ini"])
|
||||
|
|
|
@ -10,7 +10,7 @@ import configparser
|
|||
from i18n import _
|
||||
|
||||
# Get the absolute filepath
|
||||
config_path = os.path.dirname(os.path.abspath(__file__)) + "/../config.ini"
|
||||
config_path = os.path.dirname("/etc/howdy") + "/config.ini"
|
||||
|
||||
# Read config from disk
|
||||
config = configparser.ConfigParser()
|
||||
|
|
|
@ -10,7 +10,7 @@ import builtins
|
|||
from i18n import _
|
||||
|
||||
# Get the absolute path and the username
|
||||
path = os.path.dirname(os.path.realpath(__file__)) + "/.."
|
||||
path = "/etc/howdy"
|
||||
user = builtins.howdy_user
|
||||
|
||||
# Check if the models file has been created yet
|
||||
|
|
|
@ -9,7 +9,7 @@ import builtins
|
|||
from i18n import _
|
||||
|
||||
# Get the absolute path and the username
|
||||
path = os.path.dirname(os.path.realpath(__file__)) + "/.."
|
||||
path = "/etc/howdy"
|
||||
user = builtins.howdy_user
|
||||
|
||||
# Check if enough arguments have been passed
|
||||
|
|
|
@ -9,7 +9,7 @@ import fileinput
|
|||
from i18n import _
|
||||
|
||||
# Get the absolute filepath
|
||||
config_path = os.path.dirname(os.path.abspath(__file__)) + "/../config.ini"
|
||||
config_path = os.path.dirname("/etc/howdy") + "/config.ini"
|
||||
|
||||
# Check if enough arguments have been passed
|
||||
if len(builtins.howdy_args.arguments) < 2:
|
||||
|
|
|
@ -9,12 +9,11 @@ from recorders.video_capture import VideoCapture
|
|||
|
||||
from i18n import _
|
||||
|
||||
# Get the absolute path to the current directory
|
||||
path = os.path.abspath(__file__ + "/..")
|
||||
path = "/etc/howdy"
|
||||
|
||||
# Read the config
|
||||
config = configparser.ConfigParser()
|
||||
config.read(path + "/../config.ini")
|
||||
config.read(path + "/config.ini")
|
||||
|
||||
# Start video capture
|
||||
video_capture = VideoCapture(config)
|
||||
|
|
|
@ -16,7 +16,7 @@ path = os.path.dirname(os.path.abspath(__file__))
|
|||
|
||||
# Read config from disk
|
||||
config = configparser.ConfigParser()
|
||||
config.read(path + "/../config.ini")
|
||||
config.read("/etc/howdy/config.ini")
|
||||
|
||||
if config.get("video", "recording_plugin") != "opencv":
|
||||
print(_("Howdy has been configured to use a recorder which doesn't support the test command yet, aborting"))
|
||||
|
|
|
@ -126,7 +126,7 @@ face_encoder = None
|
|||
|
||||
# Try to load the face model from the models folder
|
||||
try:
|
||||
models = json.load(open(PATH + "/models/" + user + ".dat"))
|
||||
models = json.load(open("/etc/howdy/models/" + user + ".dat"))
|
||||
|
||||
for model in models:
|
||||
encodings += model["data"]
|
||||
|
@ -139,7 +139,7 @@ if len(models) < 1:
|
|||
|
||||
# Read config from disk
|
||||
config = configparser.ConfigParser()
|
||||
config.read(PATH + "/config.ini")
|
||||
config.read("/etc/howdy/config.ini")
|
||||
|
||||
# Get all config values needed
|
||||
use_cnn = config.getboolean("core", "use_cnn", fallback=False)
|
||||
|
|
|
@ -11,7 +11,7 @@ import ConfigParser
|
|||
|
||||
# Read config from disk
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(os.path.dirname(os.path.abspath(__file__)) + "/config.ini")
|
||||
config.read(os.path.dirname("/etc/howdy") + "/config.ini")
|
||||
|
||||
|
||||
def doAuth(pamh):
|
||||
|
|
|
@ -126,7 +126,7 @@ int send_message(function<int(int, const struct pam_message **,
|
|||
*/
|
||||
int identify(pam_handle_t *pamh, int flags, int argc, const char **argv,
|
||||
bool auth_tok) {
|
||||
INIReader reader("/lib/security/howdy/config.ini");
|
||||
INIReader reader("/etc/howdy/config.ini");
|
||||
// Open the system log so we can write to it
|
||||
openlog("pam_howdy", 0, LOG_AUTHPRIV);
|
||||
|
||||
|
|
Loading…
Reference in a new issue