-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from adamperkowski/fixes
refact: shell code
- Loading branch information
Showing
4 changed files
with
55 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,50 @@ | ||
#!/bin/bash | ||
|
||
version=1.0.0 | ||
latest=$(curl -fsL 'https://discordo.dlsk.tech/VERSION' || echo $version) | ||
|
||
if awk "BEGIN {exit !($version < $latest)}"; then | ||
echo 'There is a new version of Discordo available. Please run:' | ||
echo "curl -fsSL 'https://discordo.dlsk.tech/install.sh' | sudo bash" | ||
exit 1 | ||
fi | ||
|
||
if ! command -v dpkg &> /dev/null; then | ||
echo "This OS is not debian based." | ||
echo 'This OS is not Debian based.' | ||
exit 1 | ||
fi | ||
|
||
debug_mode=false | ||
|
||
while (( "$#" )); do | ||
case "$1" in | ||
-d|--debug) | ||
debug_mode=true | ||
shift | ||
;; | ||
while (("$#")); do | ||
case "$1" in | ||
-d | --debug) | ||
debug_mode=true | ||
shift | ||
;; | ||
*) | ||
PARAMS="$PARAMS $1" | ||
shift | ||
;; | ||
esac | ||
PARAMS="$PARAMS $1" | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
if $debug_mode; then | ||
echo "Debug mode is on." | ||
output="/dev/stdout" | ||
echo 'Debug mode is on.' | ||
output='/dev/stdout' | ||
else | ||
output="/dev/null" | ||
output='/dev/null' | ||
fi | ||
|
||
if [ "$(id -u)" != "0" ]; then | ||
echo "This script requires root access." | ||
echo "Usage: sudo discordo [OPTIONS]" | ||
exit 1 | ||
fi | ||
|
||
echo "Downloading newest version of Discord..." | ||
cd /tmp | ||
wget -O /tmp/discord.deb "https://discord.com/api/download?platform=linux&format=deb" &> $output | ||
if [ $? -ne 0 ]; then | ||
echo "Download error." | ||
exit 1 | ||
fi | ||
tempfile="discord-$(date +%s).deb" | ||
curl -fsL 'https://discord.com/api/download?platform=linux&format=deb' -o "$tempfile" || echo 'Failed to download Discord' | ||
echo "Installing latest version of Discord..." | ||
dpkg -i /tmp/discord.deb &> $output | ||
clear | ||
dpkg -i "$tempfile" &> $output | ||
echo "Done! You now have the latest Discord version!" | ||
rm -f /tmp/discord.deb &> $output | ||
exit 0 | ||
rm "$tempfile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,35 @@ | ||
#! /bin/bash | ||
|
||
clear | ||
|
||
if [ "$(id -u)" != "0" ]; then | ||
echo "This script requires root acces." | ||
echo 'This script requires root acces.' | ||
exit 1 | ||
fi | ||
|
||
file="/usr/bin/discordo" | ||
|
||
if [ -f "$file" ]; then | ||
echo "Detected old version of Discordo. Removing..." | ||
sudo rm -rf $file | ||
fi | ||
files=('/usr/bin/discordo' '/usr/discordo') | ||
|
||
file="/usr/discordo" | ||
for file in "${files[@]}"; do | ||
if [ -f "$file" ]; then | ||
echo "Detected Discordo in $file. Remove? (Y/n)" | ||
read -r remove | ||
case $remove in | ||
n|N) | ||
echo "Skipping." | ||
;; | ||
*) | ||
rm "$file" | ||
;; | ||
esac | ||
fi | ||
done | ||
|
||
if [ -f "$file" ]; then | ||
echo "Detected old version of Discordo. Removing..." | ||
sudo rm -rf $file | ||
if [ ! -d "/usr/bin" ]; then | ||
mkdir -p /usr/bin | ||
export PATH="$PATH:/usr/bin" | ||
echo 'Make sure to add /usr/bin to $PATH' | ||
fi | ||
|
||
cd /usr/bin | ||
sudo wget -O discordo https://discordo.dlsk.tech/discordo.sh &> /dev/null | ||
sudo chmod +x discordo | ||
echo "Installed Discordo!" | ||
curl -fsL 'https://discordo.dlsk.tech/discordo.sh' -o /usr/bin/discordo || echo 'Failed to download Discordo' | ||
sudo chmod +x /usr/bin/discordo | ||
echo 'Installed Discordo!' |