1
0
mirror of https://github.com/rancher/os.git synced 2025-09-16 06:59:12 +00:00

Optimize indentation format for shell scripts

This commit is contained in:
niusmallnan
2018-11-22 16:28:46 +08:00
parent b131ddeb7c
commit 50e72e629b
13 changed files with 117 additions and 117 deletions

View File

@@ -21,7 +21,7 @@ for i in $BASE/[0-9]*; do
if dapper -d --build -f ${i}/Dockerfile -- -t rancher/${name} ${i}; then if dapper -d --build -f ${i}/Dockerfile -- -t rancher/${name} ${i}; then
docker tag rancher/${name} ${tag} docker tag rancher/${name} ${tag}
echo "${tag}" >> dist/images echo "${tag}" >> dist/images
elif [ "$?" != "42" ]; then elif [ "$?" != "42" ]; then
exit 1 exit 1
else else

View File

@@ -15,12 +15,12 @@ DIST="../../../dist/artifacts"
command -v caddy >/dev/null 2>&1 || { echo >&2 "I require caddy but it's not installed, see https://github.com/mholt/caddy#quick-start . Aborting."; exit 1; } command -v caddy >/dev/null 2>&1 || { echo >&2 "I require caddy but it's not installed, see https://github.com/mholt/caddy#quick-start . Aborting."; exit 1; }
if [[ -e "dist/artifacts" ]]; then if [[ -e "dist/artifacts" ]]; then
cd scripts/hosting/digitalocean cd scripts/hosting/digitalocean
fi fi
if [[ ! -e "$DIST" ]]; then if [[ ! -e "$DIST" ]]; then
echo "Need to 'make release' so that there are files to serve. Aborting." echo "Need to 'make release' so that there are files to serve. Aborting."
exit 1 exit 1
fi fi
source ${DIST}/../../scripts/version source ${DIST}/../../scripts/version
@@ -35,10 +35,10 @@ SOURCECONFIG="fedora-symbiote.yml"
CLOUDCONFIG="digitalocean.sh" CLOUDCONFIG="digitalocean.sh"
cat ${SOURCECONFIG} \ cat ${SOURCECONFIG} \
| sed "s|^URL_BASE.*$|URL_BASE=http://${IP}:${PORT}|g" \ | sed "s|^URL_BASE.*$|URL_BASE=http://${IP}:${PORT}|g" \
| sed "s|^VMLINUX.*$|VMLINUX=${VMLINUX}|g" \ | sed "s|^VMLINUX.*$|VMLINUX=${VMLINUX}|g" \
| sed "s|^INITRD.*$|INITRD=${INITRD}|g" \ | sed "s|^INITRD.*$|INITRD=${INITRD}|g" \
> ${DIST}/${CLOUDCONFIG} > ${DIST}/${CLOUDCONFIG}
echo "Hosting a cloud-config script at http://${IP}:${PORT}/${CLOUDCONFIG}" echo "Hosting a cloud-config script at http://${IP}:${PORT}/${CLOUDCONFIG}"
echo "Usage:" echo "Usage:"

View File

@@ -15,29 +15,29 @@ append command [lrange $argv 4 end]
set timeout -1 set timeout -1
proc runcmd { username password cmd } { proc runcmd { username password cmd } {
send_user "<< username: $username" send_user "<< username: $username"
send_user "<< password: $password" send_user "<< password: $password"
send_user "<< cmd: $cmd" send_user "<< cmd: $cmd"
set done 0; set done 0;
while {$done == 0} { while {$done == 0} {
expect { expect {
"*?login:" { "*?login:" {
send -- "$username\r" send -- "$username\r"
} }
"*?assword:" { "*?assword:" {
send -- "$password\r" send -- "$password\r"
#send -- "\r" #send -- "\r"
} }
"*?:~#" { "*?:~#" {
send -- "$cmd\r" send -- "$cmd\r"
set done 1 set done 1
} }
"*?Reached target Shutdown." { "*?Reached target Shutdown." {
set done 1 set done 1
} }
} }
} }
} }
@@ -48,16 +48,16 @@ send -- "\r"
set running [ runcmd $username $password $command ] set running [ runcmd $username $password $command ]
expect { expect {
"*? (yes/no)?" { "*? (yes/no)?" {
send -- "no\r" send -- "no\r"
expect "# " expect "# "
} }
"# " { "# " {
} }
"*?Restarting system" { "*?Restarting system" {
} }
"*?kexec_core: Starting new kernel" { "*?kexec_core: Starting new kernel" {
} }
} }
send_user "<< DONE expect" send_user "<< DONE expect"

View File

@@ -8,12 +8,12 @@ set -ex
# https://github.com/packethost/docker-machine-driver-packet/releases # https://github.com/packethost/docker-machine-driver-packet/releases
if [ "${PACKET_API_KEY}" == "" ]; then if [ "${PACKET_API_KEY}" == "" ]; then
echo "need to set the PACKET_API_KEY" echo "need to set the PACKET_API_KEY"
exit exit
fi fi
if [ "${PACKET_PROJECT_ID}" == "" ]; then if [ "${PACKET_PROJECT_ID}" == "" ]; then
echo "need to set the PACKET_PROJECT_ID" echo "need to set the PACKET_PROJECT_ID"
exit exit
fi fi
# facilities # facilities
@@ -31,12 +31,12 @@ PLAN=baremetal_0
HOST=sven-${FACILITY}-${PLAN/_/-} HOST=sven-${FACILITY}-${PLAN/_/-}
if ! docker-machine inspect $HOST ; then if ! docker-machine inspect $HOST ; then
docker-machine create -d packet \ docker-machine create -d packet \
--packet-api-key=${PACKET_API_KEY} --packet-project-id=${PACKET_PROJECT_ID} \ --packet-api-key=${PACKET_API_KEY} --packet-project-id=${PACKET_PROJECT_ID} \
--packet-facility-code ${FACILITY} \ --packet-facility-code ${FACILITY} \
--packet-plan ${PLAN} \ --packet-plan ${PLAN} \
--packet-os=ubuntu_16_04 \ --packet-os=ubuntu_16_04 \
${HOST} ${HOST}
fi fi
SSH="docker-machine ssh $HOST" SSH="docker-machine ssh $HOST"
@@ -116,7 +116,7 @@ $SSHSOS sudo dd if=/dev/zero of=/dev/sda count=4 bs=1024
#If you're not running a type-0, also run the following command: #If you're not running a type-0, also run the following command:
if [ "$PLAN" != "baremetal_0" ]; then if [ "$PLAN" != "baremetal_0" ]; then
$SSHSOS sudo dd if=/dev/zero of=/dev/sdb count=4 bs=1024 $SSHSOS sudo dd if=/dev/zero of=/dev/sdb count=4 bs=1024
fi fi
#Both of these will hang after you run them. Just let them run for a second or two and then hit ctrl+c. #Both of these will hang after you run them. Just let them run for a second or two and then hit ctrl+c.

View File

@@ -16,7 +16,7 @@ do
c) CLOUD_CONFIG="$OPTARG" ;; c) CLOUD_CONFIG="$OPTARG" ;;
a) APPEND="$OPTARG" ;; a) APPEND="$OPTARG" ;;
g) MBR_FILE=gptmbr.bin ;; g) MBR_FILE=gptmbr.bin ;;
# upgrade! # upgrade!
r) ROLLBACK_VERSION="$OPTARG" ;; r) ROLLBACK_VERSION="$OPTARG" ;;
k) KEXEC=y ;; k) KEXEC=y ;;
# used for testing? # used for testing?

View File

@@ -6,7 +6,7 @@ set -x
DEVICE=${1} DEVICE=${1}
DISKTYPE=${2} DISKTYPE=${2}
if [[ -z $DISKTYPE ]]; then if [[ -z $DISKTYPE ]]; then
DISKTYPE="msdos" DISKTYPE="msdos"
fi fi
if [[ -z $DEVICE ]]; then if [[ -z $DEVICE ]]; then
@@ -18,14 +18,14 @@ PARTITION_COUNT=$(grep $(echo $DEVICE | cut -d '/' -f3) /proc/partitions | wc -l
if [ "$PARTITION_COUNT" -gt "1" ]; then if [ "$PARTITION_COUNT" -gt "1" ]; then
echo "Device ${DEVICE} already partitioned!" echo "Device ${DEVICE} already partitioned!"
echo "Checking to see if it is mounted" echo "Checking to see if it is mounted"
# Check this container first... # Check this container first...
if grep -q "${DEVICE}" /proc/mounts; then if grep -q "${DEVICE}" /proc/mounts; then
echo "Device is mounted, we can not repartition" 1>&2 echo "Device is mounted, we can not repartition" 1>&2
exit 1 exit 1
fi fi
# Check other system containers... # Check other system containers...
for container in $(system-docker ps -q); do for container in $(system-docker ps -q); do
if system-docker exec $container grep -q "${DEVICE}" /proc/mounts; then if system-docker exec $container grep -q "${DEVICE}" /proc/mounts; then
echo "Device is mounted in system container ${container}, we can not repartition" 1>&2 echo "Device is mounted in system container ${container}, we can not repartition" 1>&2

View File

@@ -15,7 +15,7 @@ if [ ! -e "../dist/artifacts/$INITRD" ]; then
fi fi
if [ "$RUNTEST" != "" ]; then if [ "$RUNTEST" != "" ]; then
RUNTEST="-check.f ${RUNTEST}" RUNTEST="-check.f ${RUNTEST}"
fi fi
time go test -v -timeout 9999m $RUNTEST time go test -v -timeout 9999m $RUNTEST

View File

@@ -39,7 +39,7 @@ if [ -e ${DOWNLOADS}/kernel.tar.gz ]; then
## and then package it up cpio ## and then package it up cpio
#cd ${BUILD}/kernel-fs/ #cd ${BUILD}/kernel-fs/
#echo Creating kernel ${ARTIFACTS}/linuxmods-${KERNEL_VERSION} #echo Creating kernel ${ARTIFACTS}/linuxmods-${KERNEL_VERSION}
#if [ "$COMPRESS" == "" ]; then #if [ "$COMPRESS" == "" ]; then
# COMPRESS="gzip -1" # COMPRESS="gzip -1"
#fi #fi
@@ -50,17 +50,17 @@ if [ -e ${DOWNLOADS}/kernel.tar.gz ]; then
#cp ${ARTIFACTS}/linuxmods-${KERNEL_VERSION} ${BUILD}/kernel/linuxmods #cp ${ARTIFACTS}/linuxmods-${KERNEL_VERSION} ${BUILD}/kernel/linuxmods
fi fi
else else
if [ "$ARCH" == "amd64" ]; then if [ "$ARCH" == "amd64" ]; then
echo "no ${DOWNLOADS}/kernel.tar.gz found" echo "no ${DOWNLOADS}/kernel.tar.gz found"
exit 1 exit 1
fi fi
fi fi
if [ "$ARCH" == "amd64" ]; then if [ "$ARCH" == "amd64" ]; then
ls -lah ${ARTIFACTS}/vmlinuz-* ls -lah ${ARTIFACTS}/vmlinuz-*
if [ ! -e "${ARTIFACTS}/vmlinuz-${KERNEL_VERSION}" ]; then if [ ! -e "${ARTIFACTS}/vmlinuz-${KERNEL_VERSION}" ]; then
echo "Can't find ${ARTIFACTS}/vmlinuz-${KERNEL_VERSION}" echo "Can't find ${ARTIFACTS}/vmlinuz-${KERNEL_VERSION}"
exit -1 exit -1
fi fi
fi fi

View File

@@ -4,10 +4,10 @@ set -e
cd $(dirname $0)/.. cd $(dirname $0)/..
if [ ! -e "./build/initrd/usr/share/ros/os-config.yml" ]; then if [ ! -e "./build/initrd/usr/share/ros/os-config.yml" ]; then
./.dapper release ./.dapper release
else else
echo "using existing build of ros" echo "using existing build of ros"
# ./.dapper build-target #./.dapper build-target
fi fi
source ./scripts/version source ./scripts/version
@@ -20,10 +20,10 @@ echo "cloud-init-save"
echo "---------------------------------" echo "---------------------------------"
docker run --rm -it \ docker run --rm -it \
-v $(pwd)/build/initrd/usr/share:/usr/share \ -v $(pwd)/build/initrd/usr/share:/usr/share \
-v $(pwd)/bin/ros:/usr/bin/ros \ -v $(pwd)/bin/ros:/usr/bin/ros \
-v /etc/ssl/certs:/etc/ssl/certs \ -v /etc/ssl/certs:/etc/ssl/certs \
-v /usr/share/ca-certificates:/usr/share/ca-certificates \ -v /usr/share/ca-certificates:/usr/share/ca-certificates \
-w /var/lib/rancher \ -w /var/lib/rancher \
--entrypoint sh \ --entrypoint sh \
rancher/os-base:v1.0.3 rancher/os-base:v1.0.3

View File

@@ -10,8 +10,8 @@ MEMORY=2048
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
case $1 in case $1 in
--debug) --debug)
DEBUG=1 DEBUG=1
;; ;;
--iso) --iso)
BOOT_ISO=1 BOOT_ISO=1
@@ -61,9 +61,9 @@ while [ "$#" -gt 0 ]; do
shift 1 shift 1
QEMU_APPEND="${QEMU_APPEND} $1" QEMU_APPEND="${QEMU_APPEND} $1"
;; ;;
--rsyslog) --rsyslog)
RSYSLOG=1 RSYSLOG=1
;; ;;
--append-init) --append-init)
shift 1 shift 1
APPEND_INIT="${APPEND_INIT} $1" APPEND_INIT="${APPEND_INIT} $1"
@@ -187,9 +187,9 @@ if [ "$BOOT_PXE" == "1" ]; then
return 0 return 0
fi fi
if [ "$RSYSLOG" == "1" ]; then if [ "$RSYSLOG" == "1" ]; then
defaultDev=$(ip route | grep default | cut -f 5 -d " ") defaultDev=$(ip route | grep default | cut -f 5 -d " ")
devIP=$(ip a show dev $defaultDev | grep "inet " | cut -d " " -f 6 | cut -d / -f 1) devIP=$(ip a show dev $defaultDev | grep "inet " | cut -d " " -f 6 | cut -d / -f 1)
KERNEL_ARGS="${KERNEL_ARGS} loglevel=8 netconsole=+9999@10.0.2.14/,514@${devIP}/" KERNEL_ARGS="${KERNEL_ARGS} loglevel=8 netconsole=+9999@10.0.2.14/,514@${devIP}/"
fi fi
# ELIDE_COMMANDLINE - MUST BE LAST # ELIDE_COMMANDLINE - MUST BE LAST
if [ "$APPEND_INIT" != "" ]; then if [ "$APPEND_INIT" != "" ]; then
@@ -287,16 +287,16 @@ if [ "$QIND" != "1" ]; then
fi fi
if [ "$GUICONSOLE" == "" ]; then if [ "$GUICONSOLE" == "" ]; then
# default serial console # default serial console
DISPLAY_OPTS="-nographic -serial mon:stdio -display none" DISPLAY_OPTS="-nographic -serial mon:stdio -display none"
if [ "$CONSOLEDISPLAY" == "1" ]; then if [ "$CONSOLEDISPLAY" == "1" ]; then
DISPLAY_OPTS="-curses" DISPLAY_OPTS="-curses"
fi fi
if [ "$NETCONSOLE" == "1" ]; then if [ "$NETCONSOLE" == "1" ]; then
# put ttyS1 on port 4444 # put ttyS1 on port 4444
DISPLAY_OPTS="${DISPLAY_OPTS} -serial tcp::4444,server" DISPLAY_OPTS="${DISPLAY_OPTS} -serial tcp::4444,server"
KERNEL_ARGS="rancher.console=ttyS1 rancher.autologin=ttyS1 ${KERNEL_ARGS}" KERNEL_ARGS="rancher.console=ttyS1 rancher.autologin=ttyS1 ${KERNEL_ARGS}"
fi fi
fi fi
if [ "${NO_NETWORK}" == "1" ]; then if [ "${NO_NETWORK}" == "1" ]; then

View File

@@ -49,7 +49,7 @@ QEMUARCH=${qemuarch["${ARCH}"]}
TTYCONS=${ttycons["${ARCH}"]} TTYCONS=${ttycons["${ARCH}"]}
if [ "$ENGINE_REGISTRY_MIRROR" != "" ]; then if [ "$ENGINE_REGISTRY_MIRROR" != "" ]; then
REGISTRY_MIRROR="rancher.bootstrap_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.system_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.docker.registry_mirror=${ENGINE_REGISTRY_MIRROR}" REGISTRY_MIRROR="rancher.bootstrap_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.system_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.docker.registry_mirror=${ENGINE_REGISTRY_MIRROR}"
fi fi
DEFAULT_KERNEL_ARGS="printk.devkmsg=on rancher.password=rancher console=tty1 rancher.autologin=tty1 console=${TTYCONS} rancher.autologin=${TTYCONS} ${REGISTRY_MIRROR} " DEFAULT_KERNEL_ARGS="printk.devkmsg=on rancher.password=rancher console=tty1 rancher.autologin=tty1 console=${TTYCONS} rancher.autologin=${TTYCONS} ${REGISTRY_MIRROR} "

View File

@@ -49,16 +49,16 @@ docker run --privileged -it --rm \
-v /dev/mapper:/dev/mapper \ -v /dev/mapper:/dev/mapper \
-v ${STATE}:/cluster \ -v ${STATE}:/cluster \
rancher/os:${VERSION} \ rancher/os:${VERSION} \
--isoinstallerloaded=1 \ --isoinstallerloaded=1 \
--force \ --force \
--no-reboot \ --no-reboot \
--debug \ --debug \
-c /cluster/cloud-config.yml \ -c /cluster/cloud-config.yml \
-t generic \ -t generic \
-d ${LOOPBACK} \ -d ${LOOPBACK} \
-p ${PARTITION} \ -p ${PARTITION} \
--append "rancher.autologin=tty1" --append "rancher.autologin=tty1"
#-f /cluster/images.tar.xz:var/lib/system-docker/preload/images.tar.xz #-f /cluster/images.tar.xz:var/lib/system-docker/preload/images.tar.xz
sync sync

View File

@@ -6,15 +6,15 @@ if [ "1" == "2" ]; then
linuxkit run -mem 2048 rancheros linuxkit run -mem 2048 rancheros
else else
qemu-system-x86_64 \ qemu-system-x86_64 \
-nographic \ -nographic \
-kernel ./rancheros-kernel \ -kernel ./rancheros-kernel \
-initrd ./rancheros-initrd.img \ -initrd ./rancheros-initrd.img \
-m 2048 \ -m 2048 \
-device virtio-rng-pci \ -device virtio-rng-pci \
-smp 1 \ -smp 1 \
-enable-kvm \ -enable-kvm \
-machine q35,accel=kvm:tcg \ -machine q35,accel=kvm:tcg \
-net nic,vlan=0,model=virtio \ -net nic,vlan=0,model=virtio \
-net user,vlan=0,hostfwd=tcp::3333-:22,hostname=rancher-moby \ -net user,vlan=0,hostfwd=tcp::3333-:22,hostname=rancher-moby \
-append 'printk.devkmsg=on rancher.debug=true rancher.password=rancher console=ttyS0 rancher.autologin=ttyS0 console=tty0 rancher.autologin=tty0 console=tty1 rancher.autologin=tty1 rancher.state.dev=LABEL=RANCHER_STATE rancher.state.autoformat=[/dev/sda,/dev/vda] rancher.rm_usr' -append 'printk.devkmsg=on rancher.debug=true rancher.password=rancher console=ttyS0 rancher.autologin=ttyS0 console=tty0 rancher.autologin=tty0 console=tty1 rancher.autologin=tty1 rancher.state.dev=LABEL=RANCHER_STATE rancher.state.autoformat=[/dev/sda,/dev/vda] rancher.rm_usr'
fi fi