makerepo/makerepo

41 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# --------------------------------------------------------
# makerepo - simple tool for repo creation
# Usage: makerepo [-h|--help] <repo_name> "<description>"
# --------------------------------------------------------
PROGNAME=${0##*/}
VERSION="0.0.1"
error_exit() {
printf "%s: %s\n" "$PROGNAME" "${1:-"Unknown Error"}" >&2
exit 1
}
usage() {
printf "usage: makerepo [-h|--help] <repo_name> \"<description>\"" "$PROGNAME" "$VERSION"
}
case $1 in
-h | --help)
usage; exit ;;
-* | --*)
usage; error_exit "unknown option $1" ;;
*)
printf "adding new repo \"%s\" for %s\n" "$1" "$USER"
mkdir /repos/$USER/$1
cd /repos/$USER/$1
git init --bare
printf "adding description for %s\n" "$1"
printf "%s" "$2" > description
cd -
#if [ -s README.md ]; then :; else printf "%s\n------\n%s\n" "$1" "$2" > README.md; fi
#git add README.md
printf "repo created\n"
printf "to push to repo type:\n"
printf "git remote add local /repos/%s/%s\n" "$USER" "$1"
printf "git push -u local master\n"
;;
esac