-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
45 lines (39 loc) · 1.26 KB
/
install.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
#!/bin/bash
# Install files:
function install() {
echo "Installing into ${1} …"
# Remote repo zip file:
SOURCE_ZIP="https://github.com/mhulse/basic-node-module/tarball/master"
# Get the zip file and extract all files:
curl -sS -#L "$SOURCE_ZIP" | tar -xzv --strip-components 1 --exclude={install.sh,README.md,LICENSE,package-lock.json}
# Testing (comment out the above and run these lines instead):
#SOURCE_ZIP="/Users/mhulse/Desktop/test.tar.gz"
#tar --strip-components=1 -zxf $SOURCE_ZIP
# Rename the template:
touch README.md
# Let the use know that we are done:
echo $'\n'"Congrats! Installation was successful!"$'\n'
# Open installation folder:
open "."
}
# Check if installation directory meets our requirements:
function empty() {
# Use `ls -A` if you want to account for hidden files:
if [ -d "$1" ] && [ "$(ls $1)" ]; then
# If chosen directory exists, and it’s not empty:
echo "$1 must be an empty directory."
echo "Remove files and try running this script again."
else
# Move on to the installation function:
install $1
fi
}
# Tidy up the terminal window:
clear
# Create menu:
empty "$(pwd)"
# Exit program:
exit 0
# Done!
# For more information about this script, see:
# https://github.com/mhulse/install-scripts