mirror of
https://github.com/fsquillace/junest.git
synced 2026-07-25 20:03:58 +00:00
119 lines
3.5 KiB
Bash
Executable file
119 lines
3.5 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 "-f, --fakeroot Run JuJu with fakeroot privileges"
|
|
echo -e "-r, --root Run JuJu with root privileges"
|
|
echo -e "-b, --build-image Build a JuJu image (must run in ArchLinux"
|
|
echo -e " with base-devel, package-query"
|
|
echo -e " and arch-install-scripts installed)"
|
|
echo -e "-d, --delete Delete JuJu from ${JUJU_HOME}"
|
|
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 drfbihv --long delete,root,fakeroot,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_FAKEROOT=false
|
|
OPT_ROOT=false
|
|
OPT_BUILD_IMAGE=false
|
|
OPT_DELETE=false
|
|
OPT_HELP=false
|
|
OPT_VERSION=false
|
|
while true ; do
|
|
case "$1" in
|
|
-i|--setup-from-file) OPT_SETUP_FROM_FILE=true ; shift ;;
|
|
-f|--fakeroot) OPT_FAKEROOT=true ; shift ;;
|
|
-r|--root) OPT_ROOT=true ; shift ;;
|
|
-b|--build-image) OPT_BUILD_IMAGE=true ; shift ;;
|
|
-d|--delete) OPT_DELETE=true ; shift ;;
|
|
-h|--help) OPT_HELP=true ; shift ;;
|
|
-v|--version) OPT_VERSION=true ; shift ;;
|
|
--) shift ; break ;;
|
|
*) error "Internal error!" ; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
ARGS=()
|
|
for arg do
|
|
ARGS+=($arg)
|
|
done
|
|
|
|
################ DEFINE ACTION ########################
|
|
|
|
$OPT_HELP && usage && exit
|
|
$OPT_VERSION && version && exit
|
|
|
|
if $OPT_BUILD_IMAGE; then
|
|
build_image_juju
|
|
exit
|
|
elif $OPT_DELETE; then
|
|
delete_juju
|
|
exit
|
|
fi
|
|
|
|
if ! is_juju_installed
|
|
then
|
|
if $OPT_SETUP_FROM_FILE; then
|
|
setup_from_file_juju ${ARGS[@]}
|
|
else
|
|
setup_juju
|
|
fi
|
|
fi
|
|
|
|
if $OPT_FAKEROOT; then
|
|
run_juju_as_fakeroot
|
|
elif $OPT_ROOT; then
|
|
run_juju_as_root
|
|
else
|
|
run_juju_as_user
|
|
fi
|
|
|
|
# vim: set ts=4 sw=4 noet:
|