Skip to content

Commit

Permalink
Merge pull request #1 from adamperkowski/fixes
Browse files Browse the repository at this point in the history
refact: shell code
  • Loading branch information
DanielSzewczuk authored Nov 12, 2024
2 parents d35950f + c811d76 commit eabeda3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This tool was created because Discord neither designed an auto-update, nor added
### Install

```bash
wget -O - https://discordo.dlsk.tech/install.sh | sudo bash -
curl -fsSL https://discordo.dlsk.tech/install.sh | sudo bash
```

### Usage
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
52 changes: 27 additions & 25 deletions discordo.sh
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"
41 changes: 26 additions & 15 deletions install.sh
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!'

0 comments on commit eabeda3

Please sign in to comment.