Skip to content

Commit

Permalink
Merge pull request #6197 from hexagonrecursion/expect
Browse files Browse the repository at this point in the history
Automate asciinema screencasts
  • Loading branch information
ThomasWaldmann authored Jul 6, 2022
2 parents dff33f6 + 45b3f64 commit 2418795
Show file tree
Hide file tree
Showing 9 changed files with 7,720 additions and 13,960 deletions.
4 changes: 4 additions & 0 deletions docs/misc/asciinema/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Do NOT run the examples without isolation (e.g Vagrant) or
this code may make undesirable changes to your host.

Running `vagrant up` in this directory will update the screencasts.
75 changes: 75 additions & 0 deletions docs/misc/asciinema/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Vagrant.configure("2") do |config|
config.vm.box = "debian/bullseye64"
config.vm.provision "install dependencies", type: "shell", inline: <<-SHELL
apt-get update
apt-get install -y wget expect gpg asciinema ssh adduser fuse
mkdir -p /wallpaper
wget \
--user-agent="borgbackup demo screencast" \
--input-file=/vagrant/sample-wallpapers.txt \
--directory-prefix=/wallpaper
SHELL
config.vm.provision "record install", type: "shell", inline: <<-SHELL
gpg --recv-keys "6D5B EF9A DD20 7580 5747 B70F 9F88 FB52 FAF7 B393"
asciinema rec -c 'expect /vagrant/install.tcl' --overwrite /vagrant/install.json < /dev/null
SHELL
config.vm.provision "record basic usage", type: "shell", inline: <<-SHELL
# `rm` below allows quick re-exec via:
# vagrant vagrant provision --provision-with "record basic usage"
# this is useful when testing changes
rm -r /media/backup/borgdemo || true
rm -r ~/.ssh/ || true
rm -r Wallpaper || true
deluser --remove-home borgdemo || true
# In case we have skipped "record install"
if [ ! -e /usr/local/bin/borg ] ; then
wget https://github.com/borgbackup/borg/releases/download/1.2.1/borg-linux64
install --owner root --group root --mode 755 borg-linux64 /usr/local/bin/borg
fi
mkdir -p /media/backup/borgdemo
mkdir Wallpaper
cp -r /wallpaper Wallpaper/bigcollection
cp /wallpaper/Trapper_cabin.jpg Wallpaper/deer.jpg
adduser --disabled-password borgdemo
echo '127.0.0.1 remoteserver.example' >> /etc/hosts
ssh-keygen -f ~/.ssh/id_rsa -N ''
ssh-keyscan remoteserver.example > ~/.ssh/known_hosts
runuser -u borgdemo mkdir ~borgdemo/.ssh
runuser -u borgdemo tee ~borgdemo/.ssh/authorized_keys < ~/.ssh/id_rsa.pub
asciinema rec -c 'expect /vagrant/basic.tcl' --overwrite /vagrant/basic.json < /dev/null
SHELL
config.vm.provision "record advanced usage", type: "shell", inline: <<-SHELL
rm -r /media/backup/borgdemo || true
rm -r Wallpaper || true
# In case we have skipped "record install"
if [ ! -e /usr/local/bin/borg ] ; then
wget https://github.com/borgbackup/borg/releases/download/1.2.1/borg-linux64
install --owner root --group root --mode 755 borg-linux64 /usr/local/bin/borg
fi
mkdir -p /media/backup/borgdemo
mkdir Wallpaper
cp -r /wallpaper Wallpaper/bigcollection
cp /wallpaper/Trapper_cabin.jpg Wallpaper/deer.jpg
mkdir -p ~/Downloads/big
dd if=/dev/zero of=loopbackfile.img bs=100M count=4
losetup /dev/loop0 loopbackfile.img
# Make it look as if the adv. usage screencast was recorded after basic usage
export BORG_PASSPHRASE='1234'
borg init --encryption=repokey /media/backup/borgdemo
borg create --compression lz4 /media/backup/borgdemo::backup1 Wallpaper
echo "new nice file" > Wallpaper/newfile.txt
borg create --compression lz4 /media/backup/borgdemo::backup2 Wallpaper
mv Wallpaper/bigcollection Wallpaper/bigcollection_NEW
borg create --compression lz4 /media/backup/borgdemo::backup3 Wallpaper
unset BORG_PASSPHRASE
asciinema rec -c 'expect /vagrant/advanced.tcl' --overwrite /vagrant/advanced.json < /dev/null
SHELL
end
Loading

0 comments on commit 2418795

Please sign in to comment.