Add feature for access to JuJu without root privileges

This commit is contained in:
Filippo Squillace 2014-10-20 02:01:45 +01:00
parent 55417bc0c4
commit 9a9c35a601
3 changed files with 88 additions and 27 deletions

View file

@ -5,35 +5,76 @@ JuJu
Description
-----------
**JuJu** is a small and portable GNU/Linux distribution based on ArchLinux.
It allows to have an isolated GNU/Linux environment inside the home directory
without the need to have root privileges that is accessible via chroot and run
on whatever Linux distribution.
JuJu can be used inside another GNU/Linx OS via chroot.
It only contains the package manager (called pacman and yaourt) in order to access
JuJu only contains the package manager (called pacman and yaourt) in order to access
to a wide range of packages from ArchLinux repositories.
The main advantage of using JuJu is because you have an isolated environment
in which you can install packages without affecting a production system.
Another advantage is that with JuJu you can access to a really wide range
of packages inside GNU/Linux systems that contains limited repositories
(such as CentOS and RedHat).
The main advantage of using JuJu are:
- It gives an isolated environment in which you can install packages without affecting a production system.
- Access to a really wide range of packages even inside GNU/Linux systems that contains limited repositories (such as CentOS and RedHat).
- Install packages without the need to be root.
Quickstart
----------
After installing JuJu (see next section) just run the main juju script:
```bash
juju
```
After installing JuJu (see next section) you can run juju either as root or as normal user.
To run as root:
# juju
To run as normal user:
$ juju -n
The first time you execute it, the script will download the JuJu image and place it
to the default directory ~/.juju.
You will need root privileges in order to acces to the chroot.
Installation
------------
Just clone JuJu somewhere (for example in ~/juju):
```bash
git clone git://github.com/fsquillace/juju ~/juju
export PATH=~/juju/bin:$PATH
```
$ git clone git://github.com/fsquillace/juju ~/juju
$ export PATH=~/juju/bin:$PATH
JuJu can only works on GNU/Linux OS with kernel version greater or equal
2.6.32 in 32 or 64 bit.
2.6.32 on 64 bit architecture (32 bit and arm will be available soon).
Advanced usage
--------------
You can build a new JuJu image from scratch by running the following command:
# juju -b
In this way the script will create a directory containing all the essentials
files to make JuJu working properly (such as pacman, yaourt, arch-chroot and proot).
Remember that the script to build the image must run in an ArchLinux OS with
arch-install-scripts installed.
To install the image named juju-x86\_64.tar.gz:
# juju -i juju-x86_64.tar.gz
License
-------
Copyright (c) 2012-2014
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/>.
## Author
Filippo Squillace <feel.squally@gmail.com>
## WWW
https://github.com/fsquillace/juju

View file

@ -32,6 +32,7 @@ usage() {
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"
@ -48,7 +49,7 @@ version() {
### MAIN PROGRAM ###
###################################
TEMP=`getopt -o bihv --long build-imagesetup-from-file,help,version -n 'juju' -- "$@"`
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
@ -56,12 +57,14 @@ if [ $? != 0 ] ; then error "Error on parsing the command line. Try juju -h." ;
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 ;;
@ -89,6 +92,8 @@ 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

View file

@ -33,7 +33,6 @@ source "$(dirname ${BASH_ARGV[0]})/util.sh"
################################# VARIABLES ##############################
[ -z ${JUJU_HOME} ] && JUJU_HOME=~/.juju
JUJU_REPO=https://bitbucket.org/fsquillace/juju-repo/raw/master
JUJU_BIN=$(dirname "$0")
ORIGIN_WD=$(pwd)
################################# MAIN FUNCTIONS ##############################
@ -82,10 +81,8 @@ function setup_from_file_juju(){
fi
local imagefile=$1
if [ ! -e ${imagefile} ]
then
die "Error: The JuJu image file ${imagefile} does not exist"
fi
[ ! -e ${imagefile} ] && die "Error: The JuJu image file ${imagefile} does not exist"
info "Installing JuJu from ${imagefile}..."
mkdir -p ${JUJU_HOME}
tar -zxpf ${ORIGIN_WD}/${imagefile} -C ${JUJU_HOME}
@ -99,6 +96,9 @@ function run_juju(){
${JUJU_HOME}/usr/bin/arch-chroot $JUJU_HOME
}
function run_no_root_juju(){
${JUJU_HOME}/usr/bin/proot -S ${JUJU_HOME}
}
function setup_and_run_juju(){
# Setup and run the JuJu environment
@ -109,6 +109,15 @@ function setup_and_run_juju(){
run_juju
}
function setup_and_run_no_root_juju(){
# Setup and run the JuJu environment
# The setup function will be executed only if the
# JuJu envinronment in $JUJU_HOME is not present.
[ ! "$(ls -A $JUJU_HOME)" ] && setup_juju
run_no_root_juju
}
function build_image_juju(){
# The function must runs on ArchLinux
# The dependencies are:
@ -119,21 +128,27 @@ function build_image_juju(){
mkdir -p ${maindir}/root
prepare_build_directory
info "Installing pacman and its dependencies..."
pacstrap -d ${maindir}/root pacman arch-install-scripts
pacstrap -d ${maindir}/root pacman arch-install-scripts binutils
info "Compiling and installing yaourt..."
mkdir -p ${maindir}/yaourt/{package-query,yaourt}
mkdir -p ${maindir}/packages/{package-query,yaourt,proot}
builtin cd ${maindir}/yaourt/package-query
builtin cd ${maindir}/packages/package-query
wget https://aur.archlinux.org/packages/pa/package-query/PKGBUILD
makepkg -sfc --asroot
pacman --noconfirm --root ${maindir}/root -U package-query*.pkg.tar.xz
builtin cd ${maindir}/yaourt/yaourt
builtin cd ${maindir}/packages/yaourt
wget https://aur.archlinux.org/packages/ya/yaourt/PKGBUILD
makepkg -sfc --asroot
pacman --noconfirm --root ${maindir}/root -U yaourt*.pkg.tar.xz
info "Compiling and installing proot..."
builtin cd ${maindir}/packages/proot
wget https://aur.archlinux.org/packages/pr/proot/PKGBUILD
makepkg -sfc --asroot
pacman --noconfirm --root ${maindir}/root -U proot*.pkg.tar.xz
rm ${maindir}/root/var/cache/pacman/pkg/*
builtin cd ${ORIGIN_WD}