-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLFS_BulkUnlock.sh
96 lines (84 loc) · 1.98 KB
/
LFS_BulkUnlock.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
#####################
# LFS BULK UNLOCK #
# BY FattyMieo #
# #
# VERSION: 1.2 #
# DATE: 04/10/2018 #
#####################
# Config
REPO_PATH=".."
# Color Codes
RED='\033[1;31m'
DARKRED='\033[0;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
CYAN='\033[1;36m'
MAGENTA='\033[1;35m'
NOCOLOR='\033[0m'
clear-inputs()
{
while read -r -t 0; do read -r; done
}
title()
{
echo -e "${YELLOW}\c"
echo "==============================="
echo "| LFS Bulk Unlocker |"
echo "==============================="
echo -e "${NOCOLOR}\c"
echo ""
}
# Run program
cd $REPO_PATH
if [ ! -d "$PWD/.git" ]
then
echo "Unable to detect a git repository. (\".git\" not found)"
echo "Tips: This script should be placed in LFS-GUI folder located at the topmost level of the repository."
echo ""
clear-inputs
read -n 1 -s -r -p "Press any key to continue..."
exit
fi
#Cleanup if terminated
function finish {
rm ./locks.txt
}
trap finish EXIT
title
echo -e "${CYAN}\c"
echo "Insturctions:"
echo " 1. Edit locks.txt and remove all unwanted entries."
echo " 2. Save locks.txt and return to this window."
echo -e "${NOCOLOR}\c"
echo ""
clear-inputs
read -n 1 -s -r -p "Press any key to begin..."
echo ""
echo ""
echo -e "${YELLOW}Generating list of locks into ${MAGENTA}locks.txt${YELLOW}...${NOCOLOR}"
git lfs locks >locks.txt
echo -e "${YELLOW}Opening ${MAGENTA}locks.txt${YELLOW}...${NOCOLOR}"
if start notepad++ # Prefer Notepad++
then
start notepad++ locks.txt
else
start "" locks.txt
fi
echo ""
echo -e "${GREEN}[Bulk Unlock] is ready!${NOCOLOR}"
clear-inputs
read -p "Press [Enter] key to start..."
echo ""
echo "" >> locks.txt # Make sure there's at least an newline character in the file
while read p; do
if [[ ! -z "${p}" ]]
then
echo -e "${GREEN}Unlocking ID ${MAGENTA}${p#*ID:}${GREEN}...${NOCOLOR}"
git lfs unlock -i ${p#*ID:}
fi
done <locks.txt
rm ./locks.txt
echo -e "${YELLOW}Removed ${MAGENTA}locks.txt${YELLOW}!${NOCOLOR}"
clear-inputs
read -n 1 -s -r -p "Press any key to continue..."