mirror of
https://github.com/fsquillace/junest.git
synced 2026-07-23 19:17:36 +00:00
103 lines
3.2 KiB
Bash
Executable file
103 lines
3.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# This file is part of JuJu: The portable GNU/Linux distribution
|
|
#
|
|
# Copyright (c) 2012-2014 Filippo Squillace <feel.squally@gmail.com>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU Library General Public License as published
|
|
# by the Free Software Foundation; either version 2, or (at your option)
|
|
# any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
NAME='juju'
|
|
VERSION='1.0'
|
|
|
|
source "$(dirname $0)/../lib/core.sh"
|
|
|
|
###################################
|
|
### General functions ###
|
|
###################################
|
|
|
|
usage() {
|
|
echo -e "JuJu: The portable GNU/Linux distribution"
|
|
echo -e "Usage: $NAME [options]"
|
|
echo -e "Options:"
|
|
echo -e "-i, --setup-from-file <image> Setup the JuJu image in ${JUJU_HOME}"
|
|
echo -e "-n, --no-root Run JuJu without root privileges"
|
|
echo -e "-b, --build-image Build a JuJu image (must run in ArchLinux only)"
|
|
echo -e "-h, --help Show this help message"
|
|
echo -e "-v, --version Show the $NAME version"
|
|
}
|
|
|
|
version() {
|
|
echo -e "JuJu ($VERSION): The portable GNU/Linux distribution"
|
|
echo -e "Copyright (c) 2012-2014 Filippo Squillace <feel.squally@gmail.com>"
|
|
echo -e "Homepage: http://github.com/fsquillace/juju"
|
|
}
|
|
|
|
|
|
###################################
|
|
### MAIN PROGRAM ###
|
|
###################################
|
|
|
|
TEMP=`getopt -o nbihv --long no-root,build-image,setup-from-file,help,version -n 'juju' -- "$@"`
|
|
|
|
if [ $? != 0 ] ; then error "Error on parsing the command line. Try juju -h." ; exit ; fi
|
|
|
|
# Note the quotes around `$TEMP': they are essential!
|
|
eval set -- "$TEMP"
|
|
|
|
OPT_SETUP_FROM_FILE=false
|
|
OPT_NO_ROOT=false
|
|
OPT_BUILD_IMAGE=false
|
|
OPT_HELP=false
|
|
OPT_VERSION=false
|
|
while true ; do
|
|
case "$1" in
|
|
-i|--setup-from-file) OPT_SETUP_FROM_FILE=true ; shift ;;
|
|
-n|--no-root) OPT_NO_ROOT=true ; shift ;;
|
|
-b|--build-image) OPT_BUILD_IMAGE=true ; shift ;;
|
|
-h|--help) OPT_HELP=true ; shift ;;
|
|
-v|--version) OPT_VERSION=true ; shift ;;
|
|
--) shift ; break ;;
|
|
*) error "Internal error!" ; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
$OPT_HELP && usage && exit
|
|
$OPT_VERSION && version && exit
|
|
|
|
ARGS=()
|
|
for arg do
|
|
ARGS+=($arg)
|
|
done
|
|
|
|
############## CHECKING ESSENTIAL COMMANDS ####################
|
|
# Check if the essentials commands are installed (wget and tar)
|
|
if ! which wget &> /dev/null || ! which tar &> /dev/null
|
|
then
|
|
error "Error: wget and tar commands are essentials for JuJu. Get them first."
|
|
exit 1
|
|
fi
|
|
|
|
################ DEFINE ACTION ########################
|
|
if $OPT_SETUP_FROM_FILE; then
|
|
setup_from_file_juju ${ARGS[@]}
|
|
elif $OPT_NO_ROOT; then
|
|
setup_and_run_no_root_juju
|
|
elif $OPT_BUILD_IMAGE; then
|
|
build_image_juju
|
|
else
|
|
setup_and_run_juju
|
|
fi
|
|
|
|
# vim: set ts=4 sw=4 noet:
|