Add some more helper scripts

Also, add some welcoming text when the user logs in over SSH.
This commit is contained in:
Benjamin Sago 2017-08-19 17:59:52 +01:00
parent 9e4ac8cae9
commit 1c2e34f649

55
Vagrantfile vendored
View File

@ -44,27 +44,56 @@ Vagrant.configure(2) do |config|
# By default it just uses the one in /vagrant/target, which can # By default it just uses the one in /vagrant/target, which can
# cause problems if it has different permissions than the other # cause problems if it has different permissions than the other
# directories, or contains object files compiled for the host. # directories, or contains object files compiled for the host.
config.vm.provision :shell, privileged: false, inline: <<-EOF config.vm.provision :shell, privileged: true, inline: <<-EOF
function put_line() { echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/#{developer}/.cargo/bin"' > /etc/environment
grep -q -F "$2" $1 || echo "$2" >> $1 echo 'CARGO_TARGET_DIR="/home/#{developer}/target"' >> /etc/environment
}
put_line ~/.bashrc 'export CARGO_TARGET_DIR=/home/#{developer}/target'
put_line ~/.bashrc 'export PATH=$PATH:/home/#{developer}/.cargo/bin'
EOF EOF
# Create "dexa" and "rexa" scripts that run the debug and release # Create a variety of misc scripts.
# compiled versions of exa.
config.vm.provision :shell, privileged: true, inline: <<-EOF config.vm.provision :shell, privileged: true, inline: <<-EOF
set -xe set -xe
echo -e "#!/bin/sh\n/home/#{developer}/target/debug/exa \"\\$*\"" > /usr/bin/exa echo -e "#!/bin/sh\n/home/#{developer}/target/debug/exa \"\\$*\"" > /usr/bin/exa
echo -e "#!/bin/sh\n/home/#{developer}/target/release/exa \"\\$*\"" > /usr/bin/rexa echo -e "#!/bin/sh\n/home/#{developer}/target/release/exa \"\\$*\"" > /usr/bin/rexa
echo -e "#!/bin/sh\ncargo build --manifest-path /vagrant/Cargo.toml" > /usr/bin/b
echo -e "#!/bin/sh\ncargo test --manifest-path /vagrant/Cargo.toml" > /usr/bin/t echo -e "#!/bin/sh\ncargo build --manifest-path /vagrant/Cargo.toml" > /usr/bin/build-exa
echo -e "#!/bin/sh\n/vagrant/xtests/run.sh" > /usr/bin/x ln -sf /usr/bin/build-exa /usr/bin/b
chmod +x /usr/bin/{exa,rexa,b,t,x}
echo -e "#!/bin/sh\ncargo test --manifest-path /vagrant/Cargo.toml" > /usr/bin/test-exa
ln -sf /usr/bin/test-exa /usr/bin/t
echo -e "#!/bin/sh\n/vagrant/xtests/run.sh" > /usr/bin/run-xtests
ln -sf /usr/bin/run-xtests /usr/bin/x
echo -e "#!/bin/sh\nbuild-exa && test-exa && run-xtests" > /usr/bin/compile-exa
ln -sf /usr/bin/compile-exa /usr/bin/c
chmod +x /usr/bin/{exa,rexa,b,t,x,c,build-exa,test-exa,run-xtests,compile-exa}
EOF
# Write some welcoming text.
config.vm.provision :shell, privileged: true, inline: <<-EOF
rm -f /etc/update-motd.d/*
echo -e "" > /etc/motd
echo -e "\033[1;33mThe exa development environment!\033[0m" >> /etc/motd
echo -e "" >> /etc/motd
echo -e "\033[4mCommands\033[0m" >> /etc/motd
echo -e "\033[32;1mb\033[0m or \033[32;1mbuild-exa\033[0m to run \033[1mcargo build\033[0m" >> /etc/motd
echo -e "\033[32;1mt\033[0m or \033[32;1mtest-exa\033[0m to run \033[1mcargo test\033[0m" >> /etc/motd
echo -e "\033[32;1mx\033[0m or \033[32;1mrun-xtests\033[0m to run \033[1m/vagrant/xtests/run.sh\033[0m" >> /etc/motd
echo -e "\033[32;1mc\033[0m or \033[32;1mcompile-exa\033[0m to run all three\n" >> /etc/motd
echo 'echo -e "\\033[4mVersions\\033[0m"' > /home/ubuntu/.bash_profile
echo "rustc --version" >> /home/ubuntu/.bash_profile
echo "cargo --version" >> /home/ubuntu/.bash_profile
echo "echo" >> /home/ubuntu/.bash_profile
# Disable last login date in sshd
sed -i '/PrintLastLog yes/c\PrintLastLog no' /etc/ssh/sshd_config
systemctl restart sshd
EOF EOF