This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
Contrib: archiso profile for Kovri dev + testnet #808
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Creating a Kovri Development & Testnet ISO with Archiso | ||
|
||
Here are some instructions for creating a live usb for testing and/or developing Kovri. | ||
|
||
The live usb image is based on Arch linux and the Archiso toolset. | ||
|
||
## Prerequisites | ||
- Arch Linux system | ||
- archiso | ||
|
||
## Build instructions | ||
|
||
Detailed instructions for building and customizing the archiso profile is available on the [Arch | ||
wiki](https://wiki.archlinux.org/index.php/Archiso) | ||
|
||
The testnet ISO is based on the `releng` archiso profile, with customizations to install Kovri and it's dependencies. | ||
|
||
To build the ISO: | ||
``` | ||
$ cd /path/to/kovri/contrib/archiso | ||
# ./build.sh [-N your_iso_name] [-v] | ||
``` | ||
|
||
After running the above command, your ISO will be in `out/your_iso_name.iso`. | ||
|
||
# Rebuilding instructions | ||
|
||
If you built the ISO, and want to make further changes (installing packages, configuration, etc), then you can rebuild | ||
the ISO. | ||
|
||
You will need to remove pacman's lock files, and run `build.sh` again: | ||
``` | ||
cd /path/to/kovri/contrib/archiso | ||
rm -v work/build_* | ||
``` | ||
|
||
## Preparing the live media | ||
|
||
There are different setups required for a development or testnet ISO. | ||
|
||
### Development LiveUSB | ||
|
||
The development ISO is the easiest to prepare. | ||
|
||
#### WARNING: dd can overwrite your system drive, ensure you write to the proper drive | ||
|
||
Insert a USB and write the ISO: | ||
``` | ||
$ cd /path/to/kovri/contrib/archiso | ||
# dd if=out/your_iso_name.iso of=/dev/sdX bs=1M | ||
``` | ||
|
||
In the above command, `/dev/sdX` is the path to your USB, where `X` is the proper drive letter. | ||
|
||
### Testnet LiveUSB | ||
|
||
The first part of preparing the testnet USB is the same. | ||
|
||
#### WARNING: dd can overwrite your system drive, ensure you write to the proper drive | ||
|
||
Insert a USB and write the ISO: | ||
``` | ||
$ cd /path/to/kovri/contrib/archiso | ||
# dd if=out/your_iso_name.iso of=/dev/sdX bs=1M | ||
``` | ||
|
||
In the above command, `/dev/sdX` is the path to your USB, where `X` is the proper drive letter. | ||
|
||
Now you need to add a partition to the USB for the testnet Docker images: | ||
``` | ||
# fdisk /dev/sdX | ||
Command (m for help): n | ||
Command action | ||
p | ||
[enter] # select the default beginning sector for the new partition | ||
+2G # make a 2GiB paritition | ||
w # write your changes to the disk | ||
# mkfs.ext4 -O "^has_journal" /dev/sdXN # create filesystem, X = drive letter, N = partition number | ||
``` | ||
|
||
After creating the partition, you will need to mount it after booting the LiveUSB: | ||
``` | ||
press CTRL+ALT+F2 to open tty2 | ||
login as root (no password by default) | ||
# mkdir /tmp/docker | ||
# mount /dev/sdXN /tmp/docker # X = drive letter, N = partition number | ||
``` | ||
|
||
Docker needs to know about your new partition: | ||
``` | ||
# vim /etc/docker/daemon.json | ||
... | ||
"graph" : "/tmp/docker" | ||
... | ||
``` | ||
|
||
Changing the `graph` parameter tells Docker where to store images. | ||
|
||
Now start the daemon: | ||
``` | ||
# systemctl start docker | ||
``` | ||
|
||
You can now switch back to the `kovri` user in `tty1`, and create the testnet: | ||
``` | ||
press CTRL+ALT+F1 to open tty1 | ||
$ cd /tmp/kovri | ||
$ ./contrib/testnet/testnet.sh create | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
archiso |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LANG=en_US.UTF-8 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# Create testnet directory | ||
if [[ ! -L /tmp/kovri ]]; then | ||
ln -sf /usr/src/kovri /tmp/kovri | ||
fi |
26 changes: 26 additions & 0 deletions
26
contrib/archiso/airootfs/etc/systemd/scripts/choose-mirror
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
get_cmdline() { | ||
local param | ||
for param in $(< /proc/cmdline); do | ||
case "${param}" in | ||
$1=*) echo "${param##*=}"; | ||
return 0 | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
mirror=$(get_cmdline mirror) | ||
[[ $mirror = auto ]] && mirror=$(get_cmdline archiso_http_srv) | ||
[[ $mirror ]] || exit 0 | ||
|
||
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig | ||
cat >/etc/pacman.d/mirrorlist << EOF | ||
# | ||
# Arch Linux repository mirrorlist | ||
# Generated by archiso | ||
# | ||
Server = ${mirror%%/}/\$repo/os/\$arch | ||
EOF |
10 changes: 10 additions & 0 deletions
10
contrib/archiso/airootfs/etc/systemd/system/choose-mirror.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=Choose mirror from the kernel command line | ||
ConditionKernelCommandLine=mirror | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/etc/systemd/scripts/choose-mirror | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
8 changes: 8 additions & 0 deletions
8
contrib/archiso/airootfs/etc/systemd/system/etc-pacman.d-gnupg.mount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Unit] | ||
Description=Temporary /etc/pacman.d/gnupg directory | ||
|
||
[Mount] | ||
What=tmpfs | ||
Where=/etc/pacman.d/gnupg | ||
Type=tmpfs | ||
Options=mode=0755 |
3 changes: 3 additions & 0 deletions
3
contrib/archiso/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Service] | ||
ExecStart= | ||
ExecStart=-/sbin/agetty --autologin kovri --noclear %I 38400 linux |
15 changes: 15 additions & 0 deletions
15
contrib/archiso/airootfs/etc/systemd/system/pacman-init.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Initializes Pacman keyring | ||
Wants=haveged.service | ||
After=haveged.service | ||
Requires=etc-pacman.d-gnupg.mount | ||
After=etc-pacman.d-gnupg.mount | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/bin/pacman-key --init | ||
ExecStart=/usr/bin/pacman-key --populate archlinux | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
script_cmdline () | ||
{ | ||
local param | ||
for param in $(< /proc/cmdline); do | ||
case "${param}" in | ||
script=*) echo "${param#*=}" ; return 0 ;; | ||
esac | ||
done | ||
} | ||
|
||
automated_script () | ||
{ | ||
local script rt | ||
script="$(script_cmdline)" | ||
if [[ -n "${script}" && ! -x /tmp/startup_script ]]; then | ||
if [[ "${script}" =~ ^http:// || "${script}" =~ ^ftp:// ]]; then | ||
wget "${script}" --retry-connrefused -q -O /tmp/startup_script >/dev/null | ||
rt=$? | ||
else | ||
cp "${script}" /tmp/startup_script | ||
rt=$? | ||
fi | ||
if [[ ${rt} -eq 0 ]]; then | ||
chmod +x /tmp/startup_script | ||
/tmp/startup_script | ||
fi | ||
fi | ||
} | ||
|
||
if [[ $(tty) == "/dev/tty1" ]]; then | ||
automated_script | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
~/.automated_script.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
set -e -u | ||
|
||
sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen | ||
locale-gen | ||
|
||
ln -sf /usr/share/zoneinfo/UTC /etc/localtime | ||
|
||
usermod -s /usr/bin/zsh root | ||
cp -aT /etc/skel/ /root/ | ||
chmod 700 /root | ||
|
||
! id kovri && useradd -m -s /bin/bash -G docker kovri | ||
cp -aT /etc/skel/ /home/kovri | ||
chmod 700 /home/kovri | ||
|
||
sed -i 's/#\(PermitRootLogin \).\+/\1yes/' /etc/ssh/sshd_config | ||
sed -i "s/#Server/Server/g" /etc/pacman.d/mirrorlist | ||
sed -i 's/#\(Storage=\)auto/\1volatile/' /etc/systemd/journald.conf | ||
|
||
sed -i 's/#\(HandleSuspendKey=\)suspend/\1ignore/' /etc/systemd/logind.conf | ||
sed -i 's/#\(HandleHibernateKey=\)hibernate/\1ignore/' /etc/systemd/logind.conf | ||
sed -i 's/#\(HandleLidSwitch=\)suspend/\1ignore/' /etc/systemd/logind.conf | ||
|
||
systemctl enable pacman-init.service choose-mirror.service | ||
systemctl set-default multi-user.target | ||
systemctl poweroff -i | ||
|
||
# Clone latest Kovri repo if it doesn't exist | ||
if [[ ! -d /usr/src/kovri ]]; then | ||
git clone --recursive https://github.com/monero-project/kovri.git /usr/src/kovri | ||
fi | ||
|
||
# Build and install Kovri | ||
cd /usr/src/kovri && KOVRI_DATA_PATH=/home/kovri/.kovri make -j$(nproc) release && make install | ||
chown -R kovri:kovri /home/kovri | ||
ln -sf /usr/src/kovri/build/{kovri,kovri-util} /usr/bin | ||
|
||
## # Clone latest Monero repo if it doesn't exist | ||
## if [[ ! -d /usr/src/monero ]]; then | ||
## git clone https://github.com/monero-project/monero.git /usr/src/monero | ||
## fi | ||
## | ||
## # Build and install Monero | ||
## cd /usr/src/monero && make -j$(nproc) release-static-linux-x86_64 | ||
## ln -sf /usr/src/monero/build/release/bin/* /usr/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
View this installation guide online at | ||
https://wiki.archlinux.org/index.php/Installation_Guide | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make install
installs into~/bin/
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that. Leftover from previous iterations.