Skip to content

Commit 2e12bb7

Browse files
committed
supporting tfrobot version passed to flist and multiple ssh support
1 parent 2fa5282 commit 2e12bb7

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

tfgrid3/tfrobot/Dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ RUN curl -s https://api.github.com/repos/threefoldtech/zinit/releases/latest | \
1313

1414
RUN chmod +x /sbin/zinit
1515
COPY scripts/ufw.sh /usr/local/bin/
16+
COPY scripts/tfrobot.sh /usr/local/bin/
1617

1718
# Adding zinit config files
1819
ADD zinit /etc/zinit/
1920

20-
# Install latest tfrobot
21-
RUN tfrobot_version=$(curl -s https://api.github.com/repos/threefoldtech/tfgrid-sdk-go/releases/latest | grep 'tag_name' | cut -d '"' -f 4 ) && \
22-
wget "https://github.com/threefoldtech/tfgrid-sdk-go/releases/download/${tfrobot_version}/tfgrid-sdk-go_Linux_x86_64.tar.gz" && \
23-
tar -xzf tfgrid-sdk-go_Linux_x86_64.tar.gz -C /usr/local/bin/
24-
2521
# Cleaning up
26-
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* tfgrid-sdk-go_Linux_x86_64.tar.gz
22+
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2723

2824
# Starting Command
2925
CMD ["/sbin/zinit", "init", "--container"]

tfgrid3/tfrobot/scripts/tfrobot.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Script to download the latest version of tfrobot if version was not passed as env variable
4+
5+
download_latest_tfrobot() {
6+
echo "No version provided, downloading the latest version..."
7+
tf_v=$(curl -s https://api.github.com/repos/threefoldtech/tfgrid-sdk-go/releases/latest | grep 'tag_name' | cut -d '"' -f 4)
8+
echo "Downloading latest version: $tf_v"
9+
wget -O "Latest.tar.gz" "https://github.com/threefoldtech/tfgrid-sdk-go/releases/download/${tf_v}/tfgrid-sdk-go_Linux_x86_64.tar.gz"
10+
tar -xzf Latest.tar.gz -C /usr/local/bin/
11+
rm -rf /Latest.tar.gz
12+
echo "tfrobot version ${tf_v} installed successfully."
13+
}
14+
15+
# Check if a version was provided as an argument
16+
if [ -z "$1" ]; then
17+
echo "No version argument provided."
18+
download_latest_tfrobot
19+
else
20+
tf_v=$1
21+
echo "Downloading specified version: ${tf_v}..."
22+
wget -O "tfrobot_version.tar.gz" "https://github.com/threefoldtech/tfgrid-sdk-go/releases/download/${tf_v}/tfgrid-sdk-go_Linux_x86_64.tar.gz"
23+
tar -xzf tfrobot_version.tar.gz -C /usr/local/bin/
24+
rm -rf /tfrobot_version.tar.gz
25+
echo "tfrobot version ${tf_v} installed successfully."
26+
fi

tfgrid3/tfrobot/zinit/ssh_config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ exec: /bin/sh -eux -c "
55
chmod 600 /etc/ssh/*;
66
touch ~/.ssh/authorized_keys;
77
chmod 600 ~/.ssh/authorized_keys;
8-
echo $SSH_KEY > /root/.ssh/authorized_keys;
98
echo 'ssh configred'"
10-
oneshot: true
9+
oneshot: true
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
exec: /bin/sh -eux -c "
2+
chmod +x /usr/local/bin/tfrobot.sh;
3+
if [ -z ${tfrobot_version:-} ]; then
4+
bash tfrobot.sh;
5+
else
6+
bash tfrobot.sh $tfrobot_version;
7+
fi"
8+
oneshot: true

0 commit comments

Comments
 (0)