Skip to content

Commit

Permalink
Move configuration/*.sh files to .env and .env.dist
Browse files Browse the repository at this point in the history
  • Loading branch information
stevleibelt committed Nov 18, 2024
1 parent d8f835c commit 7645b75
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 114 deletions.
21 changes: 21 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
####
# Configuration file
#
# VALUE_NAME=<default_value> # <available_value>, [<available_value>...]
# 0,1: Handled as boolean values. 0 means off, 1 means on
####
ASK_TO_DUMP_ISO=0 #0|1
ASK_TO_RUN_ISO=0 #0|1
ASK_TO_UPLOAD_ISO=0 #0|1
BE_VERBOSE=0 #0|1
BUILD_FILE_NAME="archlinux-archzfs-${KERNEL}" #<string>
IS_DRY_RUN=0 #0|1
IS_FORCED=0 #0|1
KERNEL="linux" #linux|linux-lts
PATH_TO_SSH_KEY_FILE="~/.ssh/example_key" # used for uploading iso
REPO_INDEX="last" #week|month|yyyy/mm/dd
SCP_HOST_PATH="[email protected]:/my/path/" # used for uploading iso
USE_GIT_PACKAGE=0 #0|1
USE_DKMS=0 #0|1
USE_OTHER_REPO_INDEX=0 #0|1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.env
build.sh.log
configuration/*.sh
dynamic_data/*
last_build_date.txt
last_build_date_lts.txt
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
* Changed default values for [replace_zfsbootmenu.sh](source/replace_zfsbootmenu.sh)
* Default path for old ZBM is now `/mnt/efi...`
* Default path for new ZBM is now basepath of the called script
* Changed configuration file place (breaking change)
* Instead of different configuration files below `configuration`, there is now a unified `.env` file and a `.env.dist`
* Moved from build image `archlinux:latest` to `archlinux/archlinux:latest` to fix issues like [archinstal#2443](https://github.com/archlinux/archinstall/issues/2443)
* Moved archzfs mirrorlist to dedicated file `/etc/pacman.d/archzfs`

Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ docker run -e LOG_LEVEL=DEBUG -e RUN_LOCAL=true -v .:/tmp/lint ghcr.io/super-lin

Following issues are not reproducable on all my machines.

### error: target not found: ipw2100-fw
### Error: target not found: ipw2100-fw

* This error happens when calling `build.sh`
* [This](https://gitlab.archlinux.org/archlinux/archiso/-/commit/4d64a58a905403b3abfca5077dcd924ef7901ba7) commit seams to be the reason
Expand All @@ -93,14 +93,15 @@ Following issues are not reproducable on all my machines.

## Links

* [Another archiso build script by Maurice Zhou](https://gitlab.com/m_zhou/archiso)
* [archzfs archive containing each package ever build.](http://archzfs.com/archive_archzfs/) - 20240410
* [archiso documentation](https://git.archlinux.org/archiso.git/tree/docs)
* [archiso project page](https://git.archlinux.org/archiso.git)
* [Install UEFI and BIOS compatible Arch Linx with encrypted ZFS and ZFSBootMenu by Kayvlim](https://wiki.archlinux.org/title/User:Kayvlim/Install_UEFI_and_BIOS_compatible_Arch_Linux_with_Encrypted_ZFS_and_ZFSBootMenu#Swap) - 20221108
* [pacman wiki page](https://wiki.archlinux.org/index.php/Pacman)
* [OpenSSF Scorecard Report](https://securityscorecards.dev/viewer/?uri=github.com/stevleibelt/arch-linux-live-cd-iso-with-zfs) - 20240408
* [Ubuntu server zfsbootmenu](https://github.com/Sithuk/ubuntu-server-zfsbootmenu) - 20221108
* [Another archiso build script by Maurice Zhou: gitlab.com](https://gitlab.com/m_zhou/archiso)
* [archiso documentation: archlinux.org](https://git.archlinux.org/archiso.git/tree/docs)
* [archiso project page: archlinux.org](https://git.archlinux.org/archiso.git)
* [archlinux-lts-zfs: github.com](https://github.com/r-maerz/archlinux-lts-zfs) - 20241118
* [archzfs archive containing each package ever build: archzfs.com](http://archzfs.com/archive_archzfs/) - 20240410
* [Install UEFI and BIOS compatible Arch Linx with encrypted ZFS and ZFSBootMenu by Kayvlim: archlinux.org](https://wiki.archlinux.org/title/User:Kayvlim/Install_UEFI_and_BIOS_compatible_Arch_Linux_with_Encrypted_ZFS_and_ZFSBootMenu#Swap) - 20221108
* [pacman wiki page: archlinux.org](https://wiki.archlinux.org/index.php/Pacman)
* [OpenSSF Scorecard Report: securityscorecards.dev](https://securityscorecards.dev/viewer/?uri=github.com/stevleibelt/arch-linux-live-cd-iso-with-zfs) - 20240408
* [Ubuntu server zfsbootmenu: github.com](https://github.com/Sithuk/ubuntu-server-zfsbootmenu) - 20221108

## Contributers

Expand Down
22 changes: 13 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,8 @@ function _main ()
local ISO_FILE_PATH
local PATH_TO_THIS_SCRIPT
local PATH_TO_THE_DYNAMIC_DATA_DIRECTORY
local PATH_TO_THE_OPTIONAL_CONFIGURATION_FILE
local PATH_TO_THE_DISTRIBUTION_ENVIRONMENT_FILE
local PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE
local PATH_TO_THE_OUTPUT_DIRECTORY
local PATH_TO_THE_PROFILE_DIRECTORY
local PATH_TO_THE_SOURCE_DATA_DIRECTORY
Expand All @@ -857,7 +858,8 @@ function _main ()
CURRENT_WORKING_DIRECTORY=$(pwd)
PATH_TO_THIS_SCRIPT=$(cd $(dirname "${BASH_SOURCE[0]}"); pwd)

PATH_TO_THE_OPTIONAL_CONFIGURATION_FILE="${PATH_TO_THIS_SCRIPT}/configuration/build.sh"
PATH_TO_THE_DISTRIBUTION_ENVIRONMENT_FILE="${PATH_TO_THIS_SCRIPT}/.env.dist"
PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE="${PATH_TO_THIS_SCRIPT}/.env"
#begin of main variables declaration

#bo: user input
Expand All @@ -874,7 +876,6 @@ function _main ()
local SHOW_HELP
local USE_DKMS
local USE_OTHER_REPO_INDEX
local USED_CONFIGURATION_FILE

ALL_ARGUMENTS_TO_PASS="${@}"
ASK_TO_DUMP_ISO=1
Expand All @@ -889,13 +890,16 @@ function _main ()
USE_GIT_PACKAGE=0
USE_DKMS=0
USE_OTHER_REPO_INDEX=0
USED_CONFIGURATION_FILE=0

if [[ -f "${PATH_TO_THE_OPTIONAL_CONFIGURATION_FILE}" ]];
#bo: load environment files
set -a
source "${PATH_TO_THE_DISTRIBUTION_ENVIRONMENT_FILE}"
if [[ -f "${PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE}" ]];
then
. "${PATH_TO_THE_OPTIONAL_CONFIGURATION_FILE}"
USED_CONFIGURATION_FILE=1
source "${PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE}"
fi
set +a
#eo: load environment files

while true;
do
Expand Down Expand Up @@ -987,13 +991,13 @@ function _main ()
echo " IS_DRY_RUN >>${IS_DRY_RUN}<<."
echo " IS_FORCED >>${IS_FORCED}<<."
echo " KERNEL >>${KERNEL}<<."
echo " PATH_TO_THE_OPTIONAL_CONFIGURATION_FILE >>${PATH_TO_THE_OPTIONAL_CONFIGURATION_FILE}<<."
echo " PATH_TO_THE_DISTRIBUTION_ENVIRONMENT_FILE >>${PATH_TO_THE_DISTRIBUTION_ENVIRONMENT_FILE}<<."
echo " PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE >>${PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE}<<."
echo " REPO_INDEX >>${REPO_INDEX}<<."
echo " SHOW_HELP >>${SHOW_HELP}<<."
echo " USE_GIT_PACKAGE >>${USE_GIT_PACKAGE}<<."
echo " USE_DKMS >>${USE_DKMS}<<."
echo " USE_OTHER_REPO_INDEX >>${USE_OTHER_REPO_INDEX}<<."
echo " USED_CONFIGURATION_FILE >>${USED_CONFIGURATION_FILE}<<."
echo ""
fi

Expand Down
20 changes: 0 additions & 20 deletions configuration/build.sh.dist

This file was deleted.

8 changes: 0 additions & 8 deletions configuration/upload_iso.sh.dist

This file was deleted.

82 changes: 15 additions & 67 deletions upload_iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,59 +56,6 @@ function _create_latest_build_date ()
echo "${CREATION_DATE_TIME}" > "${LATEST_BUILD_DATE_FILE_PATH}"
}

####
# @param: <string: path_to_the_local_configuration_file
####
function _create_local_configuration_file ()
{
#bo: variables
local CURRENT_DATE
local PATH_TO_THE_LOCAL_CONFIGURATION
local PATH_TO_THE_LOCAL_CONFIGURATION_DIST

CURRENT_DATE=$(date +'%y-%m-%d')
PATH_TO_THE_LOCAL_CONFIGURATION="${1}"

PATH_TO_THE_LOCAL_CONFIGURATION_DIST="${PATH_TO_THE_LOCAL_CONFIGURATION}.dist"
#eo: variables

#bo: check environment
if [[ ! -f "${PATH_TO_THE_LOCAL_CONFIGURATION_DIST}" ]];
then
echo ":: ERROR - File does not exist!"
echo " File path >>${PATH_TO_THE_LOCAL_CONFIGURATION_DIST}<< is invalid."

exit 30
fi

echo ":: Local configration file is missing. I will create it but you need to answere some questions."

cp "${PATH_TO_THE_LOCAL_CONFIGURATION_DIST}" "${PATH_TO_THE_LOCAL_CONFIGURATION}"
#eo: check environment

#bo: user input ssh key
echo " Please insert the path to the ssh key we want to use."
#-e: enable readline. @see https://stackoverflow.com/questions/4819819/get-autocompletion-when-invoking-a-read-inside-a-bash-script
read -e PATH_TO_SSH_KEY_FILE

#eo: user input ssh key

#bo: user input destination scp host path"
echo " Please insert the destionation host path."
echo " Example: [email protected]:/foo/bar"
read SCP_HOST_PATH

echo "#@since: ${CURRENT_DATE}" >> "${PATH_TO_THE_LOCAL_CONFIGURATION}"
echo "####" >> "${PATH_TO_THE_LOCAL_CONFIGURATION}"
echo "" >> "${PATH_TO_THE_LOCAL_CONFIGURATION}"
echo "#0 = off, 1 = on" >> "${PATH_TO_THE_LOCAL_CONFIGURATION}"
echo "local PATH_TO_SSH_KEY_FILE=\"${PATH_TO_SSH_KEY_FILE}\"" >> "${PATH_TO_THE_LOCAL_CONFIGURATION}"
echo "local SCP_HOST_PATH=\"${SCP_HOST_PATH}\"" >> "${PATH_TO_THE_LOCAL_CONFIGURATION}"

_echo_if_be_verbose " Created file >>${PATH_TO_THE_LOCAL_CONFIGURATION}<<."
#eo: user input destination scp host path"
}

####
# @param <string: output>
####
Expand All @@ -123,19 +70,31 @@ function _echo_if_be_verbose ()
function _main ()
{
#bo: variables
local PATH_TO_THE_DISTRIBUTION_ENVIRONMENT_FILE
local PATH_TO_THE_ISO
local PATH_TO_THIS_SCRIPT
local PATH_TO_THE_ISO
local PATH_TO_THE_ISO_SHA512
local PATH_TO_THE_LATEST_BUILD_DATE
local PATH_TO_THE_LOCAL_CONFIGURATION

local PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE

PATH_TO_THIS_SCRIPT=$(cd $(dirname "${BASH_SOURCE[0]}"); pwd)

PATH_TO_THE_LOCAL_CONFIGURATION="${PATH_TO_THIS_SCRIPT}/configuration/upload_iso.sh"
PATH_TO_THE_DISTRIBUTION_ENVIRONMENT_FILE="${PATH_TO_THIS_SCRIPT}/.env.dist"
PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE="${PATH_TO_THIS_SCRIPT}/.env"
#eo: variables

#bo: load environment files
set -a
source "${PATH_TO_THE_DISTRIBUTION_ENVIRONMENT_FILE}"
if [[ -f "${PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE}" ]];
then
source "${PATH_TO_THE_OPTIONAL_ENVIRONMENT_FILE}"
fi
set +a
#eo: load environment files

#bo: user input
#we are storing all arguments for the case if the script needs to be re-executed as root/system user
local ALL_ARGUMENTS_TO_PASS
Expand Down Expand Up @@ -209,17 +168,6 @@ function _main ()
fi
#eo: output used flags

#bo: load or create local configuration
if [[ ! -f ${PATH_TO_THE_LOCAL_CONFIGURATION} ]];
then
_echo_if_be_verbose " No file >>${PATH_TO_THE_LOCAL_CONFIGURATION}<< found."
_create_local_configuration_file "${PATH_TO_THE_LOCAL_CONFIGURATION}"
fi

_echo_if_be_verbose " Sourcing file >>${PATH_TO_THE_LOCAL_CONFIGURATION}<< found."
source "${PATH_TO_THE_LOCAL_CONFIGURATION}"
#eo: load or create local configuration

#bo: environment check
if [[ ! -f "${PATH_TO_THE_ISO}" ]];
then
Expand Down Expand Up @@ -258,4 +206,4 @@ function _main ()
#eo: upload
}

_main ${@}
_main "${@}"

0 comments on commit 7645b75

Please sign in to comment.