Commit 281cbbd6 authored by Jakub Jirutka's avatar Jakub Jirutka

indent heredocs and replace echos with heredoc where appropriate

parent 07c02f67
......@@ -33,28 +33,29 @@ fi
UMOUNT_LIST=
usage() {
echo "$PROGRAM $VERSION"
echo "usage: $PROGRAM <subcommand> [options] [args]
Available subcommands:
commit (ci)
diff
exclude (ex, delete)
include (inc, add)
list (ls)
list-backup (lb)
migrate_include_exclude
package (pkg)
revert
status (stat, st)
Common options:
-h Show help for subcommand.
-q Quiet mode.
-v Verbose mode.
"
cat <<-__EOF__
$PROGRAM $VERSION"
usage: $PROGRAM <subcommand> [options] [args]
Available subcommands:
commit (ci)
diff
exclude (ex, delete)
include (inc, add)
list (ls)
list-backup (lb)
migrate_include_exclude
package (pkg)
revert
status (stat, st)
Common options:
-h Show help for subcommand.
-q Quiet mode.
-v Verbose mode.
__EOF__
exit 1
}
......@@ -219,17 +220,18 @@ unpack_apkovl() {
# lbu_include - add/remove files to include list
#
usage_include() {
echo "$PROGRAM $VERSION
Add filename(s) to include list ($sysconfdir/include)
usage: $PROGRAM include|inc|add [-rv] <file> ...
$PROGRAM include|inc|add [-v] -l
Options:
-l List contents of include list.
-r Remove specified file(s) from include list instead of adding.
-v Verbose mode.
"
cat <<-__EOF__
$PROGRAM $VERSION
Add filename(s) to include list ($sysconfdir/include)
usage: $PROGRAM include|inc|add [-rv] <file> ...
$PROGRAM include|inc|add [-v] -l
Options:
-l List contents of include list.
-r Remove specified file(s) from include list instead of adding.
-v Verbose mode.
__EOF__
exit 1
}
......@@ -261,23 +263,24 @@ show_include() {
# lbu_package - create a package
#
usage_package() {
echo "$PROGRAM $VERSION
Create backup package.
cat <<-__EOF__
$PROGRAM $VERSION
Create backup package.
usage: $PROGRAM package|pkg -v [<dirname>|<filename>]
usage: $PROGRAM package|pkg -v [<dirname>|<filename>]
Options:
-v Verbose mode.
Options:
-v Verbose mode.
If <dirname> is a directory, a package named <hostname>.apkovl.tar.gz will
be created in the specified directory.
If <dirname> is a directory, a package named <hostname>.apkovl.tar.gz will
be created in the specified directory.
If <filename> is specified, and is not a direcotry, a package with the
specified name willbe created.
If <filename> is specified, and is not a direcotry, a package with the
specified name willbe created.
If <dirname> nor <filename> is not specified, a package named
<hostname>.apkovl.tar.gz will be created in current work directory.
"
If <dirname> nor <filename> is not specified, a package named
<hostname>.apkovl.tar.gz will be created in current work directory.
__EOF__
exit 1
}
......@@ -371,11 +374,12 @@ cmd_package() {
# lbu list - list files that would go to archive
#
usage_list() {
echo "$PROGRAM $VERSION
Lists files that would go to tar package. Same as: 'lbu package -v /dev/null'
cat <<-__EOF__
$PROGRAM $VERSION
Lists files that would go to tar package. Same as: 'lbu package -v /dev/null'
usage: $PROGRAM list|ls
"
usage: $PROGRAM list|ls
__EOF__
exit 1
}
......@@ -388,31 +392,32 @@ cmd_list() {
# lbu_commit - commit config files to writeable media
#
usage_commit() {
echo "$PROGRAM $VERSION
Create a backup of config to writeable media.
cat <<-__EOF__
$PROGRAM $VERSION
Create a backup of config to writeable media.
usage: $PROGRAM commit|ci [-nv] [<media>]
usage: $PROGRAM commit|ci [-nv] [<media>]
Options:
-d Remove old apk overlay files.
-e Protect configuration with a password.
-n Don't commit, just show what would have been commited.
-p <password> Give encryption password on the command-line
-v Verbose mode.
Options:
-d Remove old apk overlay files.
-e Protect configuration with a password.
-n Don't commit, just show what would have been commited.
-p <password> Give encryption password on the command-line
-v Verbose mode.
The following values for <media> is supported: floppy usb
If <media> is not specified, the environment variable LBU_BACKUPDIR or
LBU_MEDIA will be used. If LBU_BACKUPDIR is set, nothing will be mounted.
The following values for <media> is supported: floppy usb
If <media> is not specified, the environment variable LBU_BACKUPDIR or
LBU_MEDIA will be used. If LBU_BACKUPDIR is set, nothing will be mounted.
Password protection will use $DEFAULT_CIPHER encryption. Other ciphers can be
used by setting the DEFAULT_CIPHER or ENCRYPTION environment variables.
For possible ciphers, try: openssl -v
Password protection will use $DEFAULT_CIPHER encryption. Other ciphers can be
used by setting the DEFAULT_CIPHER or ENCRYPTION environment variables.
For possible ciphers, try: openssl -v
The password used to encrypt the file, can either be specified with the -p
option or using the PASSWORD environment variable.
The password used to encrypt the file, can either be specified with the -p
option or using the PASSWORD environment variable.
The environment variables can also be set in $LBU_CONF
"
The environment variables can also be set in $LBU_CONF
__EOF__
exit 1
}
......@@ -505,17 +510,18 @@ cmd_commit() {
# lbu_exclude - add remove file(s) from exclude list
usage_exclude() {
echo "$PROGRAM $VERSION
Add filename(s) to exclude list ($sysconfdir/exclude)
usage: $PROGRAM exclude|ex|delete [-rv] <file> ...
$PROGRAM exclude|ex|delete [-v] -l
Options:
-l List contents of exclude list.
-r Remove specified file(s) from exclude list instead of adding.
-v Verbose mode.
"
cat <<-__EOF__
$PROGRAM $VERSION
Add filename(s) to exclude list ($sysconfdir/exclude)
usage: $PROGRAM exclude|ex|delete [-rv] <file> ...
$PROGRAM exclude|ex|delete [-v] -l
Options:
-l List contents of exclude list.
-r Remove specified file(s) from exclude list instead of adding.
-v Verbose mode.
__EOF__
exit 1
}
......@@ -546,13 +552,13 @@ show_exclude() {
#---------------------------------------------------------------------------
# lbu_listbackup - Show old commits
usage_listbackup() {
cat <<EOF
$PROGRAM $VERSION
Show old commits.
cat <<-__EOF__
$PROGRAM $VERSION
Show old commits.
usage: $PROGRAM list-backup [<media>]
usage: $PROGRAM list-backup [<media>]
EOF
__EOF__
exit 1
}
......@@ -570,15 +576,15 @@ cmd_listbackup() {
#---------------------------------------------------------------------------
# lbu_revert - revert to old config
usage_revert() {
cat <<EOF
$PROGRAM $VERSION
Revert to older commit.
cat <<-__EOF__
$PROGRAM $VERSION
Revert to older commit.
usage: $PROGRAM revert <REVISION> [<media>]
usage: $PROGRAM revert <REVISION> [<media>]
The revision should be one of the files listed by 'lbu list-backup'.
The revision should be one of the files listed by 'lbu list-backup'.
EOF
__EOF__
}
cmd_revert() {
......@@ -601,15 +607,16 @@ cmd_revert() {
#---------------------------------------------------------------------------
# lbu_status - check what files have been changed since last save
usage_status() {
echo "$PROGRAM $VERSION
Check what files have been changed since last commit.
cat <<-__EOF__
$PROGRAM $VERSION
Check what files have been changed since last commit.
usage: $PROGRAM status|st [-av]
usage: $PROGRAM status|st [-av]
Options:
-a Compare all files, not just since last commit.
-v Also show include and exclude lists.
"
Options:
-a Compare all files, not just since last commit.
-v Also show include and exclude lists.
__EOF__
exit 1
}
......@@ -663,11 +670,12 @@ cmd_status() {
#-----------------------------------------------------------
# lbu_diff - run a diff against last commit
usage_diff() {
echo "$PROGRAM $VERSION
Run a diff against last commit
cat <<-__EOF__
$PROGRAM $VERSION
Run a diff against last commit
usage: $PROGRAM diff [<media>]
"
usage: $PROGRAM diff [<media>]
__EOF__
exit 1
}
......
......@@ -62,22 +62,22 @@ if [ -f $PEMFILE ]; then
echo "$PEMFILE already exist."
else
mkdir -p $SSLDIR
cat >$SSLCNF <<EOF
[ req ]
default_bits = 1024
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no
[ req_dn ]
OU=HTTPS server
CN=$(hostname -f || hostname)
emailAddress=${EMAIL:-postmaster@example.com}
[ cert_type ]
nsCertType = server
EOF
cat >$SSLCNF <<-__EOF__
[ req ]
default_bits = 1024
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no
[ req_dn ]
OU=HTTPS server
CN=$(hostname -f || hostname)
emailAddress=${EMAIL:-postmaster@example.com}
[ cert_type ]
nsCertType = server
__EOF__
echo "Generating certificates for HTTPS..."
openssl genrsa 2048 > $KEYFILE
openssl req -new -x509 -nodes -sha1 -days 3650 -key $KEYFILE \
......@@ -87,15 +87,15 @@ EOF
mv $CRTFILE $PEMFILE
fi
cat >/etc/mini_httpd/mini_httpd.conf <<EOF
nochroot
dir=/var/www/localhost/htdocs
user=nobody
cgipat=cgi-bin**
certfile=$PEMFILE
port=443
ssl
EOF
cat >/etc/mini_httpd/mini_httpd.conf <<-__EOF__
nochroot
dir=/var/www/localhost/htdocs
user=nobody
cgipat=cgi-bin**
certfile=$PEMFILE
port=443
ssl
__EOF__
if [ -n "$address" ]; then
echo "host=$address" >> /etc/mini_httpd/mini_httpd.conf
fi
......
......@@ -21,18 +21,18 @@ is_qemu() {
}
usage() {
cat <<__EOF__
usage: setup-alpine [-ahq] [-c FILE | -f FILE]
Setup Alpine Linux
options:
-a Create Alpine Linux overlay file
-c Create answer file (do not install anything)
-f Answer file to use installation
-h Show this help
-q Quick mode. Ask fewer questions.
__EOF__
cat <<-__EOF__
usage: setup-alpine [-ahq] [-c FILE | -f FILE]
Setup Alpine Linux
options:
-a Create Alpine Linux overlay file
-c Create answer file (do not install anything)
-f Answer file to use installation
-h Show this help
-q Quick mode. Ask fewer questions.
__EOF__
exit 1
}
......@@ -63,51 +63,51 @@ fi
if [ "$CREATEANSWERFILE" != "" ]; then
touch "$CREATEANSWERFILE" || echo "Cannot touch file $CREATEANSWERFILE"
cat <<__EOF__ > "$CREATEANSWERFILE"
# Example answer file for setup-alpine script
# If you don't want to use a certain option, then comment it out
cat > "$CREATEANSWERFILE" <<-__EOF__
# Example answer file for setup-alpine script
# If you don't want to use a certain option, then comment it out
# Use US layout with US variant
KEYMAPOPTS="us us"
# Use US layout with US variant
KEYMAPOPTS="us us"
# Set hostname to alpine-test
HOSTNAMEOPTS="-n alpine-test"
# Set hostname to alpine-test
HOSTNAMEOPTS="-n alpine-test"
# Contents of /etc/network/interfaces
INTERFACESOPTS="auto lo
iface lo inet loopback
# Contents of /etc/network/interfaces
INTERFACESOPTS="auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
hostname alpine-test
"
auto eth0
iface eth0 inet dhcp
hostname alpine-test
"
# Search domain of example.com, Google public nameserver
DNSOPTS="-d example.com 8.8.8.8"
# Search domain of example.com, Google public nameserver
DNSOPTS="-d example.com 8.8.8.8"
# Set timezone to UTC
TIMEZONEOPTS="-z UTC"
# Set timezone to UTC
TIMEZONEOPTS="-z UTC"
# set http/ftp proxy
PROXYOPTS="http://webproxy:8080"
# set http/ftp proxy
PROXYOPTS="http://webproxy:8080"
# Add a random mirror
APKREPOSOPTS="-r"
# Add a random mirror
APKREPOSOPTS="-r"
# Install Openssh
SSHDOPTS="-c openssh"
# Install Openssh
SSHDOPTS="-c openssh"
# Use openntpd
NTPOPTS="-c openntpd"
# Use openntpd
NTPOPTS="-c openntpd"
# Use /dev/sda as a data disk
DISKOPTS="-m data /dev/sda"
# Use /dev/sda as a data disk
DISKOPTS="-m data /dev/sda"
# Setup in /media/sdb1
LBUOPTS="/media/sdb1"
APKCACHEOPTS="/media/sdb1/cache"
# Setup in /media/sdb1
LBUOPTS="/media/sdb1"
APKCACHEOPTS="/media/sdb1/cache"
__EOF__
__EOF__
echo "Answer file $CREATEANSWERFILE has been created. Please add or remove options as desired in that file"
exit 0
fi
......
......@@ -5,16 +5,16 @@ PREFIX=
. "$PREFIX/lib/libalpine.sh"
usage() {
cat <<__EOF__
usage: setup-apkcache [-h] [DIR]
cat <<-__EOF__
usage: setup-apkcache [-h] [DIR]
Setup apk caching.
Setup apk caching.
If DIR is not specified user will be asked for location.
If DIR is not specified user will be asked for location.
options:
-h Show this help
__EOF__
options:
-h Show this help
__EOF__
exit 1
}
......@@ -85,15 +85,15 @@ mount_fstype() {
}
apk_cache_help() {
cat <<__EOF__
cat <<-__EOF__
Packages installed from network can be cached locally to be available during
boot, before the network is started. Specifying a directory here will make apk
cache the packages locally in this directory.
Packages installed from network can be cached locally to be available during
boot, before the network is started. Specifying a directory here will make apk
cache the packages locally in this directory.
Enter 'none' if you do not want to cache packages from network.
Enter 'none' if you do not want to cache packages from network.
__EOF__
__EOF__
}
while getopts "h" opt; do
......
......@@ -15,10 +15,12 @@ get_hostname_from_url() {
}
prompt_setup_method() {
echo "r) Add random from the above list"
echo "f) Detect and add fastest mirror from above list"
echo "e) Edit "${ROOT}"etc/apk/repositores with text editor"
echo ""
cat <<-__EOF__
r) Add random from the above list
f) Detect and add fastest mirror from above list
e) Edit "${ROOT}"etc/apk/repositores with text editor
__EOF__
echo -n "Enter mirror number (1-$mirror_count) or URL to add (or r/f/e/done) [$1]: "
}
......@@ -143,16 +145,16 @@ edit_repositories() {
}
usage() {
cat <<__EOF__
usage: setup-apkrepos [-fhr] [REPO...]
cat <<-__EOF__
usage: setup-apkrepos [-fhr] [REPO...]
Setup apk repositories
Setup apk repositories
options:
-f Detect and add fastest mirror
-h Show this help
-r Add a random mirror and do not prompt
__EOF__
options:
-f Detect and add fastest mirror
-h Show this help
-r Add a random mirror and do not prompt
__EOF__
exit 1
}
......
......@@ -161,28 +161,28 @@ check_syslinux() {
}
usage() {
cat <<__EOF__
$prog $version
usage: $prog [-fhUusv] SOURCE [DEST]
$prog -c DIR
cat <<-__EOF__
$prog $version
usage: $prog [-fhUusv] SOURCE [DEST]
$prog -c DIR
Copy the contents of SOURCE to DEST and make DEST bootable.
Copy the contents of SOURCE to DEST and make DEST bootable.
SOURCE can be a directory or a ISO image. DEST can be a mounted directory
or a device. If DEST is ommitted /media/usb will be used.
SOURCE can be a directory or a ISO image. DEST can be a mounted directory
or a device. If DEST is ommitted /media/usb will be used.
Options:
-f Force overwrite existing files. Will overwrite syslinux.cfg if upgrade.
-h Show this help.
-k fix kernel and initrd name in syslinux.cfg if needed.
-U Replace current alpine_dev in syslinux.cfg with UUID if UUID found.
-u Upgrade mode. Keep existing syslinux.cfg and don't run syslinux.
-s Force run syslinux, even if upgrade mode.
-v Verbose mode. Display whats going on.
Options:
-f Force overwrite existing files. Will overwrite syslinux.cfg if upgrade.
-h Show this help.
-k fix kernel and initrd name in syslinux.cfg if needed.
-U Replace current alpine_dev in syslinux.cfg with UUID if UUID found.
-u Upgrade mode. Keep existing syslinux.cfg and don't run syslinux.
-s Force run syslinux, even if upgrade mode.
-v Verbose mode. Display whats going on.
-c Check syslinux.cfg in destination DIR. Use with -f to fix.
-c Check syslinux.cfg in destination DIR. Use with -f to fix.
__EOF__
__EOF__
exit 1
}
......
......@@ -311,11 +311,11 @@ install_mounted_root() {
echo -e "${SWAP_DEVICE}\tswap\tswap\tdefaults\t0 0" \
>> "$mnt"/etc/fstab
fi
cat >>"$mnt"/etc/fstab <<EOF
/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0
/dev/fd0 /media/floppy vfat noauto 0 0
/dev/usbdisk /media/usb vfat noauto 0 0
EOF
cat >>"$mnt"/etc/fstab <<-__EOF__
/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0
/dev/fd0 /media/floppy vfat noauto 0 0
/dev/usbdisk /media/usb vfat noauto 0 0
__EOF__
# remove the installed db in case its there so we force re-install
rm -f "$mnt"/var/lib/apk/installed "$mnt"/lib/apk/db/installed
echo "Installing system on $rootdev:"
......@@ -838,46 +838,46 @@ native_disk_install() {
}
diskselect_help() {
cat <<__EOF__
cat <<-__EOF__
The disk you select can be used for a traditional disk install or for a
data-only install.
The disk you select can be used for a traditional disk install or for a
data-only install.
The disk will be erased.
The disk will be erased.
Enter 'none' if you want to run diskless.
Enter 'none' if you want to run diskless.
__EOF__
__EOF__
}
diskmode_help() {
cat <<__EOF__
cat <<-__EOF__
You can select between 'sys', 'data', 'lvm', 'lvmsys' or 'lvmdata'.
You can select between 'sys', 'data', 'lvm', 'lvmsys' or 'lvmdata'.
sys:
This mode is a traditional disk install. The following partitions will be
created on the disk: /boot, / (filesystem root) and swap.
sys:
This mode is a traditional disk install. The following partitions will be
created on the disk: /boot, / (filesystem root) and swap.
This mode may be used for development boxes, desktops, virtual servers, etc.
This mode may be used for development boxes, desktops, virtual servers, etc.
data:
This mode uses your disk(s) for data storage, not for the operating system.
The system itself will run from tmpfs (RAM).
data:
This mode uses your disk(s) for data storage, not for the operating system.
The system itself will run from tmpfs (RAM).
Use this mode if you only want to use the disk(s) for a mailspool, databases,
logs, etc.
Use this mode if you only want to use the disk(s) for a mailspool, databases,
logs, etc.
lvm:
Enable logical volume manager and ask again for 'sys' or 'data'.
lvm:
Enable logical volume manager and ask again for 'sys' or 'data'.
lvmsys:
Same as 'sys' but use logical volume manager for partitioning.
lvmsys:
Same as 'sys' but use logical volume manager for partitioning.
lvmdata:
Same as 'data' but use logical volume manager for partitioning.
lvmdata:
Same as 'data' but use logical volume manager for partitioning.
__EOF__
__EOF__
}
# ask for a root or data disk
......@@ -910,37 +910,37 @@ ask_disk() {
}
usage() {
cat <<__EOF__
usage: setup-disk [-hLqrv] [-k kernelflavor] [-m MODE] [-o apkovl] [-s SWAPSIZE]
[MOUNTPOINT | DISKDEV...]
Install alpine on harddisk.
If MOUNTPOINT is specified, then do a traditional disk install with MOUNTPOINT
as root.
If DISKDEV is specified, then use the specified disk(s) without asking. If
multiple disks are specified then set them up in a RAID array. If there are
mode than 2 disks, then use raid level 5 instead of raid level 1.
options:
-h Show this help
-m Use disk for MODE without asking, where MODE is either 'data' or 'sys'
-o Restore system from given apkovl file
-k Use kernelflavor instead of $KERNEL_FLAVOR
-L Use LVM to manage partitions
-q Exit quietly if no disks are found
-r Enable software raid1 with single disk
-s Use SWAPSIZE MB instead of autodetecting swap size (Use 0 to disable swap)
-v Be more verbose about what is happening
If BOOTFS, ROOTFS, VARFS are specified, then format a partition with specified
filesystem. If not specified, the default filesystem is ext4.
Supported filesystems for
boot: ext2, ext3, ext4, btrfs
root: ext2, ext3, ext4, btrfs, xfs
var: ext2, ext3, ext4, btrfs, xfs
__EOF__
cat <<-__EOF__
usage: setup-disk [-hLqrv] [-k kernelflavor] [-m MODE] [-o apkovl] [-s SWAPSIZE]
[MOUNTPOINT | DISKDEV...]
Install alpine on harddisk.
If MOUNTPOINT is specified, then do a traditional disk install with MOUNTPOINT
as root.
If DISKDEV is specified, then use the specified disk(s) without asking. If
multiple disks are specified then set them up in a RAID array. If there are
mode than 2 disks, then use raid level 5 instead of raid level 1.
options:
-h Show this help
-m Use disk for MODE without asking, where MODE is either 'data' or 'sys'
-o Restore system from given apkovl file
-k Use kernelflavor instead of $KERNEL_FLAVOR
-L Use LVM to manage partitions
-q Exit quietly if no disks are found
-r Enable software raid1 with single disk
-s Use SWAPSIZE MB instead of autodetecting swap size (Use 0 to disable swap)
-v Be more verbose about what is happening
If BOOTFS, ROOTFS, VARFS are specified, then format a partition with specified
filesystem. If not specified, the default filesystem is ext4.
Supported filesystems for
boot: ext2, ext3, ext4, btrfs
root: ext2, ext3, ext4, btrfs, xfs
var: ext2, ext3, ext4, btrfs, xfs
__EOF__
exit 1
}
......
......@@ -4,17 +4,17 @@ PREFIX=
. "$PREFIX/lib/libalpine.sh"
usage() {
cat <<__EOF__
usage: setup-dns [-h] [-d domain name] [IPADDR...]
cat <<-__EOF__
usage: setup-dns [-h] [-d domain name] [IPADDR...]
Setup ${ROOT}etc/resolv.conf DNS settings