summaryrefslogtreecommitdiffstats
path: root/tools/centos-img-modify.sh
diff options
context:
space:
mode:
authorAlex Yang <yangyang1@zte.com.cn>2016-11-28 23:04:44 +0800
committerAlex Yang <yangyang1@zte.com.cn>2016-12-09 22:34:57 +0800
commit5d096ad50cd0314c728484ecb19ec48a51dbf0e5 (patch)
treee39add072f5234e17d6827686d9af2e3349982fd /tools/centos-img-modify.sh
parent53917cb499147b494fb488e945662535e01013a2 (diff)
download and modify centos image
Change-Id: I1934fb75d5d7f4a50f44c06080fbcec4f6c81f02 Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'tools/centos-img-modify.sh')
-rwxr-xr-xtools/centos-img-modify.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/tools/centos-img-modify.sh b/tools/centos-img-modify.sh
new file mode 100755
index 00000000..31f122fb
--- /dev/null
+++ b/tools/centos-img-modify.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+##############################################################################
+# Copyright (c) 2016 ZTE Coreporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+set -x
+
+echo "r00tme" | passwd --stdin root
+
+sed -i 's/^SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
+
+sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config
+sed -i 's/#UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config
+
+if [ -z $ipaddr ] || [ -z $gwaddr ]; then
+ cat << EOF > /etc/sysconfig/network-scripts/ifcfg-ens3
+DEVICE="ens3"
+BOOTPROTO="dhcp"
+ONBOOT="yes"
+TYPE="Ethernet"
+USERCTL="yes"
+PEERDNS="yes"
+IPV6INIT="no"
+PERSISTENT_DHCLIENT="1"
+EOF
+
+ cat << EOF > /etc/resolv.conf
+nameserver 8.8.8.8
+EOF
+
+else
+ cat << EOF > /etc/sysconfig/network-scripts/ifcfg-ens3
+DEVICE="ens3"
+NAME="ens3"
+BOOTPROTO="static"
+ONBOOT="yes"
+TYPE="Ethernet"
+IPADDR="${ipaddr}"
+NETMASK="255.255.255.0"
+GATEWAY="${gwaddr}"
+IPV6INIT="no"
+EOF
+
+ cat << EOF > /etc/resolv.conf
+nameserver ${gwaddr}
+nameserver 8.8.8.8
+EOF
+
+fi
+
+host_name=daisy
+echo ${host_name} > /etc/hostname
+sed -i "/^127.0.0.1/s/ localhost / ${host_name} localhost /g" /etc/hosts
+
+# Allow console access via pwd
+cat << EOF > /etc/cloud/cloud.cfg.d/default.cfg
+disable_root: False
+ssh_pwauth: True
+EOF