Commit 92a90305 authored by Woude, Auke van der's avatar Woude, Auke van der
Browse files

added option to not create new branch

parent f2477277
......@@ -14,6 +14,23 @@
# CTDAS code can be downloaded from https://git.wur.nl/woude033/test_CTDAS.git
#!/bin/bash
##### This script:
# Use to set up a new ctdas run
# either clone the current branch or
# Create a new branch, based on the current branch
# Usage:
## Options:
# -n: no new branch: clone the current branch
# -M: Master: Create a new branchable branch (i.e. do NOT remove the start_ctdas.sh script
# NOTE THAT THIS SCRIPT DOES NOT CLONE FROM THE GITLAB
# But rather from the current directory.
# This means that pushing will push to the current directory,
# And that a push to the gitlab should be in two steps: First to this directory and then to the gitlab (Or set the upstream to gitlab)
set -e
usage="$basename "$0" [arg1] [arg2] [arg3] [-h] -- script to start a new CTDAS run
......@@ -30,8 +47,59 @@ where:
"
while getopts ':hs:' option; do
rootdir=$1/$2
rundir=$1/$2/exec
branchname=$3
delete=1
while getopts ':nMhs:' option; do
case "$option" in
M) delete=0
echo ' '
echo New branch is a branch from which new clones can be made, not removing the start_ctdas.sh script
echo ' '
rootdir=$2/$3
echo $rootdir
rundir=$2/$3/exec
echo $rundir
branchname=$4
;;
n) echo ' '
echo Cloning from current branch
echo ' '
rootdir=$2/$3
echo $rootdir
rundir=$2/$3/exec
echo $rundir
echo "New project to be started in folder $2"
echo " ...........with name $3"
if [ -d "$rootdir" ]; then
echo "Directory already exists, please remove before running $0"
exit 1
fi
mkdir -p ${rundir}
git clone -q ./ ${rundir}/
cd ${rundir}
echo "Creating jb file, py file, and rc-file"
cp templates/template.jb ${branchname}.jb
cp templates/template.py ${branchname}.py
cp templates/template.rc ${branchname}.rc
rm -f start_ctdas.sh
chmod u+x ${branchname}.jb
echo ""
echo "************* NOW USE ****************"
ls -lta ${branchname}.*
echo "**************************************"
echo ""
pwd
exit
;;
h) echo "$usage"
exit
;;
......@@ -46,21 +114,8 @@ while getopts ':hs:' option; do
esac
done
EXPECTED_ARGS=3
if [[ $# -ne $EXPECTED_ARGS ]]; then
printf "Missing arguments to function, need $EXPECTED_ARGS \n\n"
echo "$usage"
exit 2
fi
echo "New project to be started in folder $1"
echo " ...........with name $2"
rootdir=$1/$2
rundir=$1/$2/exec
branchname=$3
echo "New project to be started in folder $2"
echo " ...........with name $3"
if [ -d "$rootdir" ]; then
echo "Directory already exists, please remove before running $0"
......@@ -70,24 +125,24 @@ fi
mkdir -p ${rundir}
git branch ${branchname}
git checkout ${branchname}
git clone ./ ${rundir}/
git clone -q ./ ${rundir}/
git checkout @{-1}
cd ${rundir}
echo "Creating jb file, py file, and rc-file"
sed -e "s/template/$2/g" templates/template.jb > $2.jb
sed -e "s/template/$2/g" templates/template.py > $2.py
sed -e "s,template,${rootdir},g" templates/template.rc > $2.rc
rm -f start_ctdas.sh
cp templates/template.jb ${branchname}.jb
cp templates/template.py ${branchname}.py
cp templates/template.rc ${branchname}.rc
if [ "$delete"=1 ]; then
rm -f start_ctdas.sh
fi
chmod u+x $2.jb
chmod u+x ${branchname}.jb
echo ""
echo "************* NOW USE ****************"
ls -lrta $2.*
ls -lta ${branchname}.*
echo "**************************************"
echo ""
cd ${rundir}
pwd
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment