1
0
mirror of https://github.com/containers/youki synced 2024-11-23 01:11:58 +01:00

add rootful mode for vagrant

This commit is contained in:
zido 2021-09-23 18:16:09 +08:00 committed by zidoshare
parent ae4b1974fe
commit 8e7294ce43
3 changed files with 64 additions and 1 deletions

@ -192,14 +192,20 @@ $ ./integration_test.sh linux_*
### Setting up Vagrant ### Setting up Vagrant
You can try youki on platforms other than linux by using the Vagrantfile we have prepared. You can try youki on platforms other than linux by using the Vagrantfile we have prepared. We have prepared two environments for vagrant, namely rootless mode and rootful mode
``` ```
$ git clone git@github.com:containers/youki.git $ git clone git@github.com:containers/youki.git
$ cd youki $ cd youki
# If you want to develop in rootless mode, and this is the default mode
$ vagrant up $ vagrant up
$ vagrant ssh $ vagrant ssh
# or if you want to develop in rootful mode
$ VAGRANT_VAGRANTFILE=Vagrantfile.root vagrant up
$ VAGRANT_VAGRANTFILE=Vagrantfile.root vagrant ssh
# in virtual machine # in virtual machine
$ cd youki $ cd youki
$ ./build.sh $ ./build.sh

26
Vagrantfile.root Normal file

@ -0,0 +1,26 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "fedora/33-cloud-base"
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.define "rootful"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
config.vm.provision "shell", path: "./hack/set_root_login_for_vagrant.sh"
config.vm.provision "shell", inline: <<-SHELL
set -e -u -o pipefail
yum update -y
yum install -y git gcc docker systemd-devel dbus-devel libseccomp-devel
grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"
service docker start
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "export PATH=$PATH:$HOME/.cargo/bin" >> ~/.bashrc
SHELL
config.ssh.username = 'root'
config.ssh.insert_key = 'true'
end

@ -0,0 +1,31 @@
#!/bin/bash
set -x
# change sshd config
file="$1"
param[1]="PermitRootLogin "
param[2]="PubkeyAuthentication"
param[3]="PasswordAuthentication"
if [ -z "${file}" ]
then
file="/etc/ssh/sshd_config"
fi
for PARAM in ${param[@]}
do
/usr/bin/sed -i '/^'"${PARAM}"'/d' ${file}
/usr/bin/echo "All lines beginning with '${PARAM}' were deleted from ${file}."
done
/usr/bin/echo "${param[1]} yes" >> ${file}
/usr/bin/echo "'${param[1]} yes' was added to ${file}."
/usr/bin/echo "${param[2]} yes" >> ${file}
/usr/bin/echo "'${param[2]} yes' was added to ${file}."
/usr/bin/echo "${param[3]} no" >> ${file}
/usr/bin/echo "'${param[3]} no' was added to ${file}"
# reload config
service sshd reload