Browse code

Fix docker in cloud images

Change-Id: I5aff77da980b7f24f5fedd01f1a5feedd35c9eb6
Reviewed-on: http://photon-jenkins.eng.vmware.com/795
Reviewed-by: suezzelur <anishs@vmware.com>
Tested-by: suezzelur <anishs@vmware.com>

suezzelur authored on 2016/05/03 16:45:57
Showing 6 changed files
... ...
@@ -1,34 +1,24 @@
1 1
 #!/bin/bash
2 2
 
3
-
4 3
 cd /lib/systemd/system/multi-user.target.wants/
5 4
 
6 5
 ln -s ../docker.service docker.service
7
-ln -s ../eth0.service eth0.service
8
-
9 6
 cd /
10 7
 
11 8
 echo "127.0.0.1 localhost" >> /etc/hosts
12 9
 
13
-# Set UTC timezone
14
-# ln -sf /usr/share/zoneinfo/UTC /etc/localtime
15
-
16 10
 # Update /etc/resolv.conf
17
-
18 11
 rm /etc/resolv.conf
19
-
20 12
 echo "nameserver 172.31.0.2" >> /etc/resolv.conf
21 13
 echo "search ec2.internal" >> /etc/resolv.conf
22 14
 
23 15
 
24 16
 # Remove ssh host keys and add script to regenerate them at boot time.
25
-
26
-rm /etc/ssh/ssh_host_*
17
+rm -f /etc/ssh/ssh_host_*
27 18
 
28 19
 sudo groupadd docker
29 20
 sudo groupadd sudo
30 21
 
31
-
32 22
 rm /root/.ssh/authorized_keys   
33 23
 
34 24
 # ssh server config
... ...
@@ -5,15 +5,12 @@ cd /lib/systemd/system/multi-user.target.wants/
5 5
 # Create links in multi-user.target to auto-start these scripts and services.
6 6
 
7 7
 ln -s ../docker.service docker.service
8
-ln -s ../eth0.service eth0.service
9 8
 ln -s ../waagent.service waagent.service
10 9
 ln -s ../sshd-keygen.service sshd-keygen.service
11 10
 
12
-
13
-
14 11
 # Remove ssh host keys and add script to regenerate them at boot time.
15 12
 
16
-rm /etc/ssh/ssh_host_*
13
+rm -f /etc/ssh/ssh_host_*
17 14
 
18 15
 sudo groupadd docker
19 16
 sudo groupadd sudo
... ...
@@ -54,7 +51,6 @@ echo "ServerAliveInterval 180" >> /etc/ssh/ssh_config
54 54
 
55 55
 sed -i '/.*linux.*vmlinuz/ s/$/ console=ttyS0 earlyprintk=ttyS0 rootdelay=30/' /boot/grub/grub.cfg
56 56
 
57
-
58 57
 # Disable loading/unloading of modules
59 58
 echo 1 > /proc/sys/kernel/modules_disabled
60 59
 
... ...
@@ -72,6 +72,8 @@ echo "ROOT_PARTITION=/dev/mapper/${DEVICE_NAME}p2"
72 72
 rm -rf $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}
73 73
 mkdir $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}
74 74
 
75
+UUID_VALUE=$(blkid -s UUID -o value /dev/mapper/${DEVICE_NAME}p2)
76
+
75 77
 mkdir -p $ISO_MOUNT_FOLDER
76 78
 mount -o loop $PHOTON_ISO_PATH $ISO_MOUNT_FOLDER
77 79
 mount -v -t ext4 /dev/mapper/${DEVICE_NAME}p2 $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}
... ...
@@ -84,8 +86,7 @@ rm -f $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/etc/shadow-
84 84
 rm -f $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/etc/machine-id
85 85
 touch $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/etc/machine-id
86 86
 rm -f $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/etc/fstab
87
-echo "/dev/sda2    /    ext4    defaults,barrier,noatime,noacl,data=ordered 1 1" >> $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/etc/fstab
88
-
87
+echo "UUID=$UUID_VALUE    /    ext4    defaults,barrier,noatime,noacl,data=ordered 1 1" >> $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/etc/fstab
89 88
 mount -o bind /proc $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/proc
90 89
 mount -o bind /dev $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/dev
91 90
 mount -o bind /dev/pts $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/dev/pts
... ...
@@ -105,21 +106,15 @@ if [ $IMG_NAME != "ova" ] && [ $IMG_NAME != "ova_uefi" ] && [ $IMG_NAME != "ova_
105 105
     if [ $IMG_NAME = "gce" ]
106 106
       then
107 107
         cp ntpd.service $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/lib/systemd/system/
108
+        cp eth0.service $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/lib/systemd/system/
108 109
     fi
109 110
     if [ $IMG_NAME != "ova_generic" ]
110 111
       then
111
-        cp ntpd.service $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/lib/systemd/system/
112
-        cp eth0.service $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/lib/systemd/system/
113
-        cp -f docker.service $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/lib/systemd/system/
114
-        cp -f docker.socket $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/lib/systemd/system/
115 112
         if [ -e $IMG_NAME/cloud-photon.cfg ]
116 113
           then
117 114
             cp -f $IMG_NAME/cloud-photon.cfg $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/etc/cloud/cloud.cfg
118 115
         fi
119
-    
120 116
         cp $IMG_NAME/$IMG_NAME-patch.sh $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/
121
-
122
-
123 117
         cp /etc/resolv.conf $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME}/etc/
124 118
         echo "chrooting and running patch inside the chroot"
125 119
         chroot $PHOTON_IMG_OUTPUT_PATH/photon-${IMG_NAME} /bin/bash -c "/$IMG_NAME-patch.sh"
126 120
deleted file mode 100644
... ...
@@ -1,17 +0,0 @@
1
-[Unit]
2
-Description=Docker Daemon
3
-After=docker.socket  network.target
4
-Requires=docker.socket
5
-
6
-[Service]
7
-ExecStart=/bin/docker -d -s overlay -H fd://
8
-ExecReload=/bin/kill -HUP $MAINPID
9
-KillMode=process
10
-Restart=always
11
-MountFlags=slave
12
-LimitNOFILE=1048576
13
-LimitNPROC=1048576
14
-LimitCORE=infinity
15
-
16
-[Install]
17
-WantedBy=multi-user.target
18 1
\ No newline at end of file
19 2
deleted file mode 100644
... ...
@@ -1,12 +0,0 @@
1
-[Unit]
2
-Description=Docker Socket for the API
3
-PartOf=docker.service
4
-
5
-[Socket]
6
-SocketMode=0660
7
-SocketUser=root
8
-SocketGroup=docker
9
-ListenStream=/var/run/docker.sock
10
-
11
-[Install]
12
-WantedBy=sockets.target
13 1
\ No newline at end of file
... ...
@@ -32,7 +32,7 @@ echo "nameserver 8.8.8.8" >> /etc/resolv.conf
32 32
 
33 33
 # Remove ssh host keys and add script to regenerate them at boot time.
34 34
 
35
-rm /etc/ssh/ssh_host_*
35
+rm -f /etc/ssh/ssh_host_*
36 36
 
37 37
 printf "GOOGLE\n" > /etc/ssh/sshd_not_to_be_run
38 38