Initial commit

This commit is contained in:
2026-01-10 22:22:36 +00:00
commit 89d049ba7a
16 changed files with 318 additions and 0 deletions

38
build/build-deb.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
set -e
mkdir -p debian
BUILD_DIR="$(dirname "$0")"
DEBIAN_DIR="$BUILD_DIR/../debian"
DIST_DIR="$BUILD_DIR/../dist"
UNINSTALL="$BUILD_DIR/uninstall.sh"
POST_INSTALL="$BUILD_DIR/post_install.sh"
echo "$(cat "$UNINSTALL")" > "$DEBIAN_DIR/prerm"
echo "#DEBHELPER#" >> "$DEBIAN_DIR/prerm"
echo "$(cat "$POST_INSTALL")" > "$DEBIAN_DIR/postinst"
echo "#DEBHELPER#" >> "$DEBIAN_DIR/postinst"
if [ ! -f "$DEBIAN_DIR/control" ]; then
echo "Error: $DEBIAN_DIR/control not found."
exit 1
fi
if ! command -v docker >/dev/null 2>&1; then
echo "Error: Docker not found. Please install Docker."
exit 1
fi
if ! docker info >/dev/null 2>&1; then
echo "Starting Docker daemon..."
if command -v systemctl >/dev/null 2>&1; then
sudo systemctl start docker
elif command -v rc-service >/dev/null 2>&1; then
sudo rc-service docker start
else
echo "Error: Unable to determine init system. Please start Docker manually."
exit 1
fi
sleep 2
fi
docker run --rm -v "$(pwd)":/src -v "$DIST_DIR":/dist -w /src debian:latest bash -c "
apt update && apt install -y debhelper devscripts &&
dpkg-buildpackage -us -uc &&
mv /*.deb /dist/
"
echo "Package built: $(ls "$DIST_DIR"/sudo-nopasswd_*.deb | head -n 1)"

26
build/build-gentoo.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
# Script to build and install the sudo-nopasswd package on Gentoo
set -e
# Check if we're in the project directory
if [ ! -f "gentoo/app-admin/sudo-nopasswd/sudo-nopasswd-1.0.ebuild" ]; then
echo "Error: ebuild not found. Run this script from the project root."
exit 1
fi
# Check for emerge command
if ! command -v emerge >/dev/null 2>&1; then
echo "Error: emerge command not found. Ensure portage is installed."
exit 1
fi
# Set up local repository
echo "Setting up local repository..."
sudo mkdir -p /etc/portage/repos.conf
sudo tee /etc/portage/repos.conf/local.conf > /dev/null <<EOF
[local]
location = /home/sean/sudo-nopasswd/gentoo
masters = gentoo
EOF
# Regenerate cache
sudo emerge --regen
echo "Building and installing package..."
sudo emerge =app-admin/sudo-nopasswd-1.0
echo "Package installed successfully."

19
build/install.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
set -e
[ "$EUID" -eq 0 ] || { sudo "$0" "$@"; exit $?; }
CONSTANTS="sudo_no_passwd_constants.sh"
SRC="$(dirname "$0")/../src"
source "$SRC/$CONSTANTS"
mkdir -p "$SHARE_DIR"
cp "$SRC/$CONSTANTS" "$SHARE_DIR/"
cp "$SRC/$UPDATE_COMMAND" "$BIN_DIR/"
cp "$SRC/$WATCH_COMMAND" "$BIN_DIR/"
chmod +x "$BIN_DIR/$UPDATE_COMMAND" "$BIN_DIR/$WATCH_COMMAND"
if command -v systemctl >/dev/null 2>&1; then
cp "$SRC/$SERVICE_FILE" "$SYSTEMD_DIR/"
elif command -v rc-update >/dev/null 2>&1; then
cp "$SRC/$INIT_FILE" "$INITD_DIR/"
else
echo "Unsupported init system."
fi
"$(dirname "$0")/post_install.sh"

20
build/post_install.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
set -e
[ "$EUID" -eq 0 ] || { echo "Please run as root"; exit 1; }
SHARE_DIR="/usr/share/sudo-nopasswd"
CONSTANTS="sudo_no_passwd_constants.sh"
source "$SHARE_DIR/$CONSTANTS"
[ -f "$ETC_FILE" ] || touch "$ETC_FILE"
if command -v systemctl >/dev/null 2>&1; then
systemctl enable "$SERVICE_FILE"
if [ -d /run/systemd/system ]; then
systemctl daemon-reload
systemctl start "$SERVICE_FILE"
fi
elif command -v rc-update >/dev/null 2>&1; then
chmod +x "$INITD_DIR/$INIT_FILE"
rc-update add "$INIT_FILE" default
rc-service "$INIT_FILE" start
else
echo "Unsupported init system."
fi

33
build/test-deb.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
set -e
if ! command -v docker >/dev/null 2>&1; then
echo "Error: Docker not found."
exit 1
fi
if ! docker info >/dev/null 2>&1; then
echo "Starting Docker..."
if command -v systemctl >/dev/null 2>&1; then
sudo systemctl start docker
elif command -v rc-service >/dev/null 2>&1; then
sudo rc-service docker start
else
echo "Error: Unable to start Docker."
exit 1
fi
sleep 2
fi
DEB_FILE=$(ls ./*.deb 2>/dev/null | head -1)
if [ -z "$DEB_FILE" ]; then
echo "Error: No .deb file found in current directory. Run build-deb.sh first."
exit 1
fi
echo "Found .deb file: $DEB_FILE"
CONTAINER_NAME="test-debian-sudo"
echo "Starting detached Debian container..."
CONTAINER_ID=$(docker run -d --name "$CONTAINER_NAME" debian:latest tail -f /dev/null)
echo "Container started with ID: $CONTAINER_ID"
echo "Copying .deb file into container..."
docker cp "$DEB_FILE" "$CONTAINER_NAME:/root/"
echo "Setup complete."
echo "To enter the container: docker exec -it $CONTAINER_NAME /bin/bash"
echo "To stop the container: docker stop $CONTAINER_NAME && docker rm $CONTAINER_NAME"

25
build/uninstall.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
set -e
SHARE_DIR="/usr/share/sudo-nopasswd"
[ -e "$SHARE_DIR" ] || { echo "sudo-nopasswd is not installed."; exit 1; }
source "$SHARE_DIR/sudo_no_passwd_constants.sh"
[ "$EUID" -eq 0 ] || { sudo "$0" "$@"; exit $?; }
if command -v systemctl >/dev/null 2>&1; then
systemctl stop "$SERVICE_FILE" 2>/dev/null || true
systemctl disable "$SERVICE_FILE" 2>/dev/null || true
rm -f "$SYSTEMD_DIR/$SERVICE_FILE"
systemctl daemon-reload
elif command -v rc-update >/dev/null 2>&1; then
rc-service "$INIT_FILE" stop 2>/dev/null || true
rc-update del "$INIT_FILE" 2>/dev/null || true
rm -f "$INITD_DIR/$INIT_FILE"
else
echo "Unsupported init system."
fi
rm -f "$BIN_DIR/$UPDATE_COMMAND"
rm -f "$BIN_DIR/$WATCH_COMMAND"
rm -rf "$SHARE_DIR"
if [ -f "$ETC_FILE" ] && [ ! -s "$ETC_FILE" ]; then
rm -f "$ETC_FILE"
fi
echo "Uninstallation complete."