github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/images/arm-qemu/initramfs/init (about)

     1  #!/bin/sh
     2  
     3  # Copyright 2020 The gVisor Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  # This script is started as the init process in a test virtual machine,
    18  # it does all required initialization steps and run a test command inside a
    19  # gVisor instance.
    20  
    21  set -x -e
    22  
    23  /bin/busybox mkdir -p /usr/bin /usr/sbin /proc /sys /dev /tmp
    24  
    25  /bin/busybox --install -s
    26  export PATH=/usr/bin:/bin:/usr/sbin:/sbin
    27  
    28  mount -t proc -o noexec,nosuid,nodev proc /proc
    29  mount -t sysfs -o noexec,nosuid,nodev sysfs /sys
    30  mount -t devtmpfs -o exec,nosuid,mode=0755,size=2M devtmpfs /dev
    31  
    32  uname -a
    33  /runsc --TESTONLY-unsafe-nonroot --rootless --network none --debug --alsologtostderr do uname -a
    34  echo "runsc exited with code $?"
    35  
    36  # Shutdown the VM. poweroff and halt doesn't work for unknown reasons.
    37  # qemu is started with the -no-reboot flag, so the VM will be terminated.
    38  reboot -f
    39  exit 1