-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5822aad
commit 3e215b2
Showing
1 changed file
with
86 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,92 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# | ||
set -euo pipefail | ||
|
||
SRCDIR="/opt/arm" | ||
DATADIR="/srv/docker/arm" | ||
RED='\033[1;31m' | ||
NC='\033[0m' # No Color | ||
FORK=shitwolfymakes | ||
TAG=latest | ||
function usage() { | ||
echo -e "\nUsage: docker_setup.sh [OPTIONS]" | ||
echo -e " -f <fork>\tSpecify the fork to pull from on DockerHub. \n\t\tDefault is \"$FORK\"" | ||
echo -e " -t <tag>\tSpecify the tag to pull from on DockerHub. \n\t\tDefault is \"$TAG\"" | ||
} | ||
|
||
git clone -b docker --depth=1 https://github.com/1337-server/automatic-ripping-machine.git "$SRCDIR" | ||
mkdir -p "$DATADIR" | ||
while getopts 'f:t:' OPTION | ||
do | ||
case $OPTION in | ||
f) FORK=$OPTARG | ||
;; | ||
t) TAG=$OPTARG | ||
;; | ||
?) usage | ||
exit 2 | ||
;; | ||
esac | ||
done | ||
IMAGE="$FORK/automatic-ripping-machine:$TAG" | ||
|
||
cd "$SRCDIR" | ||
docker build -t arm ${APT_PROXY:+--build-target ${APT_PROXY}} . | ||
function install_reqs() { | ||
apt update -y && apt upgrade -y | ||
apt install -y curl lsscsi | ||
} | ||
|
||
install setup/docker-arm.rules /etc/udev/rules.d/docker-arm.rules | ||
udevadm control --reload | ||
echo done. insert a disc... | ||
function add_arm_user() { | ||
echo -e "${RED}Adding arm user${NC}" | ||
# create arm group if it doesn't already exist | ||
if ! [[ "$(getent group arm)" ]]; then | ||
groupadd arm | ||
else | ||
echo -e "${RED}arm group already exists, skipping...${NC}" | ||
fi | ||
|
||
# create arm user if it doesn't already exist | ||
if ! id arm >/dev/null 2>&1; then | ||
useradd -m arm -g arm | ||
passwd arm | ||
else | ||
echo -e "${RED}arm user already exists, skipping...${NC}" | ||
fi | ||
usermod -aG cdrom,video arm | ||
} | ||
|
||
function launch_setup() { | ||
# install docker | ||
if [ -e /usr/bin/docker ]; then | ||
echo -e "${RED}Docker installation detected, skipping...${NC}" | ||
else | ||
echo -e "${RED}Installing Docker${NC}" | ||
# the convenience script auto-detects OS and handles install accordingly | ||
curl -sSL https://get.docker.com | bash | ||
usermod -aG docker arm | ||
fi | ||
} | ||
|
||
function pull_image() { | ||
echo -e "${RED}Pulling image from $IMAGE${NC}" | ||
docker pull "$IMAGE" | ||
} | ||
|
||
function setup_mountpoints() { | ||
echo -e "${RED}Creating mount points${NC}" | ||
for dev in /dev/sr?; do | ||
sudo -u arm mkdir -p "/mnt$dev" | ||
done | ||
} | ||
|
||
function save_start_command() { | ||
url="https://raw.githubusercontent.com/$FORK/automatic-ripping-machine/main/scripts/docker/start_arm_container.sh" | ||
cd ~arm | ||
sudo -u arm curl -fsSL "$url" -o start_arm_container.sh | ||
chmod +x start_arm_container.sh | ||
} | ||
|
||
|
||
# start here | ||
install_reqs | ||
add_arm_user | ||
install_docker | ||
pull_image | ||
setup_mountpoints | ||
save_start_command | ||
|
||
echo -e "${RED}Installation complete. A template command to run the ARM container is located in: $(echo ~arm) ${NC}" |