lotus/tools/packer/setup-snap.sh

47 lines
1.2 KiB
Bash
Raw Normal View History

2021-12-18 01:06:32 +00:00
#!/usr/bin/env bash
# This script is executed by packer to setup the image.
# When this script is run, packer will have already copied binaries into the home directory of
# whichever user it has access too. This script is executed from within the home directory of that
# user. Bear in mind that different cloud providers, and different images on the same cloud
# provider will have a different initial user account.
set -x
# Become root, if we aren't already.
# Docker images will already be root. AMIs will have an SSH user account.
if [ x$UID != x0 ]
then
printf -v cmd_str '%q ' "$0" "$@"
exec sudo su -c "$cmd_str"
fi
2021-12-18 01:14:53 +00:00
set -e
2021-12-18 01:06:32 +00:00
MANAGED_FILES=(
/etc/motd
)
2021-12-18 01:30:23 +00:00
# this is required on digitalocean, which does not have snap seeded correctly at this phase.
apt update
apt reinstall snapd
2022-01-19 20:30:36 +00:00
snap install lotus-filecoin
2021-12-18 01:06:32 +00:00
snap alias lotus-filecoin.lotus lotus
2022-01-19 01:35:34 +00:00
snap alias lotus-file.con.lotus-daemon lotus-daemon
2021-12-18 01:06:32 +00:00
snap alias lotus-filecoin.lotus-miner lotus-miner
2022-01-19 01:35:34 +00:00
snap alias lotus-filecoin.lotus-worker lotus-worker
2021-12-18 01:06:32 +00:00
2022-01-19 01:35:34 +00:00
snap stop lotus-filecoin.lotus-daemon
2021-12-18 01:49:32 +00:00
2021-12-18 01:06:32 +00:00
# Setup firewall
yes | ufw enable
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
2021-12-18 01:49:32 +00:00
2021-12-18 02:07:54 +00:00
set +e
2021-12-18 01:49:32 +00:00
curl -L https://raw.githubusercontent.com/digitalocean/marketplace-partners/master/scripts/90-cleanup.sh | bash