Browse Source

Updated script according to feedback

main
Zen 3 years ago
parent
commit
a1cf8c7a43
  1. 2
      Makefile
  2. 18
      README.md
  3. 4
      resources/ao-service-template
  4. 1
      resources/tor-service-template
  5. 14
      scripts/ao.sh
  6. 17
      scripts/get-image.sh

2
Makefile

@ -4,7 +4,7 @@
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
it-pretty:
aesthetic:
@chmod +x scripts/init.sh
@scripts/init.sh

18
README.md

@ -1,6 +1,10 @@
# Alchemy
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**)
## Commands
`make acquisition` runs a script that downloads a file (either Raspbian or Manjaro) and confirms it with a sha256 sum.
@ -9,7 +13,7 @@ A collection of scripts for working with bare metal.
`make preparations` configures some basic settings for use on a fresh RPi installation (SSH, hostname)
`make it-pretty` is meant to be run on a freshly installed operating system.
`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
@ -17,12 +21,8 @@ It installs some utilities that I rely on for maximum developmental efficiency a
`make manifest` Installs and configures Wordpress on the system
### A Note on "resources" vs. "images"
These are two folders that scripts will pull data from and write data to. In no case should any of these files be modified directly.
Scripts will copy them to a workspace or the base directory and make modifications there before implementing them.
The difference between a 'resource' and an 'image' (in the case of this ecosystem) is that *resources are platform agnostic*, meaning
that they will apply universally to whatever system they are installed on. Conversely, *images are platform-specific*, and therefore
are subject to the architecture of the computer system in order to do what they need to do.
For the sake of not filling this project with unnecessary data, I will rely on download scripts to populate the images folder.
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.
The `resources/` folder contains templates and other files that are small enough to be moved around with the scripts.
Some of these files are fragile and should be considered read-only.

4
resources/ao-service-template

@ -2,8 +2,8 @@
Description=ao-daemon
[Service]
WorkingDirectory=HOME/ao-react
ExecStart=NODE --experimental-specifier-resolution=node -r dotenv/config HOME/ao-react/src/server/app.js
WorkingDirectory=HOME/ao-AO
ExecStart=NODE NODE_PARAMS HOME/ao-AO/src/server/app.js
User=USER
Type=simple
Restart=on-failure

1
resources/tor-service-template

@ -15,7 +15,6 @@ TimeoutSec=60
Restart=on-failure
WatchdogSec=60
LimitNOFILE=32768
User=root
Group=USER
# Hardening

14
scripts/ao.sh

@ -25,6 +25,14 @@ echo ""
echo -e "This script is designed to ask you just enough questions to keep you involved in the process,\nwhile making it as easy as possible for you to get it going. \n\n${BLUE}press enter to continue${RESET}"
read
if [ "$EUID" -eq 0 ]; then
echo -e "${RED}Woah there!${RESET} Seems you're running this script as a superuser."
echo ""
echo "That might cause some issues with permissions and whatnot. Run this script as your default user (without sudo) and I'll ask you when I need superuser permissions"
echo ""
exit 1
fi
echo -e "Making sure we've got the basics..."
echo -e "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)"
case $DISTRO in
@ -248,6 +256,8 @@ case $AO in
npm run build
npm run checkconfig
popd
NODE_PARAMS=''
;;
"react")
echo -e "Installing ${BLUE}ao-react${RESET}"
@ -269,6 +279,8 @@ case $AO in
npm install
npm run webpack
popd
NODE_PARAMS='--experimental-specifier-resolution=node -r dotenv/config'
;;
esac
@ -436,6 +448,8 @@ else
sudo sed -i "s#USER#${USER}#g" $AO_SERVICE
sudo sed -i "s#HOME#${HOME}#g" $AO_SERVICE
sudo sed -i "s#NODE#$(which node)#g" $AO_SERVICE
sudo sed -i "s#AO#${AO}#g" $AO_SERVICE
sudo sed -i "s#NODE_PARAMS#${NODE_PARAMS}#g" $AO_SERVICE
fi
echo -e "Enabling and starting the ${GREEN}AO${RESET}'s backend"
sudo systemctl enable ao

17
scripts/get-image.sh

@ -17,12 +17,16 @@ RASPBIAN_IMAGE=2021-10-30-raspios-bullseye-arm64-lite.zip
MANJARO_DOWNLOAD_LINK=https://download.manjaro.org/kde/21.2.1/manjaro-kde-21.2.1-220103-linux515.iso
MANJARO_IMAGE=manjaro-kde-21.2.1-220103-linux515.iso
UBUNTU_DOWNLOAD_LINK=https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-desktop-amd64.iso
UBUNTU_IMAGE=ubuntu-20.04.3-desktop-amd64.iso
UBUNTU_SHA256SUM="5fdebc435ded46ae99136ca875afc6f05bde217be7dd018e1841924f71db46b5 ubuntu-20.04.3-desktop-amd64.iso"
echo -e "${BOLD}Ah, I see you're looking to download an image!${RESET}"
echo ""
echo -e "${ULINE}Which one?${RESET}"
echo -e "${BOLD}1. ${RESET} Raspbian (arm64 image)"
echo -e "${BOLD}2. ${RESET} Manjaro (x86_64 image)"
echo -e "${BOLD}3. ${RESET} Ubuntu (x86_64 image)"
echo ""
IMAGE=
@ -43,6 +47,12 @@ while [ -z $IMAGE ]; do
DOWNLOAD_LINK=$MANJARO_DOWNLOAD_LINK
IMAGE=$MANJARO_IMAGE
;;
3)
echo "Ubuntu selected!"
DOWNLOAD_LINK=$UBUNTU_DOWNLOAD_LINK
IMAGE=$UBUNTU_IMAGE
SHA256SUM=$UBUNTU_SHA256SUM
;;
*)
echo "wait that doesn't make sense, try again"
;;
@ -58,9 +68,14 @@ else
curl -o images/$IMAGE $DOWNLOAD_LINK
fi
echo "Getting sha256sum and comparing..."
cd images
if [[ -z $SHA256SUM ]]; then
echo "Getting sha256sum and comparing..."
curl -so image.sha256 $DOWNLOAD_LINK.sha256
else
echo "${SHA256SUM}" > image.sha256
fi
sha256sum $IMAGE > computed.sha256
diff image.sha256 computed.sha256

Loading…
Cancel
Save