Sign inSign up

wozijisun/git

By wozijisun

•Updated about 8 years ago

Just for use git clone URL with PASSWORD.

Image
0

407

wozijisun/git repository overview

⁠Useage:


docker run -it --name git --rm -v ${PWD}:/git -e pass="PASSWORD" -e url="URL" wozijisun/git


PASSWORD is for the URL password. URL is a github or gitlab or self git app.

⁠Dockerfile is :


FROM alpine
ENTRYPOINT wozijisun

ADD git.sh /
ADD expect.exp /

RUN apk --update add git openssh expect && \
    rm -rf /var/lib/apt/lists/*         && \
    rm /var/cache/apk/*

ENTRYPOINT ["/git.sh"]

⁠git.sh


#!/bin/sh

cp /expect.exp /git/

cd /git

project_name=echo "$url" | awk -F "/" '{print $NF}'

for current_path in `ls -al | grep "^d" | awk 'NR>2{print $NF}'`
do
    if [ "${project_name}x" = "${current_path}x" ];then
        rm -rf ./${current_path}
    fi
done

expect expect.exp $pass $url

if [ $? = 0 ];then
    echo "PULL CODE SUCCESS."
else
    echo "PULL CODE FAIL."
fi

rm -rf /git/expect.exp

project_name and the loop with for ,you must use ` please check.

⁠expect.exp


#!/usr/bin/expect -f
set pass [lrange $argv 0 0]
set url [lrange $argv 1 1]

spawn git clone $url
set timeout 30
expect "bx':"
send -- "${pass}\n"
interact

Tag summary

Content type

Image

Digest

Size

12.7 MB

Last updated

about 8 years ago

docker pull wozijisun/git