diff --git a/README.md b/README.md index b878d04..8a603fb 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,18 @@ A collection of scripts for working with bare metal. ## Initialization -This script package requires some initialization to make sure that the system it runs on has the necessary tools to work properly. -Run `./init.sh` to set up the environment (**You might have to run `chmod +x init.sh` to use it**) +Ideally, this package should be able to be initialized by running `make alchemy`. +It may be the case that your system does not support `make` by default, +in which case you can initialize the environment by running the following: +`chmod +x recipes/alchemy.sh; recipes/alchemy.sh` -## Commands +## Recipes +Recipes are a core component of the Alchemy ecosystem. They are stored +in the `recipes/` directory and common ones can be sourced via make. + +Some common recipes are listed below: + +`make autonomy` runs an interactive installer to get AO up and running on the current system `make acquisition` runs a script that downloads a file (either Raspbian or Manjaro) and confirms it with a sha256 sum. @@ -14,13 +22,32 @@ Run `./init.sh` to set up the environment (**You might have to run `chmod +x ini `make preparations` configures some basic settings for use on a fresh RPi installation (SSH, hostname) `make aesthetic` is meant to be run on a freshly installed operating system. -It installs some utilities that I rely on for maximum developmental efficiency and generally makes the terminal nicer to look at. - -`make autonomy` runs an interactive installer to get AO up and running on the current system +It installs some utilities that I rely on for maximum developmental +efficiency and generally makes the terminal nicer to look at. `make manifest` Installs and configures Wordpress on the system -### A Note on "resources" vs. "images" +## Ingredients +Another core component of the Alchemy ecosystem are ingredients, which +are groups of shell commands that can be sourced for use in recipes. +These ingredients loosely follow themes which are outlined in greater +detail within the ingredient files iteself. Brief summaries: + +`lead` is the base component for recipes and other ingredients as well. +It provides infrastructure that makes development in Alchemy more accessible. + +`tin` corresponds to hardware and interaction with physical systems. + +`iron` forms the core of web development in the ecosystem. + +`copper` corresponds to connectivity to other systems on the network. + +`silver` is an ethical system of currency that is aimed to support the trade +of goods and services within a smaller community. **WIP** + +`gold` corresponds to the Bitcoin/Lightning ecosystem. + +### Other folders the `images/` folder is where alchemy scripts will store files meant to be written to hard drives, generally operating systems. Due to the nature of images being both bulky and platform-dependent, they are not included by default in this ecosystems. diff --git a/ingredients/copper b/ingredients/copper index 4287743..3ab2071 100644 --- a/ingredients/copper +++ b/ingredients/copper @@ -68,7 +68,7 @@ get_external_ip() { esac EXTERNAL_IP=$(dig @resolver4.opendns.com myip.opendns.com +short) - echo "Your external IP is $EXTERNAL_IP" + echo "Your external IP is ${BLUE}$EXTERNAL_IP${RESET}" remember "EXTERNAL_IP=$EXTERNAL_IP" } diff --git a/ingredients/lead b/ingredients/lead index fc23171..e6ba4c8 100644 --- a/ingredients/lead +++ b/ingredients/lead @@ -104,9 +104,33 @@ install_if_needed() { # It takes values and stores them away in the env for later reference remember() { KEY=$(echo ${1} | cut -d'=' -f 1) - if [[ ${1} =~ ^[A-Z_]+\=[A-Za-z0-9/._]*$ ]] && [[ -z $(env | grep ${KEY}) ]]; then - echo "${1}" >> .env - export ${1} + VALUE=$(echo ${1} | cut -d'=' -f 2) + + if [[ ! $KEY =~ ^[A-Z_]+$ ]]; then + echo "Keys must consist only of capital letters and underscores" + fi + + if [[ ! $VALUE =~ ^[A-Za-z0-9/_.]+$ ]]; then + echo "Valid characters for env values: letters, numbers, \".\",\"/\",\"_\"" + fi + + if [[ ${1} =~ ^[A-Z_]+\=[A-Za-z0-9/._]*$ ]]; then + if [[ -n $(env | grep ${KEY}) ]]; then + echo -e "${BLUE}${KEY}${RESET} has already been defined in the env!" + echo -n "would you like to overwrite it? ${BLUE}(y/n)${RESET} " + read overwrite + case $overwrite in + "y" | "Y") + unset ${KEY} + sed -i "/^${KEY}.*$/d" .env + echo "${1}" >> .env + export ${1} + ;; + esac + else + echo "${1}" >> .env + export ${1} + fi fi }