-
Notifications
You must be signed in to change notification settings - Fork 6
/
test-script-localrepo.sh
executable file
·41 lines (32 loc) · 1.03 KB
/
test-script-localrepo.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
#!/bin/bash
# Description: Test your installation script on your local repository.
# Error Handling
##################################################################
if [ -z "$1" ]; then
echo "ERROR: Please provide your installation script that you would like to test."
echo " e.g.: $0 scripts/repository/my_script.sh"
exit 1
fi
if [ ! -e "$1" ] || [ ! -f "$1" ]; then
echo "ERROR: "$1" : No such file."
exit 1
fi
# Main
##################################################################
SCRIPT_NAME="$(basename "$(test -L "$1" && readlink "$1" || echo "$1")")"
INITIAL_PATH=$(pwd)
## Change to local repository
DEB_REPO_URL=http://localhost/debian-repo/
SOURCE_LIST=/etc/apt/sources.list
cp ${SOURCE_LIST} ${SOURCE_LIST}.old
echo "deb http://localhost/debian-repo/ jessie main contrib non-free" > /etc/apt/sources.list
apt-get update
## Run script
cd scripts
cp repository/${SCRIPT_NAME} .
source load-global-vars-funcs.sh
./${SCRIPT_NAME}
rm -f ${SCRIPT_NAME}
cd ..
## Restore sources.list
yes | cp ${SOURCE_LIST}.old ${SOURCE_LIST}