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 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 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 @chmod +x scripts/init.sh
@scripts/init.sh @scripts/init.sh

18
README.md

@ -1,6 +1,10 @@
# Alchemy # Alchemy
A collection of scripts for working with bare metal. 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 ## Commands
`make acquisition` runs a script that downloads a file (either Raspbian or Manjaro) and confirms it with a sha256 sum. `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 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. 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 `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 `make manifest` Installs and configures Wordpress on the system
### A Note on "resources" vs. "images" ### 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. the `images/` folder is where alchemy scripts will store files meant to be written to hard drives, generally operating systems.
Scripts will copy them to a workspace or the base directory and make modifications there before implementing them. Due to the nature of images being both bulky and platform-dependent, they are not included by default in this ecosystems.
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 `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 Description=ao-daemon
[Service] [Service]
WorkingDirectory=HOME/ao-react WorkingDirectory=HOME/ao-AO
ExecStart=NODE --experimental-specifier-resolution=node -r dotenv/config HOME/ao-react/src/server/app.js ExecStart=NODE NODE_PARAMS HOME/ao-AO/src/server/app.js
User=USER User=USER
Type=simple Type=simple
Restart=on-failure Restart=on-failure

1
resources/tor-service-template

@ -15,7 +15,6 @@ TimeoutSec=60
Restart=on-failure Restart=on-failure
WatchdogSec=60 WatchdogSec=60
LimitNOFILE=32768 LimitNOFILE=32768
User=root
Group=USER Group=USER
# Hardening # 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}" 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 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 "Making sure we've got the basics..."
echo -e "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)" echo -e "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)"
case $DISTRO in case $DISTRO in
@ -248,6 +256,8 @@ case $AO in
npm run build npm run build
npm run checkconfig npm run checkconfig
popd popd
NODE_PARAMS=''
;; ;;
"react") "react")
echo -e "Installing ${BLUE}ao-react${RESET}" echo -e "Installing ${BLUE}ao-react${RESET}"
@ -269,6 +279,8 @@ case $AO in
npm install npm install
npm run webpack npm run webpack
popd popd
NODE_PARAMS='--experimental-specifier-resolution=node -r dotenv/config'
;; ;;
esac esac
@ -436,6 +448,8 @@ else
sudo sed -i "s#USER#${USER}#g" $AO_SERVICE sudo sed -i "s#USER#${USER}#g" $AO_SERVICE
sudo sed -i "s#HOME#${HOME}#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#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 fi
echo -e "Enabling and starting the ${GREEN}AO${RESET}'s backend" echo -e "Enabling and starting the ${GREEN}AO${RESET}'s backend"
sudo systemctl enable ao 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_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 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 -e "${BOLD}Ah, I see you're looking to download an image!${RESET}"
echo "" echo ""
echo -e "${ULINE}Which one?${RESET}" echo -e "${ULINE}Which one?${RESET}"
echo -e "${BOLD}1. ${RESET} Raspbian (arm64 image)" echo -e "${BOLD}1. ${RESET} Raspbian (arm64 image)"
echo -e "${BOLD}2. ${RESET} Manjaro (x86_64 image)" echo -e "${BOLD}2. ${RESET} Manjaro (x86_64 image)"
echo -e "${BOLD}3. ${RESET} Ubuntu (x86_64 image)"
echo "" echo ""
IMAGE= IMAGE=
@ -43,6 +47,12 @@ while [ -z $IMAGE ]; do
DOWNLOAD_LINK=$MANJARO_DOWNLOAD_LINK DOWNLOAD_LINK=$MANJARO_DOWNLOAD_LINK
IMAGE=$MANJARO_IMAGE 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" echo "wait that doesn't make sense, try again"
;; ;;
@ -58,9 +68,14 @@ else
curl -o images/$IMAGE $DOWNLOAD_LINK curl -o images/$IMAGE $DOWNLOAD_LINK
fi fi
echo "Getting sha256sum and comparing..."
cd images cd images
if [[ -z $SHA256SUM ]]; then
echo "Getting sha256sum and comparing..."
curl -so image.sha256 $DOWNLOAD_LINK.sha256 curl -so image.sha256 $DOWNLOAD_LINK.sha256
else
echo "${SHA256SUM}" > image.sha256
fi
sha256sum $IMAGE > computed.sha256 sha256sum $IMAGE > computed.sha256
diff image.sha256 computed.sha256 diff image.sha256 computed.sha256

Loading…
Cancel
Save