Re: [gitorious] cronjob to snapshot gitorious 2.4.10

2013-03-20 Thread Thomas Kjeldahl Nilsson
I'll use your predicament as a motivator to finish up and push the 
snapshot script improvements (I have a feature branch for this which has 
been almost ready to merge/push for weeks :/) Hopefully you should just 
be able to git cherry-pick those tweaks once it's pushed to the mainline 
repo. I'll keep you posted.


cheers,
Thomas


On 03/20/2013 11:03 AM, Thomas Chemineau wrote:


Hi Thomas,

Thank your for your answers.

Indeed, on my Gitorious version, I am able to execute the script with 
root privileges with success, but not from the crontab (also with root 
privileges, and all environment paths configured). When I read the 
/var/log/cron file, the script told me that I must run it under 
superuser/root privileges.


I planned a Gitorious upgrade onto the production server the next 
week. It would be really great if you have time to find any solution 
:) Oh, and if you have a fix that I could test for the moment, do not 
hesitate!


Cheers,
Thomas.


Thomas Chemineau



2013/3/19 Thomas Kjeldahl Nilsson tho...@gitorious.com 
mailto:tho...@gitorious.com


Hi Thomas,

just to be sure: so ./script/snapshot works when you run it
manually, but not from the crontab?

I would actually both to fail, unless you run them as root or
prefixed with sudo - the backup script demands to be run as a
superuser.

Note that this superuser requirement will soon go away - I've
worked on a few improvements to the snapshot scripts which I aim
to push this week.

cheers,
Thomas




On 03/19/2013 06:22 PM, Thomas Chemineau wrote:

Hi,

I have a running Gitorious installation into 2.4.10 version.

I would like to schedule a snapshot task into a cron job which
should be executed under root privileges (as mentionned into
Gitorious online doc).

Here is my cron job defined into /etc/cron.d/gitorious:

--8--
RUBY_HOME=/opt/ruby-enterprise
GITORIOUS_HOME=/opt/gitorious

*/5 * * * * root /opt/gitorious-cronjob.sh
--8--

Here is the simple script:

--8--
#!/bin/bash

# Lock file
LOCKFILE=/var/lock/gitorious-cronjob.lock

# Check lock file
[ -f $LOCKFILE ]  exit 2

# Lock this cronjob
echo $$  $LOCKFILE

# Export path
if [ -n $GITORIOUS_HOME ]  [ -n $RUBY_HOME ]; then
  export PATH=$GITORIOUS_HOME/bin:$RUBY_HOME/bin:$PATH
fi

# Run jobs
cd /opt/gitorious
./script/snapshot ~git/gitorious-$(date +%Y%m%d).tar.gz

# Remove lock file
rm -f $LOCKFILE
--8--

When I run manually this simple script, all is working fine
and an archive is correclty created into ~git directory.

But the corresponding cron job failed with the following error:

--8--
X-Cron-Env: RUBY_HOME=/opt/ruby-enterprise
X-Cron-Env: GITORIOUS_HOME=/opt/gitorious
X-Cron-Env: SHELL=/bin/sh
X-Cron-Env: HOME=/root
X-Cron-Env: PATH=/usr/bin:/bin
X-Cron-Env: LOGNAME=root
X-Cron-Env: USER=root

Snapshotting state...
(in /opt/gitorious)
Please run the task as superuser/root!
Snapshot done.
--8--

I had a look into the file lib/tasks/backup.rake, and into
the function called exif_if_sudo. There is a condition which
referred to Process.uid. This statement returns 500, the
uid of my git user which owns the entire /opt/gitorious
directory.

There is something I do not understand. So, any help would be
greatly appreciated.

Cheers,

Thomas.
-- 
-- 
To post to this group, send email to

gitorious@googlegroups.com mailto:gitorious@googlegroups.com
To unsubscribe from this group, send email to
gitorious+unsubscr...@googlegroups.com
mailto:gitorious%2bunsubscr...@googlegroups.com

---
You received this message because you are subscribed to the
Google Groups Gitorious group.
To unsubscribe from this group and stop receiving emails from
it, send an email to gitorious+unsubscr...@googlegroups.com
mailto:gitorious%2bunsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




-- 
Best regards,

Thomas Kjeldahl Nilsson,
Partner  Programmer,
Gitorious AS
http://gitorious.com


-- 
-- 
To post to this group, send email to gitorious@googlegroups.com

mailto:gitorious@googlegroups.com
To unsubscribe from this group, send email to
gitorious+unsubscr...@googlegroups.com
mailto:gitorious%2bunsubscr...@googlegroups.com

--- You received this message because you are subscribed to the
Google Groups Gitorious group.
To unsubscribe from this group and stop receiving emails from it,
send an 

Re: [gitorious] cronjob to snapshot gitorious 2.4.10

2013-03-19 Thread Thomas Kjeldahl Nilsson

Hi Thomas,

just to be sure: so ./script/snapshot works when you run it manually, 
but not from the crontab?


I would actually both to fail, unless you run them as root or prefixed 
with sudo - the backup script demands to be run as a superuser.


Note that this superuser requirement will soon go away - I've worked on 
a few improvements to the snapshot scripts which I aim to push this week.


cheers,
Thomas



On 03/19/2013 06:22 PM, Thomas Chemineau wrote:

Hi,

I have a running Gitorious installation into 2.4.10 version.

I would like to schedule a snapshot task into a cron job which should 
be executed under root privileges (as mentionned into Gitorious online 
doc).


Here is my cron job defined into /etc/cron.d/gitorious:

--8--
RUBY_HOME=/opt/ruby-enterprise
GITORIOUS_HOME=/opt/gitorious

*/5 * * * * root /opt/gitorious-cronjob.sh
--8--

Here is the simple script:

--8--
#!/bin/bash

# Lock file
LOCKFILE=/var/lock/gitorious-cronjob.lock

# Check lock file
[ -f $LOCKFILE ]  exit 2

# Lock this cronjob
echo $$  $LOCKFILE

# Export path
if [ -n $GITORIOUS_HOME ]  [ -n $RUBY_HOME ]; then
  export PATH=$GITORIOUS_HOME/bin:$RUBY_HOME/bin:$PATH
fi

# Run jobs
cd /opt/gitorious
./script/snapshot ~git/gitorious-$(date +%Y%m%d).tar.gz

# Remove lock file
rm -f $LOCKFILE
--8--

When I run manually this simple script, all is working fine and an 
archive is correclty created into ~git directory.


But the corresponding cron job failed with the following error:

--8--
X-Cron-Env: RUBY_HOME=/opt/ruby-enterprise
X-Cron-Env: GITORIOUS_HOME=/opt/gitorious
X-Cron-Env: SHELL=/bin/sh
X-Cron-Env: HOME=/root
X-Cron-Env: PATH=/usr/bin:/bin
X-Cron-Env: LOGNAME=root
X-Cron-Env: USER=root

Snapshotting state...
(in /opt/gitorious)
Please run the task as superuser/root!
Snapshot done.
--8--

I had a look into the file lib/tasks/backup.rake, and into the 
function called exif_if_sudo. There is a condition which referred to 
Process.uid. This statement returns 500, the uid of my git user 
which owns the entire /opt/gitorious directory.


There is something I do not understand. So, any help would be greatly 
appreciated.


Cheers,

Thomas.
--
--
To post to this group, send email to gitorious@googlegroups.com
To unsubscribe from this group, send email to
gitorious+unsubscr...@googlegroups.com

---
You received this message because you are subscribed to the Google 
Groups Gitorious group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to gitorious+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.





--
Best regards,
Thomas Kjeldahl Nilsson,
Partner  Programmer,
Gitorious AS
http://gitorious.com

--
--
To post to this group, send email to gitorious@googlegroups.com
To unsubscribe from this group, send email to
gitorious+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups Gitorious group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to gitorious+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.