Skip to content

Commit

Permalink
Bug fixes and verious improments
Browse files Browse the repository at this point in the history
The following has been implemented
1) Fix permissions errors on the tracker file
2) Move the tracker file as part of "1"
3) Introduce a test for what was failing before
4) Change tests to use the makefile installation
5) Fix whiptail being the default: SHOW_UI was
   not being set to zero when unspecified
  • Loading branch information
NeroReflex committed Aug 18, 2024
1 parent 4bdd761 commit 353786b
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 466 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
run: |
cd test
./run.sh
- name: Test Tracker file permissions
run: |
docker run --name test_tracker -u root --rm --entrypoint=/workdir/test/test-permissions.sh -v $(pwd):/workdir -v /dev:/dev --privileged archlinux:latest
- name: Test Deployment creation & installation
run: |
docker run --name test_deploy -u root --rm --entrypoint=/workdir/test/test-deploy.sh -v $(pwd):/workdir -v /dev:/dev --privileged archlinux:latest
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ ifeq ($(PREFIX),)
PREFIX := /
endif

VERSION := $(shell git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')
ifeq ($(VERSION),)
VERSION := $(shell git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')
endif

.PHONY: install

Expand All @@ -17,8 +19,6 @@ install:
install -m 755 "__frzr-unlock" "${PREFIX}/usr/bin"
install -m 755 "frzr-bootloader" "${PREFIX}/usr/bin"
install -m 755 "__frzr-bootloader" "${PREFIX}/usr/bin"
install -m 755 "frzr-kernel" "${PREFIX}/usr/bin"
install -m 755 "__frzr-kernel" "${PREFIX}/usr/bin"
install -m 755 "frzr-version" "${PREFIX}/usr/bin"
install -m 755 "__frzr-version" "${PREFIX}/usr/bin"
install -m 755 "frzr-bootstrap" "${PREFIX}/usr/bin"
Expand Down
29 changes: 25 additions & 4 deletions __frzr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
source "${BASH_SOURCE%/*}/__frzr-envars"

frzr_status() {
echo "Error occurred in script: $0"
echo "Command: $BASH_COMMAND"
echo "Line: $LINENO"

# Output frzr status tracker using the JSON format
cat <<EOF
{
Expand Down Expand Up @@ -46,11 +50,28 @@ EOF
trap frzr_status SIGINT SIGTERM ERR

write_tracker_file() {
local running_user=$(whoami)
local grps=$(groups)

if [ ! -d "${TRACKER_FILE_DIR}" ]; then
if echo "$grps" | grep -Fq "frzr"; then
sg frzr -c "mkdir $TRACKER_FILE_DIR"
else
mkdir "${TRACKER_FILE_DIR}"
chmod g+w "${TRACKER_FILE_DIR}"
chown :frzr "${TRACKER_FILE_DIR}"
fi
fi

if [ ! -f "${TRACKER_FILE_PATH}" ]; then
touch "${TRACKER_FILE_PATH}"
chown $UID:379 "${TRACKER_FILE_PATH}"
chmod g+w "${TRACKER_FILE_PATH}"
if echo "$grps" | grep -Fq "frzr"; then
rm -f "${TRACKER_FILE_PATH}"
sg frzr -c "touch ${TRACKER_FILE_PATH}"
else
sudo rm -rf "${TRACKER_FILE_PATH}"
sudo touch "${TRACKER_FILE_PATH}"
sudo chown :frzr "${TRACKER_FILE_PATH}"
sudo chmod g+w "${TRACKER_FILE_PATH}"
fi
fi

frzr_status > "${TRACKER_FILE_PATH}"
Expand Down
6 changes: 5 additions & 1 deletion __frzr-envars
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ if [ -z "$EFI_MOUNT_PATH" ]; then
EFI_MOUNT_PATH="${MOUNT_PATH}/efi" # EFI mount path
fi

if [ -z "$SHOW_UI" ]; then
SHOW_UI="0"
fi

if [ -z "$FRZR_INSTALLER" ]; then
FRZR_INSTALLER="0"
fi
Expand All @@ -47,7 +51,7 @@ ACTUAL_CHECKSUM="" # Actual checksum of the file downloaded
STATE=""

# Tracker file directory
TRACKER_FILE_DIR="/tmp"
TRACKER_FILE_DIR="/tmp/frzr"
TRACKER_FILE_PATH="${TRACKER_FILE_DIR}/frzr.tracker"

# Signals
Expand Down
Loading

0 comments on commit 353786b

Please sign in to comment.