mirror of https://github.com/tteck/Proxmox.git
Update ha_setup.sh
This commit is contained in:
parent
1b77da6c18
commit
e5699e079f
50
ha_setup.sh
50
ha_setup.sh
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Setup script environment
|
set -o errexit
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -o errtrace
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
set -o nounset
|
||||||
set -o nounset #Treat unset variables as an error
|
set -o pipefail
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
|
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
trap 'die "Script interrupted."' INT
|
trap 'die "Script interrupted."' INT
|
||||||
|
|
||||||
|
@ -23,25 +23,22 @@ function msg() {
|
||||||
echo -e "$TEXT"
|
echo -e "$TEXT"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prepare container OS
|
echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m"
|
||||||
msg "Setting up container OS..."
|
|
||||||
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
|
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
|
||||||
locale-gen >/dev/null
|
locale-gen >/dev/null
|
||||||
apt-get -y purge openssh-{client,server} >/dev/null
|
apt-get -y purge openssh-{client,server} >/dev/null
|
||||||
apt-get autoremove >/dev/null
|
apt-get autoremove >/dev/null
|
||||||
|
|
||||||
# Update container OS
|
echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m"
|
||||||
msg "Updating container OS..."
|
|
||||||
apt update &>/dev/null
|
apt update &>/dev/null
|
||||||
apt-get -qqy upgrade &>/dev/null
|
apt-get -qqy upgrade &>/dev/null
|
||||||
|
|
||||||
# Install prerequisites
|
echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m"
|
||||||
msg "Installing prerequisites..."
|
|
||||||
apt-get -qqy install \
|
apt-get -qqy install \
|
||||||
curl &>/dev/null
|
curl \
|
||||||
|
wget &>/dev/null
|
||||||
# Customize Docker configuration
|
|
||||||
msg "Customizing Docker..."
|
echo -e "${CHECKMARK} \e[1;92m Customizing Docker... \e[0m"
|
||||||
DOCKER_CONFIG_PATH='/etc/docker/daemon.json'
|
DOCKER_CONFIG_PATH='/etc/docker/daemon.json'
|
||||||
mkdir -p $(dirname $DOCKER_CONFIG_PATH)
|
mkdir -p $(dirname $DOCKER_CONFIG_PATH)
|
||||||
cat >$DOCKER_CONFIG_PATH <<'EOF'
|
cat >$DOCKER_CONFIG_PATH <<'EOF'
|
||||||
|
@ -50,12 +47,10 @@ cat >$DOCKER_CONFIG_PATH <<'EOF'
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Install Docker
|
echo -e "${CHECKMARK} \e[1;92m Installing Docker.io... \e[0m"
|
||||||
msg "Installing Docker..."
|
apt-get install -y docker.io &>/dev/null
|
||||||
sh <(curl -sSL https://get.docker.com) &>/dev/null
|
|
||||||
|
|
||||||
# Install Portainer
|
echo -e "${CHECKMARK} \e[1;92m Installing Portainer... \e[0m"
|
||||||
msg "Installing Portainer..."
|
|
||||||
docker volume create portainer_data >/dev/null
|
docker volume create portainer_data >/dev/null
|
||||||
docker run -d \
|
docker run -d \
|
||||||
-p 8000:8000 \
|
-p 8000:8000 \
|
||||||
|
@ -66,8 +61,7 @@ docker run -d \
|
||||||
-v portainer_data:/data \
|
-v portainer_data:/data \
|
||||||
portainer/portainer-ce:latest &>/dev/null
|
portainer/portainer-ce:latest &>/dev/null
|
||||||
|
|
||||||
# Install Home Assistant
|
echo -e "${CHECKMARK} \e[1;92m Installing Home Assistant... \e[0m"
|
||||||
msg "Installing Home Assistant..."
|
|
||||||
docker volume create hass_config >/dev/null
|
docker volume create hass_config >/dev/null
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name homeassistant \
|
--name homeassistant \
|
||||||
|
@ -80,11 +74,10 @@ docker run -d \
|
||||||
--net=host \
|
--net=host \
|
||||||
homeassistant/home-assistant:stable &>/dev/null
|
homeassistant/home-assistant:stable &>/dev/null
|
||||||
|
|
||||||
# Customize container
|
echo -e "${CHECKMARK} \e[1;92m Customizing Container... \e[0m"
|
||||||
msg "Customizing container..."
|
rm /etc/motd
|
||||||
rm /etc/motd # Remove message of the day after login
|
rm /etc/update-motd.d/10-uname
|
||||||
rm /etc/update-motd.d/10-uname # Remove kernel information after login
|
touch ~/.hushlogin
|
||||||
touch ~/.hushlogin # Remove 'Last login: ' and mail notification after login
|
|
||||||
GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf"
|
GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf"
|
||||||
mkdir -p $(dirname $GETTY_OVERRIDE)
|
mkdir -p $(dirname $GETTY_OVERRIDE)
|
||||||
cat << EOF > $GETTY_OVERRIDE
|
cat << EOF > $GETTY_OVERRIDE
|
||||||
|
@ -95,6 +88,5 @@ EOF
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//')
|
systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//')
|
||||||
|
|
||||||
# Cleanup container
|
echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m"
|
||||||
msg "Cleanup..."
|
|
||||||
rm -rf /ha_setup.sh /var/{cache,log}/* /var/lib/apt/lists/*
|
rm -rf /ha_setup.sh /var/{cache,log}/* /var/lib/apt/lists/*
|
||||||
|
|
Loading…
Reference in New Issue