Zen
3 years ago
14 changed files with 218 additions and 145 deletions
@ -1,29 +1,80 @@
|
||||
# This Makefile exists because it's my favorite way to simplify running groups of commands directly from the command line
|
||||
#
|
||||
# Variables
|
||||
IMAGE := raspios_lite_arm64.zip
|
||||
DOWNLOAD_LINK := https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2021-11-08/2021-10-30-raspios-bullseye-arm64-lite.zip
|
||||
# This Makefile exists because it's my favorite way to simplify running
|
||||
# groups of commands directly from the command line
|
||||
# -- Bare Metal Alchemist, 2022
|
||||
|
||||
alchemy: |
||||
@chmod +x recipes/alchemy.sh
|
||||
@recipes/alchemy.sh
|
||||
|
||||
aesthetic: |
||||
@chmod +x scripts/init.sh
|
||||
@scripts/init.sh
|
||||
@chmod +x recipes/init.sh
|
||||
@recipes/init.sh
|
||||
|
||||
autonomy: |
||||
@chmod +x scripts/ao.sh
|
||||
@scripts/ao.sh
|
||||
@chmod +x recipes/ao.sh
|
||||
@recipes/ao.sh
|
||||
|
||||
acquisition: |
||||
@chmod +x scripts/get-image.sh
|
||||
@scripts/get-image.sh
|
||||
@chmod +x recipes/get-image.sh
|
||||
@recipes/get-image.sh
|
||||
|
||||
imbuement: |
||||
@chmod +x scripts/write-image.sh
|
||||
@scripts/write-image.sh
|
||||
@chmod +x recipes/write-image.sh
|
||||
@recipes/write-image.sh
|
||||
|
||||
preparations: |
||||
@chmod +x scripts/prep-rpi-usb.sh
|
||||
@scripts/prep-rpi-usb.sh
|
||||
@chmod +x recipes/prep-rpi-usb.sh
|
||||
@recipes/prep-rpi-usb.sh
|
||||
|
||||
prosperity: |
||||
@echo "This will install prestashop eventually"
|
||||
|
||||
manifest: |
||||
@chmod +x scripts/wordpress.sh
|
||||
@scripts/wordpress.sh
|
||||
@chmod +x recipes/wordpress.sh
|
||||
@recipes/wordpress.sh
|
||||
|
||||
help: |
||||
@echo "We'll get there!"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# This is just for fun!
|
||||
something: |
||||
@echo "You might need to be a little more creative than that..."
|
||||
|
||||
cool: |
||||
@echo "Maybe try 'make help' if you're confused?"
|
||||
|
@ -0,0 +1,95 @@
|
||||
#!/bin/sh |
||||
# Bare Metal Alchemist, 2022 |
||||
|
||||
############################################# |
||||
# Lead - ♄ # |
||||
############################################# |
||||
|
||||
# The most basic ingredient in an Alchemy recipe, lead is used in all |
||||
# recipes in this repository to standardize some simple things that I |
||||
# rely on to make scripts concise and pleasant to use |
||||
|
||||
# --------------- Escape Codes --------------- |
||||
# These constants are used to add color and text formatting to the |
||||
# terminal's output -- Further reading: ANSI Escape Codes |
||||
RED="\e[0;31m" |
||||
GREEN="\e[0;32m" |
||||
BLUE="\e[0;34m" |
||||
BOLD="\e[1m" |
||||
ULINE="\e[4m" |
||||
RESET="\e[0m" |
||||
|
||||
# --------------- Traps --------------- |
||||
|
||||
# Traps, in the case of shell scripting, listen for certain signals |
||||
# that are broadcast by the system and execute a command in response |
||||
|
||||
# Make sure that ctrl+C consistently exits the script |
||||
trap "exit" INT |
||||
|
||||
# Give informative error messages when we receive ERR |
||||
trap 'echo -e "${RED}Oops!${RESET} Something went wrong on line $LINENO of this script. Exit code was $?" >&2' ERR |
||||
|
||||
|
||||
# --------------- Environment Setup --------------- |
||||
|
||||
if [ -f .env ]; then |
||||
export $(grep -v '^#' .env | xargs) |
||||
else |
||||
if [ -z $ALCHEMY ]; then |
||||
echo "No .env file, this might cause some issues..." |
||||
fi |
||||
fi |
||||
|
||||
|
||||
# --------------- Functions --------------- |
||||
|
||||
# Coding Moment: generally, whenever you see something with brackets |
||||
# at the end of it, like this() or like(this), it's a function! |
||||
# It takes inputs and gives (or does) something as an output |
||||
|
||||
# This one installs utilities to your OS (If you need them!) |
||||
install_if_needed() { |
||||
for package in "$@" # $@ means "all the arguments you passed |
||||
do |
||||
|
||||
case $DISTRO in |
||||
"debian") |
||||
# TODO Better installation detection than "which" |
||||
if [ -z $(which $package 2>/dev/null) ]; then |
||||
echo "installing" $package |
||||
sudo apt install -y $package |
||||
else |
||||
echo $package 'already installed!' |
||||
fi |
||||
;; |
||||
"arch") |
||||
if pacman -Qi $package &>/dev/null; then |
||||
echo $package 'already installed!' |
||||
else |
||||
echo "installing" $package |
||||
sudo pacman -S $package --noconfirm --needed |
||||
fi |
||||
;; |
||||
"fedora") |
||||
# TODO Better installation detection than "which" |
||||
if [ -z $(which $package 2>/dev/null) ]; then |
||||
echo "installing" $package |
||||
sudo dnf install -y $package |
||||
else |
||||
echo $package 'already installed!' |
||||
fi |
||||
;; |
||||
"mac") |
||||
# TODO Better installation detection than "which" |
||||
if [ -z $(which $package 2>/dev/null) ]; then |
||||
echo "installing" $package |
||||
brew install $package |
||||
else |
||||
echo $package 'already installed!' |
||||
fi |
||||
;; |
||||
esac |
||||
done |
||||
} |
||||
|
@ -0,0 +1,9 @@
|
||||
#!/bin/sh |
||||
|
||||
# Installs certbot and runs it |
||||
# -- Bare Metal Alchemist, 2022 |
||||
|
||||
source ingredients/lead |
||||
|
||||
install_if_needed certbot python3-certbot-nginx |
||||
sudo certbot --nginx |
@ -1,48 +0,0 @@
|
||||
#!/bin/bash |
||||
|
||||
# Installs certbot and runs it |
||||
# ~ Zen, 2022 |
||||
|
||||
if [ -f "/etc/debian_version" ]; then |
||||
DISTRO="debian" |
||||
echo "Debian, Ubuntu, or Raspbian OS detected." |
||||
elif [ -f "/etc/arch-release" ]; then |
||||
DISTRO="arch" |
||||
echo "Arch- or Manjaro-based OS detected." |
||||
elif [ $(uname | grep -c "Darwin") -eq 1 ]; then |
||||
DISTRO="mac" |
||||
echo "MacOS detected." |
||||
else |
||||
echo "I don't know what OS you're running! Cancelling this operation." |
||||
exit 1 |
||||
fi |
||||
|
||||
echo "" |
||||
|
||||
install_if_needed() { |
||||
for package in "$@" |
||||
do |
||||
if [ -z $(which $package) ]; then |
||||
echo "installing" $package |
||||
|
||||
case $DISTRO in |
||||
"debian") |
||||
sudo apt install -y $package |
||||
;; |
||||
"arch") |
||||
sudo pacman -S $package |
||||
;; |
||||
"mac") |
||||
brew install $package |
||||
;; |
||||
esac |
||||
|
||||
else |
||||
echo $package 'already installed!' |
||||
fi |
||||
done |
||||
|
||||
} |
||||
|
||||
install_if_needed certbot python3-certbot-nginx |
||||
sudo certbot --nginx |
@ -1,53 +0,0 @@
|
||||
#!/bin/bash |
||||
|
||||
# Font decoration for better a e s t h e t i c |
||||
RED="\e[0;31m" |
||||
GREEN="\e[0;32m" |
||||
BLUE="\e[0;34m" |
||||
BOLD="\e[1m" |
||||
ULINE="\e[4m" |
||||
RESET="\e[0m" |
||||
|
||||
# Make sure that ctrl+C actually exits the script |
||||
trap "exit" INT |
||||
|
||||
# Give informative error messages |
||||
trap 'echo -e "${RED}Oops!${RESET} Something went wrong on line $LINENO of this script. Exit code was $?" >&2' ERR |
||||
|
||||
# --------------- Functions --------------- |
||||
# Coding Moment: generally, whenever you see something with brackets at the end of it, like this() |
||||
# or like(this), it's a function! It takes inputs and gives (or does) something as an output |
||||
|
||||
install_if_needed() { |
||||
for package in "$@" |
||||
do |
||||
# TODO Better installation detection than "which" |
||||
if [ -z $(which $package 2>/dev/null) ]; then |
||||
echo "installing" $package |
||||
|
||||
case $DISTRO in |
||||
"debian") |
||||
sudo apt install -y $package |
||||
;; |
||||
"arch") |
||||
sudo pacman -S $package --noconfirm --needed |
||||
;; |
||||
"fedora") |
||||
sudo dnf install -y $package |
||||
;; |
||||
"mac") |
||||
brew install $package |
||||
;; |
||||
esac |
||||
else |
||||
echo $package 'already installed!' |
||||
fi |
||||
done |
||||
} |
||||
|
||||
# --------------- Environment Setup --------------- |
||||
if [ -f .env ]; then |
||||
export $(grep -v '^#' .env | xargs) |
||||
else |
||||
echo "No .env file, this might cause some issues..." |
||||
fi |
Loading…
Reference in new issue