mirrorgit

Simple Script for Mirroring git Repos
git clone git://git.ckyln.com/mirrorgit.git
Log | Files | Refs | README | LICENSE

commit 04cf37b7beff02960f854da9f635038ac6651170
parent ea68ab1d452cf7eaab084e3ca1a8754dd22961df
Author: Cem Keylan <cem@ckyln.com>
Date:   Thu, 20 Jun 2019 11:02:06 +0300

Created an initial setup

Diffstat:
MREADME.md | 12++++--------
Mmirrorgit.sh | 53+++++++++++++++++++++++++++++++----------------------
2 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/README.md b/README.md @@ -10,18 +10,14 @@ It is pretty simple. ## Usage -Before you use this script you must edit it and add -* Your username -* The server you are mirroring from (eg. https://git.example.com) -* The server you are mirroring to without (eg. github.com) -* A list of the repositories you will be mirroring - -After that you can simply type, - ```shell sh mirrorgit.sh ``` +The script creates a file on your home directory to save configuration + +The file can be located and be edited in ~/.mirrorgitrc + ## Dependencies * Git (obviously) * SSH keys deployed on the mirror repository diff --git a/mirrorgit.sh b/mirrorgit.sh @@ -16,28 +16,37 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see <https://www.gnu.org/licenses/>. -##### IMPORTANT ###### -## You must have an ssh key on the mirror repository in order to be able -## to push your mirrors -SSH="NO" -## After you are sure you have ssh keys on the repo, remove or -## comment this line -###################### +initialize() {\ + clear + printf "███╗ ███╗██╗██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗████████╗ \n████╗ ████║██║██╔══██╗██╔══██╗██╔═══██╗██╔══██╗██╔════╝ ██║╚══██╔══╝ \n██╔████╔██║██║██████╔╝██████╔╝██║ ██║██████╔╝██║ ███╗██║ ██║ \n██║╚██╔╝██║██║██╔══██╗██╔══██╗██║ ██║██╔══██╗██║ ██║██║ ██║ \n██║ ╚═╝ ██║██║██║ ██║██║ ██║╚██████╔╝██║ ██║╚██████╔╝██║ ██║ \n╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ \n" + printf "\nHello, I see you don't have a configuration file on $HOME/.mirrorgitrc\n\nLet's set it up!\nYou need to enter your git username first\nUsername: " + read username + printf "Now, add the domain you will be mirroring from (eg. "https://git.example.com")\nURL: " + read fromhost + printf "You should now add the domain you will be mirroring to.\nIMPORTANT: You must have your ssh keys deployed on this git repository\nDo you understand? (y/n) " + read answer + case $answer in + y*) + printf "Mirror Host should not contain http (eg. \"github.com\")\nEnter host name: " + read tohost + printf "\ +USERNAME=\"$username\"\n\n\ +## Add only the host name\n\ +FROMHOST=\"$fromhost\"\n\ +## Mirrorhost should not contain https or http (eg. \"github.com\")\n\ +MIRRORHOST=\"$tohost\"\n" > $HOME/.mirrorgitrc + ;; + *) + printf "Did you read the prompt carefully?\n" && exit 1 + ;; + esac + printf "Repos you will be mirroring (leave spaces between repos)\nRepos: " + read repos + printf "REPONAMES=\"${repos}\"\n" >> $HOME/.mirrorgitrc +} -case $SSH in - NO) printf "Please configure the script and read the comments\n" && exit 1 ;; -esac - -USERNAME="" - -## Add only the host name (eg. "https://github.com" ) -FROMHOST="" -## Mirrorhost should not contain https or http (eg. "github.com") -MIRRORHOST="" - -## Add the names of your repositories -## with only a space (eg. "repo1 repo2 repo3") -REPONAMES="" +[ -f $HOME/.mirrorgitrc ] || initialize +source $HOME/.mirrorgitrc [ -z $USERNAME ] && printf "You must add your username to the script before you can use it\n" && exit 1 [ -z $FROMHOST ] && printf "You must add your own git repo address beforeyou can use the script\n" && exit 1 @@ -61,5 +70,5 @@ do cd $TEMPFOLD done -printf "Done\n" +printf "\nDone\n" cd $ORIGFOLD