-
Notifications
You must be signed in to change notification settings - Fork 8
/
growroot.sh
48 lines (46 loc) · 1.88 KB
/
growroot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
#
# Copyright 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# Install the package "cloud-init" and the "growroot" tool it includes. Upon
# reboot, it will automatically repartition the root volume to fill all
# available space.
echo "Installing growroot ..."
if which apt-get > /dev/null 2>&1 ; then
# Debian and derivatives.
if grep -i Ubuntu /etc/issue > /dev/null 2>&1 ; then
echo "This appears to be Ubuntu; this script should be necessary." >&2
echo "Please try booting Ubuntu with a large disk and check df(1) output." >&2
fi
echo "Using apt-get (Debian, etc.) ..."
apt-get -qq -y update
apt-get -qq -y install cloud-init cloud-initramfs-growroot
elif which yum > /dev/null 2>&1 ; then
# RHEL and CentOS.
echo "Using rpm/yum (RHEL, CentOS, etc.); WARNING: work-in-progress"
rpm -Uvh --quiet "https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm"
yum makecache
yum -q -y install cloud-init cloud-initramfs-tools dracut-modules-growroot
elif which zypper > /dev/null 2>&1 ; then
# SUSE and derivatives.
echo "Using zypper (SUSE, etc.); WARNING: work-in-progress"
zypper refresh
zypper --non-interactive --quiet install cloud-init cloud-utils
else
echo "Not a supported OS: none of {apt-get, yum, zypper} were found." >&2
exit 2
fi
echo "Done"