Skip to content

Commit

Permalink
Remove force option and clean up log file on success.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoylen committed Feb 20, 2018
1 parent 6442597 commit edc9051
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 52 deletions.
10 changes: 8 additions & 2 deletions q-gui-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,15 @@ if [ -z "$FORCE" ]; then
echo "$PROG: error: unsupported operating system: $OS (use --force?)"
exit 1
fi
ISSUE=`head -1 /etc/issue`

if [ -r '/etc/system-release' ]; then
ISSUE=`cat /etc/system-release`
else
ISSUE=`head -1 /etc/issue`
fi
if [ "$ISSUE" != 'CentOS release 6.4 (Final)' -a \
"$ISSUE" != 'Scientific Linux release 6.4 (Carbon)' ]; then
"$ISSUE" != 'CentOS release 6.9 (Final)' -a \
"$ISSUE" != 'Scientific Linux release 6.4 (Carbon)' ]; then
echo "$PROG: error: unsupported distribution: $ISSUE (use --force?)"
exit 1
fi
Expand Down
51 changes: 21 additions & 30 deletions q-storage-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Synopsis
q-storage-setup.sh
[ -a | --autofs] [ -m | --mount ] [ -u | --umount ]
[ -d | --dir dirname]
[ -f | --force yum|apt]
[ -v | --verbose ]
[ -V | --version ]
[ -h | --help ] allocSpec {allocSpec...}
Expand All @@ -18,7 +17,7 @@ Description
-----------

_Don't want to read all this (even though you really should)? Then jump
straight to the "Examples" section below._
to the "Examples" section below._

This script simplifies the task of setting up _autofs_, or directly
mounting/unmounting, QRISdata Collection Storage allocations.
Expand All @@ -38,27 +37,17 @@ of these options:

Other options are:

- `-d --dir name` sets the directory containing the mount point. The
directory must be an absolute directory (i.e. starting with a
slash). In the mount and unmount modes, the directory must already
exist; the default of `/mnt` is used if this option is not
specified. In the autofs mode, the default of `/data` is used if this
option is not specified.

- `-h | --help` shows help information.

- `-V | --version` shows the scripts version number.

- `-d --dir name` sets the directory containing the mount point. The
directory must be an absolute directory (i.e. starting with a
slash). Used in autofs, mount and unmount modes only. For mount and
unmount modes, the directory must already exist; the default of `/mnt`
is used if this option is not specified. For autofs mode, the default
of `/data` is used if this option is not specified.

- `-f | --force pkg` forces use of commands for the given package
manager type. This script has been tested with particular Linux
distributions that use the "apt" (e.g. Ubuntu and Debian), "dnf" or
"yum" package managers (e.g. CentOS and Fedora). It attempts to
automatically detect which package manager is being used. If the
automatic detection fails and/or you want to take the risk of running
it on an untested distribution, force it to use the commands for a
particular package manager by using this option with `apt`, `dnf` or
`yum` as the argument.

- `-v | --verbose` show extra information.

The `allocSpec` is a storage allocation Q-number or NFS path. A
Expand Down Expand Up @@ -199,17 +188,18 @@ Supported distributions
This script has been tested on the following distributions (as
installed from the NeCTAR official images):

- CentOS 6.7 x86_64
- Fedora 26 x86_64
- CentOS 7.0 x86_64
- Debian 8 x86_64 (Jessie)
- Fedora 22 x86_64
- Fedora 23 x86_64
- Scientific Linux 6.7 x86_64 (Carbon)
- Ubuntu 15.10 (Wily) amd64
- Ubuntu 16.04 (Xenial) amd64
- CentOS 6.7 x86_64 (Limitation: MTU is 1500 instead of 9000)
- Scientific Linux 6.8 x86_64 (Carbon) (Limitation: MTU is 1500 instead of 9000)

These currently (2018-02-20) do **not** work because of problems with
network configuration on the instances:

It should also work with NeCTAR images for previous versions of these
distributions too.
- Ubuntu 14.04 (Trusty) amd64 (Problem: No IPv4 address)
- Ubuntu 16.04 (Xenial) amd64 (Problem: No IPv4 address)
- Ubuntu 17.10 (Artful) amd64 (Problem: No IPv4 address)
- Debian 8 x86_64 (Jessie) (Problem: No IPv4 address)

Files
-----
Expand Down Expand Up @@ -322,7 +312,7 @@ This error occurs on the Fedora images.
Just re-run the script a second time, with the same parameters, and it
should work.

### warning: MTU for eth1 is not 9000 bytes
### warning: eth1: MTU != 9000

The Maximum Transmission Unit (MTU) for the network interface is not
set to 9000. This problem usually occurs on Fedora images, which
Expand Down Expand Up @@ -404,4 +394,5 @@ specify a different location.
Contact
-------

Please send feedback and queries to Hoylen Sue at <[email protected]>.
Please send feedback and queries to Hoylen Sue at <[email protected]>
or raise a ticket with [QRIScloud Support](https://www.qriscloud.org.au/support).
40 changes: 20 additions & 20 deletions q-storage-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,11 @@ DO_MOUNT=
DO_UMOUNT=
STAGE=
DIR=
FORCE=

## Define options: trailing colon means has an argument

SHORT_OPTS=hd:amufvV
LONG_OPTS=help,dir:,autofs,mount,umount,force,verbose,version
SHORT_OPTS=hd:amuvV
LONG_OPTS=help,dir:,autofs,mount,umount,verbose,version

ALLOC_SPEC_HELP="
allocSpec = the QRISdata Collection Storage allocation to mount/unmount.
Expand All @@ -145,7 +144,6 @@ Options:
-d name directory containing mount points
default for autofs: $DEFAULT_AUTO_MOUNT_DIR
default for mount or umount: $DEFAULT_ADHOC_MOUNT_DIR
-f pkg set package manager type (\"apt\", \"dnf\" or \"yum\" )
-v show extra information
-V show version
Expand Down Expand Up @@ -206,7 +204,6 @@ while [ $# -gt 0 ]; do
-m | --mount) DO_MOUNT=yes;;
-u | --umount) DO_UMOUNT=yes;;
-d | --dir) DIR="$2"; shift;;
-f | --force) FORCE=yes;;
-V | --version) echo "$PROG $VERSION"; exit 0;;
-v | --verbose) VERBOSE=yes;;

Expand Down Expand Up @@ -334,16 +331,12 @@ if [ -n "$ERROR" ]; then
fi

#----------------------------------------------------------------
# Check pre-conditions
# Check OS is supported

if [ -z "$FORCE" ]; then
# Check OS is supported

OS=`uname -s`
if [ "$OS" != 'Linux' ]; then
echo "$PROG: error: unsupported OS: $OS (use --force if you feel lucky)"
exit 1
fi
OS=`uname -s`
if [ "$OS" != 'Linux' ]; then
echo "$PROG: error: unsupported operating system: $OS" >&2
exit 1
fi

#----------------------------------------------------------------
Expand Down Expand Up @@ -579,7 +572,13 @@ fi
# Check MTU packet size

if ! ip link show dev eth1 | grep -q ' mtu 9000 '; then
echo "$PROG: warning: eth1: MTU != 9000 (please contact QRIScloud Support)" >&2
echo "$PROG: warning: eth1: MTU != 9000 (performace may be reduced)" >&2

# Change this to an error when setting the MTU actually works.
# Currently, it does not work on CentOS 6 because the broken DHCP value of 1500
# overrides the value in /etc/sysconfig/network-scripts/ifcfg-eth1.

# echo "$PROG: error: eth1: MTU != 9000 (please contact QRIScloud Support)" >&2
# exit 1
fi

Expand Down Expand Up @@ -743,6 +742,8 @@ if [ -n "$DO_UMOUNT" ]; then
if [ -n "$ERROR" ]; then
exit 1
fi

rm "$LOG"
exit 0 # done for this mode
fi

Expand Down Expand Up @@ -861,6 +862,7 @@ if [ -n "$DO_MOUNT" ]; then
exit 1
fi

rm "$LOG"
exit 0 # done for this mode
fi

Expand Down Expand Up @@ -942,13 +944,12 @@ if [ -n "$VERBOSE" ]; then
fi

if which systemctl >/dev/null 2>&1; then
# Systemd is used
# Systemd is used (e.g. CentOS 7)
systemctl enable autofs.service >>"$LOG" 2>&1
systemctl restart autofs.service >>"$LOG" 2>&1
else
# Init.d is used
# Init.d is used (e.g. CentOS 6)
service autofs restart >>"$LOG" 2>&1
echo "$PROG: warning: using init.d instead of systemd"
fi

#----------------------------------------------------------------
Expand Down Expand Up @@ -981,8 +982,7 @@ fi
#----------------------------------------------------------------
# Success

echo "$PROG: done" >>"$LOG"

rm "$LOG"
exit 0

#----------------------------------------------------------------
Expand Down

0 comments on commit edc9051

Please sign in to comment.