Skip to content

Commit

Permalink
Merge pull request #117 from semirke/6.1.x
Browse files Browse the repository at this point in the history
Ownership issue fix 1/x; deploy-dev.sh extension
  • Loading branch information
dterweij committed Mar 10, 2014
2 parents 16e6477 + 13b1e02 commit 053599c
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 83 deletions.
149 changes: 71 additions & 78 deletions deploy-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,63 +21,80 @@
#
# Install and deploy a develoment version on a local enviroment
#
# Version 0.6 Added better argument handling and --single-branch to git by Semir
# Version 0.5 Copied and patched for Kloxo by dkstiler [ Dionysis Kladis <[email protected]> ]
# Version 0.4 Added which, zip and unzip as requirement [ Danny Terweij <[email protected]> ]
# Version 0.3 Added perl-ExtUtils-MakeMaker as requirement to install_GIT [ Danny Terweij <[email protected]> ]
# Version 0.2 Changed git version [ Danny Terweij <[email protected]> ]
# Version 0.1 Initial release [ Ángel Guzmán Maeso <[email protected]> ]
#
KLOXO_PATH='/usr/local/lxlabs'
REPO="lxcenter"
BRANCH="6.1.x"

usage(){
echo "Usage: $0 [BRANCH] [REPOSITORY] [-h]"
echo 'BRANCH: master or dev or 6.1.x'
echo 'REPOSITORY: lxcenter or the repo you want to use'
echo "-b : BRANCH (optional): git branch (like: $BRANCH)"
echo "-r : REPOSITORY (optional): the repo you want to use (like: $REPO)"
echo 'h: shows this help.'
exit 1
}
if [ -z "$1" ] ; then
echo "Please Supply Branch Arguments"
usage
elif [ -z "$2" ] ; then
echo "Please Sypply Repository Arguments"
usage
fi

while getopts “h:r:b:” OPTION
do
case $OPTION in
h)
usage
exit 1
;;
r)
REPO="$OPTARG"
;;
b)
BRANCH="$OPTARG"
;;
?)
usage
exit
;;
esac
done

echo "Using REPO: $REPO BRANCH: $BRANCH "

install_GIT()
{
# Redhat based
if [ -f /etc/redhat-release ] ; then
# Install git with curl and expat support to enable support on github cloning
yum install -y gcc gettext-devel expat-devel curl-devel zlib-devel openssl-devel perl-ExtUtils-MakeMaker
# Debian based
elif [ -f /etc/debian_version ] ; then
# No tested
apt-get install gcc
fi
# Redhat based
if [ -f /etc/redhat-release ] ; then
# Install git with curl and expat support to enable support on github cloning
yum install -y gcc gettext-devel expat-devel curl-devel zlib-devel openssl-devel perl-ExtUtils-MakeMaker
# Debian based
elif [ -f /etc/debian_version ] ; then
# No tested
apt-get install gcc
fi

# @todo Try to get the lastest version from some site. LATEST file?
## GIT_VERSION='1.8.3.4'
GIT_VERSION='1.9.0'
# @todo Try to get the lastest version from some site. LATEST file?
## GIT_VERSION='1.8.3.4'
GIT_VERSION='1.9.0'

echo "Downloading and compiling GIT ${GIT_VERSION}"
wget http://git-core.googlecode.com/files/git-${GIT_VERSION}.tar.gz
tar xvfz git-*.tar.gz; cd git-*;
./configure --prefix=/usr --with-curl --with-expat
make all
make install
echo "Downloading and compiling GIT ${GIT_VERSION}"
wget http://git-core.googlecode.com/files/git-${GIT_VERSION}.tar.gz
tar xvfz git-*.tar.gz; cd git-*;
./configure --prefix=/usr --with-curl --with-expat
make all
make install

echo 'Cleaning GIT files.'
cd ..; rm -rf git-*
echo 'Cleaning GIT files.'
cd ..; rm -rf git-*
}

require_root()
{
if [ `/usr/bin/id -u` -ne 0 ]; then
echo 'Please, run this script as root.'
usage
fi
if [ `/usr/bin/id -u` -ne 0 ]; then
echo 'Please, run this script as root.'
usage
fi
}

require_requirements()
Expand All @@ -96,51 +113,27 @@ require_requirements
echo 'Installing Kloxo development version.'

if which git >/dev/null; then
echo 'GIT support detected.'
echo 'GIT support detected.'
else
echo 'No GIT support detected. Installing GIT.'
install_GIT
echo 'No GIT support detected. Installing GIT.'
install_GIT
fi

# Clone from GitHub the last version using git transport (no http or https)
echo "Cleaning up old installs"
rm -Rf /usr/local/lxlabs.bak
mv /usr/local/lxlabs /usr/local/lxlabs.bak

echo "Installing branch $BRANCH from $REPO repository"
git clone -b $BRANCH --single-branch git://github.com/$REPO/kloxo.git ${KLOXO_PATH}

if [ $? -ne 0 ]; then
echo "Git checkout failed. Exiting."
exit 1;
fi

case $1 in
master )
# Clone from GitHub the last version using git transport (no http or https)
echo "Installing branch kloxo/master from $2 repository"
mkdir -p ${KLOXO_PATH}
git clone git://github.com/$2/kloxo.git ${KLOXO_PATH}
cd ${KLOXO_PATH}
git checkout master
cd ${KLOXO_PATH}/kloxo-install
sh ./make-distribution.sh
cd ${KLOXO_PATH}/kloxo
sh ./make-distribution.sh
printf "Done.\nInstall Kloxo:\ncd ${KLOXO_PATH}/kloxo-install/\nsh kloxo-installer.sh with args\n"
;;
dev )
# Clone from GitHub the last version using git transport (no http or https)
echo "Installing branch kloxo/dev from $2 repository"
git clone git://github.com/$2/kloxo.git ${KLOXO_PATH}
cd ${KLOXO_PATH}
git checkout dev -f
cd ${KLOXO_PATH}/kloxo-install
sh ./make-distribution.sh
cd ${KLOXO_PATH}/kloxo
sh ./make-distribution.sh
printf "Done.\nInstall Kloxo:\ncd ${KLOXO_PATH}/kloxo-install/\nsh kloxo-installer.sh with args\n"
;;
6.1.x )
# Clone from GitHub the last version using git transport (no http or https)
echo "Installing branch kloxo/6.1.x from $2 repository"
git clone git://github.com/$2/kloxo.git ${KLOXO_PATH}
cd ${KLOXO_PATH}
git checkout 6.1.x -f
cd ${KLOXO_PATH}/kloxo-install
sh ./make-distribution.sh
cd ${KLOXO_PATH}/kloxo
sh ./make-distribution.sh
printf "Done.\nInstall Kloxo:\ncd ${KLOXO_PATH}/kloxo-install/\nsh kloxo-installer.sh with args\n"
;;
* )
usage
return 1 ;;
esac
cd ${KLOXO_PATH}/kloxo-install
sh ./make-distribution.sh
cd ${KLOXO_PATH}/kloxo
sh ./make-distribution.sh
printf "Done.\nInstall Kloxo:\ncd ${KLOXO_PATH}/kloxo-install/\nsh kloxo-installer.sh with args\n"
5 changes: 4 additions & 1 deletion kloxo/httpdocs/htmllib/phplib/lib/coreFfilelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ static function removeLeadingSlash($f)
}

static function checkOwnership($username, $path)
{
{
// When creating new files, must not check owner
if(!lfile_exists($path)) return true;

$owner= posix_getpwuid(fileowner(expand_real_root($path)));
if($owner['name']!==$username){
log_log("fileacc_hacking", "{$username} tried to access {$owner['name']}'s file: $path");
Expand Down
12 changes: 8 additions & 4 deletions kloxo/httpdocs/lib/domain/web/webtrafficlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ static function getweb_usage($name, $customer_name, $oldtime, $newtime, $d)
$web_home = "$sgbl->__path_httpd_root";

$log_path = "$web_home/$name/stats";
$processedir = "$sgbl->__path_customer_root/$customer_name/__processed_stats/";

lxfile_mkdir($processedir);
$processeddir = "$sgbl->__path_customer_root/$customer_name/__processed_stats/";

lxfile_mkdir($processeddir);

lxfile_generic_chown($processeddir, $customer_name);

$dir1 = "$log_path/";

$files = lscandir_without_dot($dir1);
Expand All @@ -97,7 +98,10 @@ static function getweb_usage($name, $customer_name, $oldtime, $newtime, $d)
if (isOn($d->remove_processed_stats)) {
lxfile_rm("$dir1/$file");
} else {
lxfile_mv("$dir1/$file", getNotexistingFile($processedir, $file));

$fname= getNotexistingFile($processeddir, $file);
lxfile_mv("$dir1/$file",$fname);
lxfile_generic_chown($fname, $customer_name);
}
}
}
Expand Down

0 comments on commit 053599c

Please sign in to comment.