optimized config
This commit is contained in:
+3
-7
@@ -1,8 +1,4 @@
|
|||||||
{
|
{
|
||||||
"usage": {
|
"usage": {},
|
||||||
"testuser1": {
|
|
||||||
"2026-09-17": 636
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"temporary_grants": []
|
"temporary_grants": []
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-28
@@ -1,28 +1 @@
|
|||||||
users:
|
users: []
|
||||||
- id: 1
|
|
||||||
username: testuser1
|
|
||||||
enabled: true
|
|
||||||
daily_allowance:
|
|
||||||
sunday: 0
|
|
||||||
monday: 0
|
|
||||||
tuesday: 0
|
|
||||||
wednesday: 0
|
|
||||||
thursday: 900
|
|
||||||
friday: 0
|
|
||||||
saturday: 0
|
|
||||||
access_windows:
|
|
||||||
thursday:
|
|
||||||
- start: '16:00'
|
|
||||||
end: '21:00'
|
|
||||||
- id: 2
|
|
||||||
username: testuser2
|
|
||||||
enabled: false
|
|
||||||
daily_allowance:
|
|
||||||
sunday: 0
|
|
||||||
monday: 0
|
|
||||||
tuesday: 0
|
|
||||||
wednesday: 0
|
|
||||||
thursday: 0
|
|
||||||
friday: 0
|
|
||||||
saturday: 0
|
|
||||||
access_windows: {}
|
|
||||||
|
|||||||
+188
-161
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -euo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Linux Parental Control Installer
|
# Linux Parental Control Installer
|
||||||
@@ -23,6 +23,10 @@ POLKIT_DEST="/etc/polkit-1/actions/$POLKIT_ACTION.policy"
|
|||||||
|
|
||||||
SOCKET_PATH="/run/parental-control.sock"
|
SOCKET_PATH="/run/parental-control.sock"
|
||||||
|
|
||||||
|
INSTALL_USER=""
|
||||||
|
INSTALL_GROUP=""
|
||||||
|
PACKAGE_MANAGER=""
|
||||||
|
POLKIT_AGENT=""
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Output helpers
|
# Output helpers
|
||||||
@@ -48,29 +52,32 @@ error() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Error handling
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
on_error() {
|
||||||
|
echo
|
||||||
|
echo "Installation failed."
|
||||||
|
echo "Line: $1"
|
||||||
|
echo "Command: $2"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
trap 'on_error "$LINENO" "$BASH_COMMAND"' ERR
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Root check
|
# Root check
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
if [ "$EUID" -ne 0 ]; then
|
if [ "$EUID" -ne 0 ]; then
|
||||||
echo
|
error "Run this installer with sudo:
|
||||||
echo "This installer requires administrator privileges."
|
|
||||||
echo
|
|
||||||
echo "Run:"
|
|
||||||
echo
|
|
||||||
echo " sudo ./install.sh"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
sudo ./install.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Find original user
|
# Find original user
|
||||||
#
|
|
||||||
# When running through sudo, SUDO_USER is the person who
|
|
||||||
# launched the installer. We use this to keep the source tree
|
|
||||||
# owned by that user rather than root.
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then
|
if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then
|
||||||
@@ -85,6 +92,11 @@ fi
|
|||||||
|
|
||||||
INSTALL_GROUP="$(id -gn "$INSTALL_USER")"
|
INSTALL_GROUP="$(id -gn "$INSTALL_USER")"
|
||||||
|
|
||||||
|
INSTALL_USER_HOME="$(getent passwd "$INSTALL_USER" | cut -d: -f6)"
|
||||||
|
|
||||||
|
if [ -z "$INSTALL_USER_HOME" ] || [ ! -d "$INSTALL_USER_HOME" ]; then
|
||||||
|
error "Could not determine the home directory of $INSTALL_USER."
|
||||||
|
fi
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Header
|
# Header
|
||||||
@@ -107,7 +119,6 @@ echo "Installation user:"
|
|||||||
echo " $INSTALL_USER"
|
echo " $INSTALL_USER"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Check project files
|
# Check project files
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -143,9 +154,8 @@ done
|
|||||||
|
|
||||||
success "All required project files found."
|
success "All required project files found."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Check Linux
|
# Detect operating system
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
info "Detecting operating system"
|
info "Detecting operating system"
|
||||||
@@ -164,7 +174,6 @@ OS_VERSION="${VERSION_ID:-unknown}"
|
|||||||
echo " Distribution: $OS_NAME"
|
echo " Distribution: $OS_NAME"
|
||||||
echo " Version: $OS_VERSION"
|
echo " Version: $OS_VERSION"
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Check systemd
|
# Check systemd
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -172,15 +181,22 @@ echo " Version: $OS_VERSION"
|
|||||||
info "Checking systemd"
|
info "Checking systemd"
|
||||||
|
|
||||||
if ! command -v systemctl >/dev/null 2>&1; then
|
if ! command -v systemctl >/dev/null 2>&1; then
|
||||||
error "systemd is required, but systemctl was not found."
|
error "systemd is required for this version of the application.
|
||||||
|
|
||||||
|
This installer does not support non-systemd distributions."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /run/systemd/system ]; then
|
if [ ! -d /run/systemd/system ]; then
|
||||||
error "systemd is installed but does not appear to be running."
|
error "systemd is installed but is not currently running."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "systemd detected."
|
if ! command -v loginctl >/dev/null 2>&1; then
|
||||||
|
error "loginctl was not found.
|
||||||
|
|
||||||
|
The application requires systemd-logind."
|
||||||
|
fi
|
||||||
|
|
||||||
|
success "systemd and loginctl detected."
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Detect package manager
|
# Detect package manager
|
||||||
@@ -188,8 +204,6 @@ success "systemd detected."
|
|||||||
|
|
||||||
info "Detecting package manager"
|
info "Detecting package manager"
|
||||||
|
|
||||||
PACKAGE_MANAGER=""
|
|
||||||
|
|
||||||
if command -v pacman >/dev/null 2>&1; then
|
if command -v pacman >/dev/null 2>&1; then
|
||||||
PACKAGE_MANAGER="pacman"
|
PACKAGE_MANAGER="pacman"
|
||||||
|
|
||||||
@@ -202,12 +216,6 @@ elif command -v dnf >/dev/null 2>&1; then
|
|||||||
elif command -v zypper >/dev/null 2>&1; then
|
elif command -v zypper >/dev/null 2>&1; then
|
||||||
PACKAGE_MANAGER="zypper"
|
PACKAGE_MANAGER="zypper"
|
||||||
|
|
||||||
elif command -v apk >/dev/null 2>&1; then
|
|
||||||
PACKAGE_MANAGER="apk"
|
|
||||||
|
|
||||||
elif command -v xbps-install >/dev/null 2>&1; then
|
|
||||||
PACKAGE_MANAGER="xbps"
|
|
||||||
|
|
||||||
else
|
else
|
||||||
error "No supported package manager was detected.
|
error "No supported package manager was detected.
|
||||||
|
|
||||||
@@ -216,15 +224,15 @@ Supported package managers:
|
|||||||
apt
|
apt
|
||||||
dnf
|
dnf
|
||||||
zypper
|
zypper
|
||||||
apk
|
|
||||||
xbps-install"
|
You can install the required dependencies manually,
|
||||||
|
then run the installer again."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "Package manager: $PACKAGE_MANAGER"
|
success "Package manager: $PACKAGE_MANAGER"
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Install system packages
|
# Install system dependencies
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
info "Installing system dependencies"
|
info "Installing system dependencies"
|
||||||
@@ -236,7 +244,9 @@ case "$PACKAGE_MANAGER" in
|
|||||||
python \
|
python \
|
||||||
python-pip \
|
python-pip \
|
||||||
polkit \
|
polkit \
|
||||||
desktop-file-utils
|
polkit-gnome \
|
||||||
|
desktop-file-utils \
|
||||||
|
systemd
|
||||||
;;
|
;;
|
||||||
|
|
||||||
apt)
|
apt)
|
||||||
@@ -250,47 +260,37 @@ case "$PACKAGE_MANAGER" in
|
|||||||
python3-venv \
|
python3-venv \
|
||||||
polkitd \
|
polkitd \
|
||||||
policykit-1 \
|
policykit-1 \
|
||||||
desktop-file-utils
|
policykit-1-gnome \
|
||||||
|
desktop-file-utils \
|
||||||
|
systemd
|
||||||
;;
|
;;
|
||||||
|
|
||||||
dnf)
|
dnf)
|
||||||
dnf install -y \
|
dnf install -y \
|
||||||
python3 \
|
python3 \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
|
python3-virtualenv \
|
||||||
polkit \
|
polkit \
|
||||||
desktop-file-utils
|
polkit-gnome \
|
||||||
|
desktop-file-utils \
|
||||||
|
systemd
|
||||||
;;
|
;;
|
||||||
|
|
||||||
zypper)
|
zypper)
|
||||||
zypper --non-interactive install \
|
zypper --non-interactive install \
|
||||||
python3 \
|
python3 \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
|
python3-virtualenv \
|
||||||
polkit \
|
polkit \
|
||||||
desktop-file-utils
|
polkit-gnome \
|
||||||
;;
|
desktop-file-utils \
|
||||||
|
systemd
|
||||||
apk)
|
|
||||||
apk add \
|
|
||||||
python3 \
|
|
||||||
py3-pip \
|
|
||||||
py3-virtualenv \
|
|
||||||
polkit \
|
|
||||||
desktop-file-utils
|
|
||||||
;;
|
|
||||||
|
|
||||||
xbps)
|
|
||||||
xbps-install -Sy \
|
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
polkit \
|
|
||||||
desktop-file-utils
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
success "System dependencies installed."
|
success "System dependencies installed."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Find Python
|
# Find Python
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -311,11 +311,13 @@ if [ -z "$SYSTEM_PYTHON" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PYTHON_MAJOR="$(
|
PYTHON_MAJOR="$(
|
||||||
"$SYSTEM_PYTHON" -c 'import sys; print(sys.version_info.major)'
|
"$SYSTEM_PYTHON" -c \
|
||||||
|
'import sys; print(sys.version_info.major)'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
PYTHON_MINOR="$(
|
PYTHON_MINOR="$(
|
||||||
"$SYSTEM_PYTHON" -c 'import sys; print(sys.version_info.minor)'
|
"$SYSTEM_PYTHON" -c \
|
||||||
|
'import sys; print(sys.version_info.minor)'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
PYTHON_VERSION="$(
|
PYTHON_VERSION="$(
|
||||||
@@ -324,39 +326,35 @@ PYTHON_VERSION="$(
|
|||||||
)"
|
)"
|
||||||
|
|
||||||
if [ "$PYTHON_MAJOR" -ne 3 ]; then
|
if [ "$PYTHON_MAJOR" -ne 3 ]; then
|
||||||
error "Python 3 is required. Found Python $PYTHON_VERSION."
|
error "Python 3 is required.
|
||||||
|
|
||||||
|
Found Python $PYTHON_VERSION."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PYTHON_MINOR" -lt 9 ]; then
|
||||||
|
error "Python $PYTHON_VERSION is too old.
|
||||||
|
|
||||||
|
Python 3.9 or newer is required."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " Python: $SYSTEM_PYTHON"
|
echo " Python: $SYSTEM_PYTHON"
|
||||||
echo " Version: $PYTHON_VERSION"
|
echo " Version: $PYTHON_VERSION"
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# Check Python version for PySide6
|
|
||||||
# ============================================================
|
|
||||||
|
|
||||||
if [ "$PYTHON_MINOR" -lt 9 ]; then
|
|
||||||
error "Python $PYTHON_VERSION is too old for this application.
|
|
||||||
|
|
||||||
Python 3.9 or newer is required."
|
|
||||||
fi
|
|
||||||
|
|
||||||
success "Python version is supported."
|
success "Python version is supported."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Create/recreate virtual environment
|
# Create virtual environment
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
info "Preparing Python virtual environment"
|
info "Preparing Python virtual environment"
|
||||||
|
|
||||||
if [ -x "$PYTHON" ]; then
|
if [ -x "$PYTHON" ]; then
|
||||||
success "Existing virtual environment is valid."
|
success "Existing virtual environment found."
|
||||||
|
|
||||||
else
|
else
|
||||||
if [ -d "$VENV_DIR" ]; then
|
if [ -d "$VENV_DIR" ]; then
|
||||||
echo " Existing virtual environment is broken."
|
warning "Existing virtual environment is incomplete."
|
||||||
echo " Removing it..."
|
warning "Removing it."
|
||||||
|
|
||||||
rm -rf "$VENV_DIR"
|
rm -rf "$VENV_DIR"
|
||||||
fi
|
fi
|
||||||
@@ -366,13 +364,12 @@ else
|
|||||||
if ! "$SYSTEM_PYTHON" -m venv "$VENV_DIR"; then
|
if ! "$SYSTEM_PYTHON" -m venv "$VENV_DIR"; then
|
||||||
error "Could not create the Python virtual environment.
|
error "Could not create the Python virtual environment.
|
||||||
|
|
||||||
Your distribution may require an additional Python venv package."
|
Install your distribution's Python venv package."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "Virtual environment created."
|
success "Virtual environment created."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Install Python dependencies
|
# Install Python dependencies
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -389,9 +386,8 @@ info "Installing Python dependencies"
|
|||||||
|
|
||||||
success "Python dependencies installed."
|
success "Python dependencies installed."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Validate Python application
|
# Validate Python source
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
info "Checking Python source files"
|
info "Checking Python source files"
|
||||||
@@ -403,35 +399,8 @@ info "Checking Python source files"
|
|||||||
|
|
||||||
success "Python source validation passed."
|
success "Python source validation passed."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Remove Python cache files created by installer
|
# Validate configuration
|
||||||
# ============================================================
|
|
||||||
|
|
||||||
find "$INSTALL_DIR/app" \
|
|
||||||
"$INSTALL_DIR/desktop" \
|
|
||||||
-type d \
|
|
||||||
-name "__pycache__" \
|
|
||||||
-prune \
|
|
||||||
-exec rm -rf {} + \
|
|
||||||
2>/dev/null || true
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# Restore source ownership
|
|
||||||
# ============================================================
|
|
||||||
|
|
||||||
info "Fixing source ownership"
|
|
||||||
|
|
||||||
chown -R \
|
|
||||||
"$INSTALL_USER:$INSTALL_GROUP" \
|
|
||||||
"$INSTALL_DIR"
|
|
||||||
|
|
||||||
success "Source tree owned by $INSTALL_USER."
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# Verify configuration
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
info "Checking application configuration"
|
info "Checking application configuration"
|
||||||
@@ -444,8 +413,7 @@ if [ ! -f "$INSTALL_DIR/config/state.json" ]; then
|
|||||||
error "state.json was not found."
|
error "state.json was not found."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "YAML/JSON configuration files found."
|
success "Configuration files found."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Install systemd service
|
# Install systemd service
|
||||||
@@ -460,9 +428,6 @@ sed \
|
|||||||
"$INSTALL_DIR/parental-control.service" \
|
"$INSTALL_DIR/parental-control.service" \
|
||||||
> "$SERVICE_TEMP"
|
> "$SERVICE_TEMP"
|
||||||
|
|
||||||
# Ensure the service does not write Python bytecode into the
|
|
||||||
# Git repository.
|
|
||||||
|
|
||||||
if ! grep -q '^Environment=PYTHONDONTWRITEBYTECODE=' "$SERVICE_TEMP"; then
|
if ! grep -q '^Environment=PYTHONDONTWRITEBYTECODE=' "$SERVICE_TEMP"; then
|
||||||
sed -i \
|
sed -i \
|
||||||
'/^\[Service\]/a Environment=PYTHONDONTWRITEBYTECODE=1' \
|
'/^\[Service\]/a Environment=PYTHONDONTWRITEBYTECODE=1' \
|
||||||
@@ -480,34 +445,102 @@ rm -f "$SERVICE_TEMP"
|
|||||||
|
|
||||||
success "Systemd service installed."
|
success "Systemd service installed."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Install polkit policy
|
# Install polkit policy
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
info "Checking polkit policy"
|
info "Installing polkit policy"
|
||||||
|
|
||||||
if [ -f "$POLKIT_SOURCE" ]; then
|
if [ ! -f "$POLKIT_SOURCE" ]; then
|
||||||
|
error "Polkit policy file was not found:
|
||||||
mkdir -p /etc/polkit-1/actions
|
|
||||||
|
|
||||||
install \
|
|
||||||
-o root \
|
|
||||||
-g root \
|
|
||||||
-m 644 \
|
|
||||||
"$POLKIT_SOURCE" \
|
|
||||||
"$POLKIT_DEST"
|
|
||||||
|
|
||||||
success "Polkit policy installed."
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
warning "Polkit policy file is not present."
|
|
||||||
warning "Expected: $POLKIT_SOURCE"
|
|
||||||
warning "Skipping polkit policy installation."
|
|
||||||
|
|
||||||
|
$POLKIT_SOURCE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mkdir -p /etc/polkit-1/actions
|
||||||
|
|
||||||
|
install \
|
||||||
|
-o root \
|
||||||
|
-g root \
|
||||||
|
-m 644 \
|
||||||
|
"$POLKIT_SOURCE" \
|
||||||
|
"$POLKIT_DEST"
|
||||||
|
|
||||||
|
success "Polkit policy installed."
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Detect polkit authentication agent
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
info "Detecting polkit authentication agent"
|
||||||
|
|
||||||
|
POLKIT_AGENT=""
|
||||||
|
|
||||||
|
POLKIT_AGENT_CANDIDATES=(
|
||||||
|
"/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1"
|
||||||
|
"/usr/libexec/polkit-gnome-authentication-agent-1"
|
||||||
|
"/usr/lib/polkit-1-gnome/polkit-gnome-authentication-agent-1"
|
||||||
|
)
|
||||||
|
|
||||||
|
for candidate in "${POLKIT_AGENT_CANDIDATES[@]}"; do
|
||||||
|
if [ -x "$candidate" ]; then
|
||||||
|
POLKIT_AGENT="$candidate"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$POLKIT_AGENT" ]; then
|
||||||
|
success "Authentication agent found:"
|
||||||
|
success "$POLKIT_AGENT"
|
||||||
|
else
|
||||||
|
warning "A polkit authentication agent was not found."
|
||||||
|
warning "GUI administrative actions may require manual configuration."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Configure Sway polkit authentication agent
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
configure_sway_polkit() {
|
||||||
|
local user_home="$1"
|
||||||
|
local sway_config="$user_home/.config/sway/config"
|
||||||
|
local marker="parental-control-polkit-agent"
|
||||||
|
|
||||||
|
if [ -z "$POLKIT_AGENT" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$sway_config" ]; then
|
||||||
|
warning "Sway configuration not found:"
|
||||||
|
warning "$sway_config"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -Fq "$marker" "$sway_config"; then
|
||||||
|
success "Sway polkit authentication agent is already configured."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -a \
|
||||||
|
"$sway_config" \
|
||||||
|
"$sway_config.parental-control-backup"
|
||||||
|
|
||||||
|
cat >> "$sway_config" <<EOF
|
||||||
|
|
||||||
|
# $marker
|
||||||
|
exec_always --no-startup-id $POLKIT_AGENT
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chown \
|
||||||
|
"$INSTALL_USER:$INSTALL_GROUP" \
|
||||||
|
"$sway_config"
|
||||||
|
|
||||||
|
success "Sway polkit authentication agent configured."
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -n "$POLKIT_AGENT" ]; then
|
||||||
|
configure_sway_polkit "$INSTALL_USER_HOME"
|
||||||
|
fi
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Install desktop launcher
|
# Install desktop launcher
|
||||||
@@ -532,7 +565,6 @@ chmod 644 "$DESKTOP_FILE"
|
|||||||
|
|
||||||
success "Desktop launcher installed."
|
success "Desktop launcher installed."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Validate desktop launcher
|
# Validate desktop launcher
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -551,19 +583,27 @@ else
|
|||||||
warning "desktop-file-validate is not available."
|
warning "desktop-file-validate is not available."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Update desktop database
|
# Update desktop database
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
if command -v update-desktop-database >/dev/null 2>&1; then
|
if command -v update-desktop-database >/dev/null 2>&1; then
|
||||||
|
|
||||||
update-desktop-database \
|
update-desktop-database \
|
||||||
/usr/share/applications \
|
/usr/share/applications \
|
||||||
>/dev/null 2>&1 || true
|
>/dev/null 2>&1 || true
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Restore source ownership
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
info "Fixing source ownership"
|
||||||
|
|
||||||
|
chown -R \
|
||||||
|
"$INSTALL_USER:$INSTALL_GROUP" \
|
||||||
|
"$INSTALL_DIR"
|
||||||
|
|
||||||
|
success "Source tree owned by $INSTALL_USER."
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Reload systemd
|
# Reload systemd
|
||||||
@@ -573,8 +613,7 @@ info "Reloading systemd"
|
|||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
success "systemd reloaded."
|
success "Systemd reloaded."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Remove stale IPC socket
|
# Remove stale IPC socket
|
||||||
@@ -594,7 +633,6 @@ if [ -e "$SOCKET_PATH" ]; then
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Enable service
|
# Enable service
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -605,7 +643,6 @@ systemctl enable "$SERVICE_NAME"
|
|||||||
|
|
||||||
success "Service enabled."
|
success "Service enabled."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Restart service
|
# Restart service
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -614,11 +651,12 @@ info "Starting parental control service"
|
|||||||
|
|
||||||
systemctl restart "$SERVICE_NAME"
|
systemctl restart "$SERVICE_NAME"
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Wait for service
|
# Wait for service
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
|
info "Waiting for service startup"
|
||||||
|
|
||||||
SERVICE_READY=0
|
SERVICE_READY=0
|
||||||
|
|
||||||
for _ in $(seq 1 15); do
|
for _ in $(seq 1 15); do
|
||||||
@@ -632,7 +670,6 @@ for _ in $(seq 1 15); do
|
|||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
if [ "$SERVICE_READY" -ne 1 ]; then
|
if [ "$SERVICE_READY" -ne 1 ]; then
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@@ -659,7 +696,6 @@ fi
|
|||||||
|
|
||||||
success "Service is running."
|
success "Service is running."
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Verify IPC socket
|
# Verify IPC socket
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -667,17 +703,12 @@ success "Service is running."
|
|||||||
info "Checking IPC socket"
|
info "Checking IPC socket"
|
||||||
|
|
||||||
if [ ! -S "$SOCKET_PATH" ]; then
|
if [ ! -S "$SOCKET_PATH" ]; then
|
||||||
|
|
||||||
warning "IPC socket was not created:"
|
warning "IPC socket was not created:"
|
||||||
warning "$SOCKET_PATH"
|
warning "$SOCKET_PATH"
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
success "IPC socket is active."
|
success "IPC socket is active."
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Final verification
|
# Final verification
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -686,7 +717,6 @@ info "Running final checks"
|
|||||||
|
|
||||||
CHECK_FAILED=0
|
CHECK_FAILED=0
|
||||||
|
|
||||||
|
|
||||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||||
echo " Service: OK"
|
echo " Service: OK"
|
||||||
else
|
else
|
||||||
@@ -694,7 +724,6 @@ else
|
|||||||
CHECK_FAILED=1
|
CHECK_FAILED=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -x "$PYTHON" ]; then
|
if [ -x "$PYTHON" ]; then
|
||||||
echo " Python: OK"
|
echo " Python: OK"
|
||||||
else
|
else
|
||||||
@@ -702,7 +731,6 @@ else
|
|||||||
CHECK_FAILED=1
|
CHECK_FAILED=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$DESKTOP_FILE" ]; then
|
if [ -f "$DESKTOP_FILE" ]; then
|
||||||
echo " Desktop: OK"
|
echo " Desktop: OK"
|
||||||
else
|
else
|
||||||
@@ -710,21 +738,19 @@ else
|
|||||||
CHECK_FAILED=1
|
CHECK_FAILED=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -S "$SOCKET_PATH" ]; then
|
if [ -S "$SOCKET_PATH" ]; then
|
||||||
echo " IPC: OK"
|
echo " IPC: OK"
|
||||||
else
|
else
|
||||||
echo " IPC: WARNING"
|
echo " IPC: WARNING"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$POLKIT_DEST" ]; then
|
if [ -f "$POLKIT_DEST" ]; then
|
||||||
echo " Polkit: OK"
|
echo " Polkit: OK"
|
||||||
else
|
else
|
||||||
echo " Polkit: NOT INSTALLED"
|
echo " Polkit: FAILED"
|
||||||
|
CHECK_FAILED=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$INSTALL_DIR/config/users.yaml" ]; then
|
if [ -f "$INSTALL_DIR/config/users.yaml" ]; then
|
||||||
echo " Users: OK"
|
echo " Users: OK"
|
||||||
else
|
else
|
||||||
@@ -732,7 +758,6 @@ else
|
|||||||
CHECK_FAILED=1
|
CHECK_FAILED=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$INSTALL_DIR/config/state.json" ]; then
|
if [ -f "$INSTALL_DIR/config/state.json" ]; then
|
||||||
echo " State: OK"
|
echo " State: OK"
|
||||||
else
|
else
|
||||||
@@ -740,12 +765,10 @@ else
|
|||||||
CHECK_FAILED=1
|
CHECK_FAILED=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$CHECK_FAILED" -ne 0 ]; then
|
if [ "$CHECK_FAILED" -ne 0 ]; then
|
||||||
error "One or more required installation checks failed."
|
error "One or more required installation checks failed."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Finished
|
# Finished
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -762,9 +785,6 @@ echo "Launch:"
|
|||||||
echo " Application menu"
|
echo " Application menu"
|
||||||
echo " Rofi"
|
echo " Rofi"
|
||||||
echo
|
echo
|
||||||
echo "Rofi:"
|
|
||||||
echo " Super + D"
|
|
||||||
echo
|
|
||||||
echo "Service:"
|
echo "Service:"
|
||||||
echo " systemctl status $SERVICE_NAME"
|
echo " systemctl status $SERVICE_NAME"
|
||||||
echo
|
echo
|
||||||
@@ -781,5 +801,12 @@ echo
|
|||||||
echo "Installation:"
|
echo "Installation:"
|
||||||
echo " $INSTALL_DIR"
|
echo " $INSTALL_DIR"
|
||||||
echo
|
echo
|
||||||
|
echo "Polkit agent:"
|
||||||
|
if [ -n "$POLKIT_AGENT" ]; then
|
||||||
|
echo " $POLKIT_AGENT"
|
||||||
|
else
|
||||||
|
echo " Not detected"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in New Issue
Block a user