Initial commit.
This commit is contained in:
67
Dockerfile.sh
Executable file
67
Dockerfile.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
cntName=osx-builder
|
||||
docker create --name $cntName --entrypoint tail --privileged -v /dev/kvm:/dev/kvm git.ivasoft.cz/sw/osx:base -f /dev/null
|
||||
docker start $cntName
|
||||
cat <<"EOF" | docker exec --interactive $cntName bash
|
||||
set -eux
|
||||
sudo pacman -Sy gnu-netcat sshpass --noconfirm
|
||||
sed -i -r 's:^.*\-audiodev .*$:-display none \\:' /home/arch/OSX-KVM/Launch-nopicker.sh
|
||||
sed -i -r 's:^(.*)\-device ide\-hd.*,drive=MacHDD.*$:\1\-device nvme,drive=MacHDD,serial=nvme-1 \\:' /home/arch/OSX-KVM/Launch-nopicker.sh
|
||||
sed -i -r 's:^(.*)\-monitor .*$:\1\-monitor telnet\:\:55773,server,nowait \\:' /home/arch/OSX-KVM/Launch-nopicker.sh
|
||||
# Enable VNC during the build as we will need to manually authenticate into the Mac App Store
|
||||
export EXTRA="-vnc 0.0.0.0:99,password=off"
|
||||
((/home/arch/OSX-KVM/Launch-nopicker.sh)&)
|
||||
# Enable password-less connection to the VM
|
||||
/usr/bin/ssh-keygen -t rsa -f ~/.ssh/id_docker_osx -q -N ""
|
||||
chmod 600 ~/.ssh/id_docker_osx
|
||||
until [[ "$(sshpass -p${PASSWORD} ssh-copy-id -o "StrictHostKeyChecking no" -f -i ~/.ssh/id_docker_osx.pub -p 10022 ${USERNAME}@127.0.0.1)" ]]; do
|
||||
echo "Waiting for the VM to start up..."
|
||||
sleep 15
|
||||
done
|
||||
tee -a ~/.ssh/config <<< 'Host 127.0.0.1'
|
||||
tee -a ~/.ssh/config <<< " User ${USERNAME}"
|
||||
tee -a ~/.ssh/config <<< ' Port 10022'
|
||||
tee -a ~/.ssh/config <<< ' IdentityFile ~/.ssh/id_docker_osx'
|
||||
tee -a ~/.ssh/config <<< ' StrictHostKeyChecking no'
|
||||
# Enable password-less sudo
|
||||
echo -e "${PASSWORD}\nmac ALL=(ALL) NOPASSWD: ALL"|ssh 127.0.0.1 'sudo -S tee "/etc/sudoers.d/mac"'
|
||||
# Change uid
|
||||
echo -e "chown -Rh 1000 /Users/mac\ndscl . -change /Users/mac UniqueID 501 1000"|ssh 127.0.0.1 sudo bash
|
||||
## Instal homebrew and software
|
||||
echo Installing Homebrew ...
|
||||
ssh 127.0.0.1 '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
|
||||
# (gmp is a hack for ruby)
|
||||
echo Installing packages ...
|
||||
ssh 127.0.0.1 'brew install node@20 libyaml gmp mas'
|
||||
# Create base directories for act and drone
|
||||
ssh 127.0.0.1 mkdir /Users/mac/drone
|
||||
echo -e "drone\tUsers/mac/drone" | ssh 127.0.0.1 'sudo tee "/etc/synthetic.conf"'
|
||||
# Redirect all commands to VM
|
||||
echo Redirecting executables
|
||||
sed -i -r 's:^\#\!/bin/bash$:\#\!/usr.orig/bin/bash:' /home/arch/OSX-KVM/Launch-nopicker.sh
|
||||
sudo rm /bin /sbin
|
||||
# ... all executables will stop working in the container after this command
|
||||
sudo mv /usr /usr.orig
|
||||
EOF
|
||||
|
||||
docker cp run.sh ${cntName}:/home/arch/OSX-KVM/
|
||||
rm -rf /tmp/links_
|
||||
mkdir /tmp/links_
|
||||
cd /tmp/links_
|
||||
ln -s usr.orig/lib lib && docker cp lib ${cntName}:/
|
||||
ln -s usr.orig/lib lib64 && docker cp lib64 ${cntName}:/
|
||||
mkdir -p usr/bin && mkdir -p usr/local/bin && chmod -R 755 usr && ln -s /usr.orig/lib usr/lib && docker cp usr ${cntName}:/
|
||||
mkdir bin && chmod 755 bin && docker cp bin ${cntName}:/
|
||||
ln -s /home/arch/OSX-KVM/run.sh bash && docker cp bash ${cntName}:/bin/
|
||||
ln -s /home/arch/OSX-KVM/run.sh uname && docker cp uname ${cntName}:/usr/bin/
|
||||
ln -s /home/arch/OSX-KVM/run.sh node && docker cp node ${cntName}:/usr/local/bin/
|
||||
ln -s /home/arch/OSX-KVM/run.sh brew && docker cp brew ${cntName}:/usr/local/bin/
|
||||
cd /tmp
|
||||
rm -rf /tmp/links_
|
||||
|
||||
echo Please connect using VNC to port :5999 and log into the Mac App Store manually
|
||||
read -p "Press any key to when done.. " -n1 -s
|
||||
|
||||
## Install apps from Mac App Store (497799835 - Xcode)
|
||||
echo Installing apps from Mac App Store
|
||||
docker exec -i $cntName /usr.orig/bin/ssh 127.0.0.1 'mas install 497799835'
|
||||
Reference in New Issue
Block a user