Skip to content

Commit e758968

Browse files
authored
Merge pull request #15 from gitdev-bash/Add-installer
Add installer
2 parents c1dc673 + 166330e commit e758968

File tree

3 files changed

+78
-5
lines changed

3 files changed

+78
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
__pycache__/
2+
Usb-Hut1_12v2.pdf
3+
keylist-en

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,23 @@ ls /sys/class/udc > UDC
5656
Press Ctrl-D to exit
5757
`reboot` reboot to activate the changes
5858
### Install
59-
Also run these commands as root!
59+
Run these as a sudo user or root!
6060

61-
`mkdir /etc/piduck`
61+
**If you want to reinstall or update piduck, please rerun the script.**
6262

63-
`wget -O /etc/piduck/piduck.py https://raw.githubusercontent.com/gitdev-bash/piduck/main/piduck.py`
63+
#### if you have curl
6464

65-
`chmod 555 /etc/piduck/piduck.py`
65+
`curl -sSL https://raw.githubusercontent.com/gitdev-bash/piduck/master/install.sh | bash`
66+
67+
#### if you have wget
68+
69+
`wget -q -O - https://raw.githubusercontent.com/gitdev-bash/piduck/master/install.sh | bash`
70+
71+
#### If you already have it locally
72+
73+
`chmod 755 install.sh`
74+
`./install.sh`
6675

67-
`ln -s /etc/piduck/piduck.py /usr/bin/piduck`
6876
## Usage
6977
Syntax of [Ducky-Script-v1][Ducky-Script-v1-Syntax]
7078
Root is needed (again)

install.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
if [ "$EUID" == "0" ]
4+
then
5+
echo "Running as root"
6+
elif [[ "$(which sudo)" != "" ]]
7+
then
8+
echo "Running as sudo"
9+
if [[ "$0" == "bash" ]]; then
10+
exec curl -sSL https://raw.githubusercontent.com/gitdev-bash/piduck/master/install.sh | sudo bash "$@"
11+
else
12+
exec sudo bash "$0" "$@"
13+
fi
14+
exit $?
15+
fi
16+
#if [[ -d "/etc/piduck" ]]
17+
#then
18+
# echo "Seems like piduck is already installed!"
19+
# exit 4
20+
#else
21+
if [[ "$(which git)" != "" ]]
22+
then
23+
echo "Using git!"
24+
git clone https://github.com/gitdev-bash/piduck.git /tmp/piduck
25+
elif [[ "$(which wget)" != "" && "$(which unzip)" != "" ]]
26+
then
27+
echo "Using wget and unzip"
28+
wget -q -O /tmp/piduck.zip https://github.com/gitdev-bash/piduck/zipball/master/
29+
unzip /tmp/piduck.zip
30+
rm /tmp/piduck.zip
31+
elif [[ "$(which curl)" != "" && "$(which unzip)" != "" ]]
32+
then
33+
echo "Using curl and unzip"
34+
curl -sSL -o /tmp/piduck.zip https://github.com/gitdev-bash/piduck/zipball/master/
35+
unzip /tmp/piduck.zip
36+
rm /tmp/piduck.zip
37+
elif [[ "$(which wget)" != "" && "$(which gunzip)" != "" ]]
38+
then
39+
echo "Using wget and gunzip"
40+
wget -q -O /tmp/piduck.zip https://github.com/gitdev-bash/piduck/tarball/master/
41+
tar -xzvf /tmp/piduck.tar.gz
42+
rm /tmp/piduck.tar.gz
43+
elif [[ "$(which curl)" != "" && "$(which gunzip)" != "" ]]
44+
then
45+
echo "Using curl and gunzip"
46+
curl -sSL -o /tmp/piduck.zip https://github.com/gitdev-bash/piduck/tarball/master/
47+
tar -xzvf /tmp/piduck.tar.gz
48+
rm /tmp/piduck.tar.gz
49+
else
50+
echo "Ops missing dependencies"
51+
exit 2
52+
fi
53+
mkdir /etc/piduck
54+
mv /tmp/piduck/piduck.py /etc/piduck/piduck.py
55+
mv /tmp/piduck/pd_key_maps /etc/piduck/pd_key_maps
56+
mv /tmp/piduck/requirements.txt /etc/piduck/requirements.txt
57+
chmod 555 /etc/piduck/piduck.py /etc/piduck/pd_key_maps/*
58+
chmod 444 /etc/piduck/pd_key_maps/* /etc/piduck/requirements.txt
59+
rm -rf /tmp/piduck
60+
ln -s /etc/piduck/piduck.py /usr/bin/piduck
61+
#fi
62+
echo "DONE!"
63+
exit 0

0 commit comments

Comments
 (0)