-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup-as-remote.sh
More file actions
executable file
·49 lines (43 loc) · 1.52 KB
/
setup-as-remote.sh
File metadata and controls
executable file
·49 lines (43 loc) · 1.52 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
#!/bin/bash
#
# This script sets up the current server to listen as an LXD remote, which can
# be added to other LXD servers with "remote add ...". The point is that
# you can copy containers between servers then.
#
# It's recommended to copy snapshots (not running containers):
#
# $TOOL snapshot NAME-OF-LXD-CONTAINER
# $TOOL copy --mode push --stateless --instance-only NAME-OF-LXD-CONTAINER/snapshot-XXXXXX-X NAME-OF-REMOTE-LXD-SERVER:
#
# If you are brave you CAN copy instances, but your instance will be "FROZEN"
# by LXD while copying:
#
# $TOOL copy --mode push --stateless --instance-only NAME-OF-LXD-CONTAINER/snapshot-XXXXXX-X NAME-OF-REMOTE-LXD-SERVER:
# Strict mode
set -e
# Force location
cd "$(dirname "$0")" || exit
# Configuration
source .env
source detect.sh
# Incus requires a name for the trust
if [ $# -lt 1 ]; then
printf "\nUsage: $0 <name>\n\n"
exit 1
fi
NAME="$1"
# Open port that can be connected to
# You can disable later: $TOOL config set core.https_address ''
$TOOL config set core.https_address :8443
# Just for debug
printf "\nJust for reference, currently trusted clients:\n\n"
$TOOL config trust list
printf "\nCurrently outstanding (unused) tokens:\n\n"
$TOOL config trust list-tokens
# Generate a trust token
# NOTE: Will ask for a client name
printf "\nGenerating a new client token:\n\n"
$TOOL config trust add "$NAME"
printf "\nNow run this command on the other side, and supply the token generated (above):\n\n"
printf "$TOOL remote add --accept-certificate \"$DOMAIN\""
printf "\n\n"