简体   繁体   中英

EC2 user data script crashes during SVN update

I'm trying to use EC2 user data script shebang functionality to update an SVN repository that is already checked out on the instance's EBS image and then run some other commands. The script is consistently crashing during the svn up command, leaving most or all of the files within the repo in a locked state. None of the commands after the svn up command run.

My user data script looks like this:

#!/bin/bash
echo "about to update..." >> /home/ubuntu/test.log
svn up /home/ubuntu/path/to/repository
echo "update finished" >> /home/ubuntu/test.log

The svn up does not finished correctly and the second echo command does not execute.

I'm not seeing any errors in any logs (I'm not exactly sure which logs I should be scouring over, but I've looked through all the obvious ones). Any ideas why svn would be failing?

Permissions problem? Try:

sudo svn up ...

I finally figured out a way to get this working. Instead of calling svn up directly within my user data script, I compiled a simple C app that does the svn up and execute that in the user data script instead:

#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
int main(void) {
    execl("/usr/bin/svn", "svn", "update", "/path/to/repository/", (const char *) NULL);
    return(EXIT_SUCCESS);
}

Unfortunately, I'm not quite sure why this works. I thought to try this because we had a similar issue in a SVN post-commit hook that required the same solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM