-
Notifications
You must be signed in to change notification settings - Fork 1
/
updateall.sh.example
executable file
·41 lines (40 loc) · 1.16 KB
/
updateall.sh.example
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
#!/bin/bash
#requires jq -> http://stedolan.github.io/jq/ or sudo apt instlall jq
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
if [ $# -eq 0 ]
then
echo "No arguments supplied"
exit 1
fi
location=${1} #specify the locaiton where you want clone the repos
type=${2:-public} #specify the type of the repos to be cloned
user="" #enter your username here
token="" #enter your user token from github
organization=${3} #enter organization name or pass as arguement
read -p "Directory speicified to clone repos is $location are you sure?(enter y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
cd $location
repo_list=$(curl https://api.github.com/orgs/$organization/repos?type=$type\&per_page=1000 -u ${user}:${token} | jq .[].ssh_url | sed -e 's/^"//' -e 's/"$//')
size=${#repo_list}
if [ $size > 0 ]
then
echo -e "${GREEN}Updating $type repos${NC}"
for repo in $repo_list
do
dirgit=${repo#*/}
dir=${dirgit%.*}
cd $dir
echo "Repo : $dir"
git pull
cd ..
done
else
echo "${RED}No $type repos found${NC}"
fi
else
exit 1
fi