Project

General

Profile

Actions

Bug #4376

closed

The rudder-sync.sh script needs to be fixed and be added to the rudder-tools repo

Added by Dennis Cabooter over 10 years ago. Updated about 9 years ago.

Status:
Released
Priority:
4
Category:
-
Target version:
-
Severity:
UX impact:
User visibility:
Effort required:
Priority:
Name check:
Fix check:
Regression:

Description

The rudder-sync.sh script needs to be fixed and be added to the rudder-tools repo.

At the moment the script is not in https://github.com/Normation/rudder-tools/tree/master/scripts. I think it would be nice to add it.

The script now looks like this:

#!/bin/bash
#
# Name:        rudder-sync.sh
# Description: Git pull and rsync Rudder techniques repo
# Author:      Matthieu "Kegeruneku" Cerda matthieu.cerda@normation.com
#
# Can be used manually or as cron.daily file. Pipe to /dev/null when using 
# cron. If you change the branch, remove /var/rudder/techniques-repo so it 
# can be cloned again automagically.
#

TECHNIQUE_BRANCH="branches/rudder/2.8" 
RUDDER_BASE="/var/rudder" 
REPO_NAME="techniques-repo" 
REPO_DIR="${RUDDER_BASE}/${REPO_NAME}" 
MASTER_REPO="https://github.com/Normation/rudder-techniques.git" 
TECH_FROM="${REPO_DIR}/techniques" 
TECH_TO="${RUDDER_BASE}/configuration-repository/techniques" 

# If directory is not present, clone repo in it
if [ ! -d $REPO_DIR ]; then
  cd $RUDDER_BASE
  git clone $MASTER_REPO $REPO_NAME

  cd $REPO_DIR
  git checkout -b $TECHNIQUE_BRANCH origin/${TECHNIQUE_BRANCH}
fi

# Update repo to latest version
cd $REPO_DIR
git pull

# Rsync repository with live tree
rsync -av ${TECH_FROM}/ ${TECH_TO}/

# Send e-mail if any modification has been made
cd $TECH_TO
if [ `git status --porcelain | wc -l` -gt 0 ]; then
  echo "Pending modifications inside the Rudder Techniques repository" 
fi

I now use Rudder 2.9, so I need to change:

TECHNIQUE_BRANCH="branches/rudder/2.8"

to:

TECHNIQUE_BRANCH="branches/rudder/2.9"

However, the script ``as is'' does not switch branches automagically. This needs to be fixed.

Actions #1

Updated by Dennis Cabooter over 10 years ago

12:32 < Kegeruneku> dnns: For 
                    http://www.rudder-project.org/redmine/issues/4376, do you 
                    think specifying the version as an argument would be an 
                    acceptable solution ?

Yeah, but then it looks nice to do it like this:

#!/bin/bash
#
# Name:        rudder-sync.sh
# Description: Git pull and rsync Rudder techniques repo
# Author:      Matthieu "Kegeruneku" Cerda matthieu.cerda@normation.com
#
# Can be used manually or as cron.daily file. Pipe to /dev/null when using 
# cron. If you change the branch, remove /var/rudder/techniques-repo so it 
# can be cloned again automagically.
#

# Global vars 
RUDDER_BASE="/var/rudder" 
REPO_NAME="techniques-repo" 
REPO_DIR="${RUDDER_BASE}/${REPO_NAME}" 
MASTER_REPO="https://github.com/Normation/rudder-techniques.git" 
TECH_FROM="${REPO_DIR}/techniques" 
TECH_TO="${RUDDER_BASE}/configuration-repository/techniques" 

Usage() {
  # Print usage and exit
  echo "Usage:   $0 -b [branch name]" 
  echo "Example: $0 -b branches/rudder/2.8" 
  exit 1
}

# Parse commandline options
while getopts "b:" OPTIONS > /dev/null 2>&1; do
  case $OPTIONS in
    b) TECHNIQUE_BRANCH=$OPTARG ;;
    *) Usage ;;
  esac
done

# Check zero value
[[ $TECHNIQUE_BRANCH ]] || Usage 

# If directory is not present, clone repo in it
if [ ! -d $REPO_DIR ]; then
  cd $RUDDER_BASE
  git clone $MASTER_REPO $REPO_NAME

  cd $REPO_DIR
  git checkout -b $TECHNIQUE_BRANCH origin/${TECHNIQUE_BRANCH}
fi

# Update repo to latest version
cd $REPO_DIR
git pull

# Rsync repository with live tree
rsync -av ${TECH_FROM}/ ${TECH_TO}/

# Send e-mail if any modification has been made
cd $TECH_TO
if [ `git status --porcelain | wc -l` -gt 0 ]; then
  echo "Pending modifications inside the Rudder Techniques repository" 
fi
Actions #2

Updated by Matthieu CERDA over 10 years ago

  • Category set to 13
  • Status changed from New to Pending technical review
  • Assignee changed from Matthieu CERDA to Jonathan CLARKE
  • Priority changed from N/A to 4
  • % Done changed from 0 to 100
  • Pull Request set to https://github.com/Normation/rudder-tools/pull/4

PR available.

Actions #3

Updated by Jonathan CLARKE over 10 years ago

  • Status changed from Pending technical review to Discussion
  • Assignee changed from Jonathan CLARKE to Matthieu CERDA

A couple of updates please Matthieu (see comments in PR!)

Actions #4

Updated by Matthieu CERDA over 10 years ago

  • Status changed from Discussion to Pending technical review
  • Assignee changed from Matthieu CERDA to Jonathan CLARKE

PR updated :)

Actions #5

Updated by Matthieu CERDA over 10 years ago

  • Status changed from Pending technical review to Pending release
Actions #7

Updated by Jonathan CLARKE over 9 years ago

  • Status changed from Pending release to Released
Actions #8

Updated by Benoît PECCATTE about 9 years ago

  • Project changed from Rudder to Rudder websites
  • Category deleted (13)
Actions

Also available in: Atom PDF