Last active
July 18, 2022 14:34
-
-
Save visualblind/dd871c1d87d9481b5009685cbe4f53f1 to your computer and use it in GitHub Desktop.
Nextcloud Talk Chat Commands: Diskspace, Ping
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
#!/usr/bin/env bash | |
BIN_DF=$(which "df") | |
if ! [ -x "$BIN_DF" ]; then | |
echo "df (coreutils package) not installed." | |
echo "See the official documentation for more information" | |
exit 1 | |
fi | |
case "$1" in | |
--help) | |
echo -e '/diskspace - Returns disk space information from the server you are connected\n'; | |
echo -e 'Example: /diskspace\nAlias: /df'; | |
exit 0 | |
;; | |
"") | |
df -hT / | |
;; | |
esac | |
exit 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
#!/usr/bin/env bash | |
# https://nextcloud-talk.readthedocs.io/en/latest/commands/ | |
# For security reasons commands can only be added via the command line. ./occ talk:command:add --help gives you a short overview of the required arguments, but they are explained here in more depth. | |
# Add the script commands with {ARGUMENTS} even if they dont require any, this is for readability when users run /help | |
sudo -u abc /config/www/nextcloud/occ talk:command:add diskspace "Disk Space" "/config/www/scripts/df.sh {ARGUMENTS}" 1 2 | |
sudo -u abc /config/www/nextcloud/occ talk:command:add df "Disk Space" "alias:diskspace" 1 2 | |
sudo -u abc /config/www/nextcloud/occ talk:command:add ping Ping "/config/www/scripts/ping.sh {ARGUMENTS}" 1 2 | |
# List all available commands | |
# Usage: talk:command:list [options] [--] [<app>] | |
sudo -u abc /config/www/nextcloud/occ talk:command:list | |
# +----+-----+-------------+------------+---------------------------------------------------------------------------+----------+---------+ | |
# | id | app | name | command | script | response | enabled | | |
# +----+-----+-------------+------------+---------------------------------------------------------------------------+----------+---------+ | |
# | 1 | | talk | help | help | 1 | 3 | | |
# | 2 | | Wikipedia | wiki | php /config/www/nextcloud/.../sample-commands/wikipedia.php {ARGUMENTS} | 2 | 3 | | |
# | 3 | | Hacker News | hackernews | php /config/www/nextcloud/.../sample-commands/hackernews.php {ARGUMENTS} | 2 | 3 | | |
# | 4 | | Calculator | calculator | /config/www/nextcloud/.../sample-commands/calc.sh {ARGUMENTS} | 1 | 3 | | |
# | 5 | | Calculator | calc | alias:calculator | 2 | 3 | | |
# | 6 | | Disk Space | diskspace | /config/www/scripts/df.sh {ARGUMENTS} | 1 | 2 | | |
# | 7 | | Ping | ping | /config/www/scripts/ping.sh {ARGUMENTS} | 1 | 2 | | |
# | 8 | | Disk Space | df | alias:diskspace | 1 | 2 | | |
# +----+-----+-------------+------------+---------------------------------------------------------------------------+----------+---------+ |
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
#!/usr/bin/env bash | |
BIN_PING=$(which "ping") | |
if ! [ -x "$BIN_PING" ]; then | |
echo "Ping (inetutils package) not installed." | |
echo "See the official documentation for more information" | |
exit 1 | |
fi | |
case "$1" in | |
--help) | |
echo "/ping - Usage: /ping <domain/ip address> or use it without domain/ip parameter" | |
exit 0 | |
;; | |
"") | |
ping -4 -c 5 google.com | |
;; | |
*) | |
ping -4 -c 5 "$1" | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment