-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
97 lines (79 loc) · 3.14 KB
/
Copy pathinstall.sh
File metadata and controls
97 lines (79 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
# Copyright 2025 Genesis Corporation
#
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -eu
set -x
set -o pipefail
AGENT_PATH="/opt/universal_agent"
IMG_ARTS_PATH="/opt/gci_base/genesis/images/genesis_base"
WORK_DIR="/var/lib/genesis"
SYSTEMD_SERVICE_DIR=/etc/systemd/system/
PASSWD="${GEN_USER_PASSWD:-ubuntu}"
SDK_PATH="/opt/gcl_sdk"
DEV_MODE=$([ -d "$SDK_PATH" ] && echo "true" || echo "false")
# Metrics and logs
ALLOY_VERSION="1.10.0"
# Install packages
sudo apt update
sudo apt install -y build-essential python3.12-dev python3.12-venv \
cloud-guest-utils irqbalance qemu-guest-agent libev-dev rsync parted j2cli
export UV_INSTALLER_GHE_BASE_URL=https://github.com
curl -LsSf https://github.com/astral-sh/uv/releases/download/0.11.7/uv-installer.sh | sh
source "$HOME"/.local/bin/env
# Install the Core Agent
# Prepare a fresh virtrual environment
rm -fr "$AGENT_PATH/.venv"
mkdir -p "$AGENT_PATH/.venv"
python3 -m venv "$AGENT_PATH/.venv"
source "$AGENT_PATH"/.venv/bin/activate
pip install pip --upgrade
# In the dev mode the genesis_core package is installed from the local machine
if [[ "$DEV_MODE" == "true" ]]; then
pip install -r "$SDK_PATH"/requirements.txt
pip install -e "$SDK_PATH"
# Install the Core Agent as a package from pypi
else
pip install gcl-sdk=="$GEN_SDK_VERSION"
fi
sudo cp -r "$IMG_ARTS_PATH/etc/genesis_universal_agent" /etc/
sudo ln -sf "$AGENT_PATH/.venv/bin/genesis-universal-agent" "/usr/bin/genesis-universal-agent"
# Install stuff for bootstrap procedure and systemd services
sudo mkdir -p "$WORK_DIR/bootstrap/scripts/"
sudo cp "$IMG_ARTS_PATH/bootstrap.sh" "$WORK_DIR/bootstrap/"
sudo cp "$IMG_ARTS_PATH/root_autoresize.sh" "/usr/bin/"
sudo cp "$IMG_ARTS_PATH/etc/systemd/genesis-bootstrap.service" $SYSTEMD_SERVICE_DIR
sudo cp "$IMG_ARTS_PATH/etc/systemd/genesis-root-autoresize.service" $SYSTEMD_SERVICE_DIR
sudo cp "$IMG_ARTS_PATH/etc/systemd/genesis-universal-agent.service" $SYSTEMD_SERVICE_DIR
sudo mkdir "/usr/local/lib/genesis/"
sudo cp -a "$IMG_ARTS_PATH/lib/." "/usr/local/lib/genesis/"
# Enable genesis core services
sudo systemctl enable genesis-bootstrap genesis-root-autoresize genesis-universal-agent
# Install Alloy
wget -q https://github.com/grafana/alloy/releases/download/v${ALLOY_VERSION}/alloy-${ALLOY_VERSION}-1.amd64.deb
sudo dpkg -i alloy-${ALLOY_VERSION}-1.amd64.deb
rm -f alloy-${ALLOY_VERSION}-1.amd64.deb
# Set default password
cat > /tmp/__passwd <<EOF
ubuntu:$PASSWD
EOF
sudo chpasswd < /tmp/__passwd
rm -f /tmp/__passwd
# Cleanup
sudo rm -fr /opt/gci_base
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*
sudo rm -rf /tmp/*
fstrim -v /