summaryrefslogtreecommitdiff
path: root/pbs-init
blob: 1a18911b524a81ea943dde4fa22ac98fd715dae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash -euE

. pbs-plumb-shlib

cmd=${0##*/}
usage() {
	echo "Usage: $cmd [OPTIONS] [DIRECTORY]"
	echo 'Creates a new pbs repository.'
	echo ''
	echo 'Options:'
	echo '  -h            Show this message'
}

main() {
	while getopts 'h' arg; do
		case $arg in
			h) usage; return 0;;
			*) usage; return 1;;
		esac
	done
	shift $(($OPTIND - 1))
	if [[ $# > 1 ]]; then
		usage
		return 1
	fi

	local dir=${1:-./}
	mkdir -p "$dir"
	cd "$dir"

	if in_pbs; then
		error "Already in a PBS directory"
		exit 1
	fi

	git init
	touch .pbs-root
	git add .pbs-root
	git commit -m 'initial commit'
}

main "$@"