TS3Tools / TS3UpdateScript

Automate all update processes for your TeamSpeak 3 server instances
GNU General Public License v3.0
189 stars 22 forks source link

script problem #88

Closed skapytek closed 6 years ago

skapytek commented 6 years ago

Hi, i put this into a script which is called "ts3update.sh"

#!/bin/bash
/root/TS3UpdateScript/TS3UpdateScript --inform-online-clients --check 

when im now logged in as "root" and try this command bash ts3update.sh i get only this message:

Please wait... Script is working...
Unregonized option:
Usage: ./TS3UpdateScript OPTION(S)

i dont know whats wrong with my script and my commands. Maybe you can help me out.

regards

Sebbo94BY commented 6 years ago

Hi, It doesn't make sense to put the command into a shell script and to execute this script as the executed program is already a shell script.

The script is detecting all parameters, the path and so on using $ variables. $0 for example is used to detect the root directory of the TS3UpdateScript as well as the scripts file name: See line 72-75

In your case, these values would reflect the values of your ts3update.sh and not the TS3UpdateScript.

If you only want a short version of this command, you could create yourself an alias. Edit your ~/.bashrc and append the required aliases, you want to have:

alias ts3up='/root/TS3UpdateScript/TS3UpdateScript --check'
alias ts3upinfo='/root/TS3UpdateScript/TS3UpdateScript --check --inform-online-clients'
alias ts3upinfodel='/root/TS3UpdateScript/TS3UpdateScript --check --inform-online-clients --delete-old-logs'

You can add aliases as much as you want to and the names can be anything with characters (a-z) and numbers (0-9).

After saving this file, just login again as this user or reload this file: source ~/.bashrc

After this, you can use your aliases by simply executing the alias name: ts3upinfo

If you want to automate the execution of this command, you need a cronjob like this:

$ cat /etc/cron.d/TS3UpdateScript 
PATH=/usr/local/bin:/usr/bin:/bin
MAILTO="updates@example.com"

# TS3UpdateScript: Cronjob(s) for auto updates

  45 2 * * 1  root /root/TS3tools/TS3UpdateScript/TS3UpdateScript --update-script

  0 3 * * 1  root /root/TS3tools/TS3UpdateScript/TS3UpdateScript --check --delete-old-logs --disable-temporary-password-backup 

# ^ ^ ^ ^ ^
# | | | | |
# | | | | |___ Weekday (0-7, Sunday is mostly 0)
# | | | |_____ Month (1-12)
# | | |_______ Day (1-31)
# | |_________ Hour (0-23)
# |___________ Minute (0-59)

But please note, that cronjobs are an exclusive feature for paid users, which support the project: Script licenses

skapytek commented 6 years ago

i put alias ts3upinfo='/root/TS3UpdateScript/TS3UpdateScript --check --inform-online-clients' into my .bashrc So when i logged in as root i just put ts3upinfo into the shell and press enter?

Sebbo94BY commented 6 years ago

When you've putted it into the .bashrc of the root user and it's loaded by Linux at the login process, then yes.

As I said, you can simply reload this file using this command as the files owner: source .bashrc

Relogging does the same.

skapytek commented 6 years ago

Ah thanks. Forgot to relog. How would a correct ts3update.sh look? I tried this now: ./TS3UpdateScript/TS3UpdateScript --update-script && ./TS3UpdateScript/TS3UpdateScript --inform-online-clients --check in my ts3update.sh but its not working. Only the --update-script is working. Then i get this message: Unregonized option: Usage: ./TS3UpdateScript OPTION(S) Try './TS3UpdateScript --help' for more options.

Sorry, im a beginner in the shell and im trying to learn and understand. Ah and i also can speak german, if thats better for you to understand me ^^

Sebbo94BY commented 6 years ago

As already said here: It's not possible.

The script is detecting all parameters, the path and so on using $ variables. $0 for example is used to detect the root directory of the TS3UpdateScript as well as the scripts file name: See line 72-75

In your case, these values would reflect the values of your ts3update.sh and not the TS3UpdateScript.