Browse Source

Updated README and 'remember' function

main
Zen 3 years ago
parent
commit
3954379633
  1. 41
      README.md
  2. 2
      ingredients/copper
  3. 26
      ingredients/lead

41
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.

2
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"
}

26
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
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
}

Loading…
Cancel
Save