Skip to content

Commit a9256fd

Browse files
committed
Improved behavior of the script with git repositories.
1 parent 1b2a5ad commit a9256fd

File tree

2 files changed

+122
-37
lines changed

2 files changed

+122
-37
lines changed

Diff for: README.md

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ $ bash -x teambox-installer.sh > teambox-installer.log
4343

4444
This will give you a preview of all the commands that were executed while the script is running.
4545

46+
### Command line arguments
47+
48+
- `--keep`: Preserves the build directory in /tmp.
49+
- `--use-head`: Use the tip of all the repositories instead of a specific release tag.
50+
- `--fdg`: Fetch the Teambox repositories from http://github.com/fdgonthier instead of http://github.com/tmbx. The repositories by yours truly might be more current than those merged in the tmbx group, but it comes at the cost of stabilitiy.
51+
4652
## Ubuntu
4753

4854
Ubuntu is not the preferred distribution of Teambox but, starting Ubuntu 12.04, it is similar enough to Debian Wheezy to require no special handling in the script. Teambox should work as well on Ubuntu as on Debian.

Diff for: teambox-installer.sh

+116-37
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ ORG_NAME=teambox.co
2020
KEY_ID=99999999
2121

2222
# GIT repository configuration
23-
GIT_TBXSOSD=https://github.com/fdgonthier/tbxsosd.git
24-
GIT_KAS=https://github.com/fdgonthier/kas.git
25-
GIT_TEAMBOX_CORE=https://github.com/fdgonthier/teambox-core.git
26-
GIT_KMOD=https://github.com/fdgonthier/kmod.git
27-
GIT_TAG=R1
23+
GIT_DEFAULT_TAG=R2
2824

2925
##
3026
##
@@ -450,14 +446,28 @@ debian_install_packages() {
450446
#
451447

452448
core_build() {
449+
local GIT_TEAMBOX_CORE
450+
451+
if [ $opt_fdg = 1 ]; then
452+
GIT_TEAMBOX_CORE=https://github.com/fdgonthier/teambox-core.git
453+
else
454+
GIT_TEAMBOX_CORE=https://github.com/tmbx/teambox-core.git
455+
fi
456+
453457
if [ ! -d $BUILD_DIR/teambox-core/.git ]; then
454458
(cd $BUILD_DIR && git clone $GIT_TEAMBOX_CORE)
455459
[ $? -eq 0 ] || return 1
456-
#cd $BUILD_DIR/teambox-core && git checkout $GIT_TAG
457-
#[ $? -eq 0 ] || return 1
460+
if [ $opt_usehead = 0 ]; then
461+
git --git-dir=$BUILD_DIR/teambox-core checkout $opt_gittag
462+
[ $? -eq 0 ] || return 1
463+
fi
458464
else
459-
(cd $BUILD_DIR/teambox-core && git pull)
460-
[ $? -eq 0 ] || return 1
465+
if [ $opt_usehead = 1 ]; then
466+
git --git-dir=$BUILD_DIR/teambox-core checkout master
467+
[ $? -eq 0 ] || return 1
468+
git --git-dir=$BUILD_DIR/teambox-core pull
469+
[ $? -eq 0 ] || return 1
470+
fi
461471
fi
462472
(cd $BUILD_DIR/teambox-core &&
463473
scons --quiet --config=force \
@@ -482,18 +492,32 @@ core_install() {
482492
}
483493

484494
tbxsosd_build() {
495+
local GIT_TBXSOSD
496+
485497
mkdir -p $TEAMBOX_HOME/etc/tbxsosd
486498
[ $? -eq 0 ] || return 1
487499

500+
if [ $opt_fdg = 1 ]; then
501+
GIT_TBXSOSD=https://github.com/fdgonthier/tbxsosd.git
502+
else
503+
GIT_TBXSOSD=https://github.com/tmbx/tbxsosd.git
504+
fi
505+
488506
# Programs
489507
if [ ! -d $BUILD_DIR/tbxsosd/.git ]; then
490508
(cd $BUILD_DIR && git clone $GIT_TBXSOSD)
491509
[ $? -eq 0 ] || return 1
492-
#cd $BUILD_DIR/tbxsosd && git tag $GIT_TAG
493-
#[ $? -eq 0 ] || return 1
510+
if [ $opt_usehead = 0 ]; then
511+
git --git-dir=$BUILD_DIR/tbxsosd tag tags/$opt_gittag
512+
[ $? -eq 0 ] || return 1
513+
fi
494514
else
495-
(cd $BUILD_DIR/tbxsosd && git pull)
496-
[ $? -eq 0 ] || return 1
515+
if [ $opt_usehead = 1 ]; then
516+
git --git-dir=$BUILD_DIR/tbxsosd checkout master
517+
[ $? -eq 0 ] || return 1
518+
git --git-dir=$BUILD_DIR/tbxsosd pull
519+
[ $? -eq 0 ] || return 1
520+
fi
497521
fi
498522
(cd $BUILD_DIR/tbxsosd &&
499523
scons PREFIX=$TEAMBOX_HOME --config=force \
@@ -544,14 +568,29 @@ tbxsosd_install() {
544568
}
545569

546570
kmod_build() {
571+
local GIT_KMOD
572+
573+
if [ $opt_fdg = 1 ]; then
574+
GIT_KMOD=https://github.com/fdgonthier/kmod.git
575+
else
576+
GIT_KMOD=https://github.com/tmbx/kmod.git
577+
fi
578+
547579
# Programs
548580
if [ ! -d $BUILD_DIR/kmod/.git ]; then
549581
(cd $BUILD_DIR && git clone $GIT_KMOD)
550582
[ $? -eq 0 ] || return 1
551-
#cd $BUILD_DIR/kmod && git checkout $GIT_TAG
552-
#[ $? -eq 0 ] || return 1
583+
if [ $opt_usehead = 0 ]; then
584+
git --git-dir=$BUILD_DIR/kmod checkout tags/$opt_gittag
585+
[ $? -eq 0 ] || return 1
586+
fi
553587
else
554-
(cd $BUILD_DIR/kmod && git pull)
588+
if [ $opt_usehead = 1 ]; then
589+
git --git-dir=$BUILD_DIR/kmod checkout master
590+
[ $? -eq 0 ] || return 1
591+
git --git-dir=$BUILD_DIR/kmod pull
592+
[ $? -eq 0 ] || return 1
593+
fi
555594
fi
556595
(cd $BUILD_DIR/kmod && scons --quiet config DESTDIR=$TEAMBOX_HOME)
557596
[ $? -eq 0 ] || return 1
@@ -571,15 +610,29 @@ kmod_install() {
571610
}
572611

573612
kas_build() {
613+
local GIT_KAS
614+
615+
if [ $opt_fdg = 1 ]; then
616+
GIT_KAS=https://github.com/fdgonthier/kas.git
617+
else
618+
GIT_KAS=https://github.com/tmbx/kas.git
619+
fi
620+
574621
# Programs
575622
if [ ! -d $BUILD_DIR/kas/.git ]; then
576623
(cd $BUILD_DIR && git clone $GIT_KAS)
577624
[ $? -eq 0 ] || return 1
578-
#cd $BUILD_DIR/kas && git checkout $GIT_TAG
579-
#[ $? -eq 0 ] || return 1
625+
if [ $opt_usehead = 0 ]; then
626+
git --git-dir=$BUILD_DIR/kas checkout tags/$opt_gittag
627+
[ $? -eq 0 ] || return 1
628+
fi
580629
else
581-
(cd $BUILD_DIR/kas && git pull)
582-
[ $? -eq 0 ] || return 1
630+
if [ $opt_usehead = 1 ]; then
631+
git --git-dir=$BUILD_DIR/kas checkout master
632+
[ $? -eq 0 ] || return 1
633+
git --git-dir=$BUILD_DIR/kas pull
634+
[ $? -eq 0 ] || return 1
635+
fi
583636
fi
584637
(cd $BUILD_DIR/kas && scons --quiet config \
585638
libktools_include=$TEAMBOX_HOME/include \
@@ -663,40 +716,61 @@ if [ $(id -u) != 0 ]; then
663716
exit 1
664717
fi
665718

666-
vmmode=0
667-
vmfirst=0
668-
gittag=R1
669-
usehead=0
719+
opt_vmmode=0
720+
opt_vmfirst=0
721+
opt_gittag=$GIT_DEFAULT_TAG
722+
opt_usehead=0
723+
opt_keep=0
724+
opt_fdg=0
670725

671726
firstboot='.*teambox-firstboot'
672727
if [[ $0 =~ $firstboot ]]; then
673-
vmfirst=1
728+
opt_vmfirst=1
674729
fi
675730

676-
ARGS=$(getopt -o vht:h -l "vm,git-tag:,use-head,help" -- "$@");
731+
ARGS=$(getopt -o vht:hkf -l "vm,git-tag:,use-head,help,keep,fdg" -- "$@");
732+
[ $? = 0 ] || exit 0
677733
eval set -- "$ARGS";
678734

679735
while true; do
680736
case "$1" in
681737
-v|--vm)
682738
shift
683-
vmmode=1
739+
opt_vmmode=1
684740
;;
685741
-h|--use-head)
686742
shift
687-
usehead=0
743+
opt_usehead=0
688744
;;
689745
-t|--git-tag)
690746
shift
691-
gittag=$1
747+
if [ -n "$1" ]; then
748+
opt_gittag=$1
749+
shift
750+
else
751+
echo "Missing argument to --git-tag."
752+
exit 1
753+
fi
754+
;;
755+
-k|--keep)
756+
shift
757+
opt_keep=1
758+
;;
759+
-f|--fdg)
760+
shift
761+
opt_fdg=1;
692762
;;
693763
-h|--help)
694764
shift
695765
echo "Teambox Installer script"
696766
echo "Copyright Opersys Inc. 2013"
697767
echo ""
698-
echo " --vm VM mode install VM generating hooks"
699-
echo " Depends on the presence of Turnkey Initthooks"
768+
echo " --vm (-v) VM mode install VM generating hooks "
769+
echo " --keep (-k) Keep the build directory $BUILD_DIR after "
770+
echo " installation "
771+
echo " --fdg (-f) Fetch from http://github.com/fdgonthier repositories "
772+
echo " instead of the ordinary Teambox repositories. "
773+
echo " --git-tag (-t) [tag] Fetch this release tag instead of the default one. "
700774
exit 0
701775
;;
702776
--)
@@ -711,7 +785,7 @@ allSteps="build install"
711785

712786
#exec 2>&1 > teambox-installer.log
713787

714-
if [ $vmfirst = 0 ]; then
788+
if [ $opt_vmfirst = 0 ]; then
715789
detect_distribution dist
716790

717791
if [ "$dist" != "debian" -a "$dist" != "ubuntu" -a "$dist" != "centos" ]; then
@@ -738,7 +812,7 @@ generate_ssl $TEAMBOX_HOME/etc/tbxsosd/ssl \
738812
generate_ssl $TEAMBOX_HOME/etc/kcd/ssl \
739813
kcd.req kcd.key kcd.crt kcd.cnf
740814

741-
if [ $vmfirst = 0 ]; then
815+
if [ $opt_vmfirst = 0 ]; then
742816
echo "*** Installing Python virtual environment packages (don't hold your breath)" >&2
743817
generate_python_virtual_env
744818
if [ $? -eq 1 ]; then
@@ -764,14 +838,14 @@ fi
764838

765839
# Don't execute this if we are producing a VM. It will be executed at
766840
# first boot. In non VM mode, always execute.
767-
if [ $vmmode = 0 -o $vmfirst = 1 ]; then
841+
if [ $opt_vmmode = 0 -o $opt_vmfirst = 1 ]; then
768842
password_fix_all
769843
configure_teambox
770844
fix_hostnames
771845
fi
772846

773847
# Never executed except at first boot.
774-
if [ $vmfirst = 1 ]; then
848+
if [ $opt_vmfirst = 1 ]; then
775849
# Reconfigure the SSH keys.
776850
rm /etc/ssh/ssh_host_dsa_key*
777851
rm /etc/ssh/ssh_host_rsa_key*
@@ -788,7 +862,7 @@ if [ $vmfirst = 1 ]; then
788862
fi
789863

790864
# Install the hook for initthooks
791-
if [ $vmmode = 1 ]; then
865+
if [ $opt_vmmode = 1 ]; then
792866
echo $PWD
793867
cp $0 /etc/init.d/teambox-firstboot
794868
if [ ! -z "$(which update-rc.d 2> /dev/null)" ]; then
@@ -799,11 +873,16 @@ if [ $vmmode = 1 ]; then
799873
fi
800874

801875
# Restart the services.
802-
if [ $vmmode = 0 -a $vmfirst = 0 ]; then
876+
if [ $opt_vmmode = 0 -a $opt_vmfirst = 0 ]; then
803877
run_service tbxsosd
804878
run_service kcd
805879
run_service kcdnotif
806880
run_service kwsfetcher
807881

808882
echo "Please start or restart Apache immediately." >&2
809883
fi
884+
885+
# Erase the build directory if required.
886+
if [ $opt_keep = 0 ]; then
887+
rm -r $BUILD_DIR
888+
fi

0 commit comments

Comments
 (0)