Jump to content
metin2dev

Search the Community

Showing results for tags 'sh' in content posted in Programming / Scripts.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Community
    • Announcements
    • Feedback
  • Metin2
    • General
    • Questions and Answers
    • Guides & HowTo
    • Design
    • Private Servers
    • Services
    • Videos
  • Releases
    • General
    • Tools
    • Programming / Scripts
    • Quests
    • Binaries & Clients/Serverfiles
    • 3D Models
    • 2D Graphics
    • Operating Systems
  • Safe Zone
    • Offtopic
    • Games Talk
    • Music/Videos/Art

Categories

There are no results to display.

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


ICQ


Yahoo


Skype


Location

Found 4 results

  1. charparodar

    sh MySQL Backup Script + SSH

    Hi there So, I needed a script that was able to transfer my backups through SSH to another UNIX based server (in this case, Ubuntu). Since I already had the server authenticating with key I had to set it up on the script. Prerequisites: mysqldump gzip ssh scp How does it work: -Dumps and compresses the desired mysql databases -Transfers compressed files to remote host -Removes local compressed files Here's the script with as using private key (it needs to be in OpenSSH format, not PuTTY): #!/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin # Bins MYSQLDUMP=`which mysqldump` GZIP=`which gzip` SSH=`which ssh` SCP=`which scp` # Date for folders and filenames DAY=$(date +"%Y-%m-%d.%T") FILETIME=$(date +"%Y-%m-%d.%T") # Local backup folder (no trailing slash) LOCAL_FOLDER="/tmp/backups" # FTP Configuration REMOTE_HOST="IP" REMOTE_PORT="PORT" REMOTE_USER="USER" REMOTE_PEM="/PATH/TO/KEY" #With no trailing slash REMOTE_FOLDER="/PATH/TO/DESTINATION/FOLDER/" # With trailing slash # MySQL Configuration MYSQL_USER="USER" # Which databases shall we backup? # Databases should be separated with a space DATABASES="account common log player" # Check if DATABASES var is set... if [ "$DATABASES" == "" ]; then echo -e "\033[31mThere is no databases specified...\033[0m" exit 1 fi # Dump and compress for db in $DATABASES do FILE=$db.$FILETIME.gz echo -e "\033[32mDumping $db!\033[0m" $MYSQLDUMP --set-gtid-purged=OFF -u $MYSQL_USER $db | $GZIP -9 > $LOCAL_FOLDER/$FILE done # Transfer all backup files to remote host echo -e "\033[32m\nTransfering files!\033[0m" # Create the remote folder $SSH -p "${REMOTE_PORT}" -i "${REMOTE_PEM}" "${REMOTE_USER}@${REMOTE_HOST}" "mkdir ${REMOTE_FOLDER}${DAY}" # Transfer the files to the remote folder $SCP -P "${REMOTE_PORT}" -r -i "${REMOTE_PEM}" "${LOCAL_FOLDER}" "${REMOTE_USER}@${REMOTE_HOST}:/${REMOTE_FOLDER}/${DAY}" # Delete local dump files rm -f $LOCAL_FOLDER/* If you don't want to use key just remove: -i "${REMOTE_PEM}" You can add more databases to the backup, just edit the array: DATABASES="account common log player" Don't forget to set the script to UNIX formatted text file. I based my script on MadTiago's one, but his only works for FTP. Hope it's useful for someone
  2. Greetings Hereby im sharing with you a script that i've made today for exporting all of the needed dependencies of a binary. This is useful so you don't need to copy line by line each lib file. Please ensure that you change the binary's path. In this case 'db/db_r' and 'game/game_r' # Destination path: /tmp/server_lib32 rm -rf /tmp/server_lib32 mkdir -p /tmp/server_lib32 ldd db/db_r | tail -n+2 | awk '{sub(/.*=> /, ""); print}' | sed 's/([^)]*)//g' | sed -e 's/^[ \t]*//' | xargs -I {} cp {} /tmp/server_lib32/. ldd game/game_r | tail -n+2 | awk '{sub(/.*=> /, ""); print}' | sed 's/([^)]*)//g' | sed -e 's/^[ \t]*//' | xargs -I {} cp {} /tmp/server_lib32/. Best regards, Gamemaster
  3. Hello, I want to release my bash file that generates a all_logs.txt file that contains all syserrs messages from: All channels and all cores of each of them. Including game99 Including auth. Including db. all_logs.txt will look like this: There are currently no errors in my server so that is why it is very small and clean, but everything from all syserrs will be there for you waiting to solve it. I think it is much better instead of going one by one folder to check. In order to install follow the instructions below. Create a new file named show_all_syserr.sh in the same directory as your start.sh and/or other bash files. Open it and write the following code: #!/bin/sh rm -f all_logs.txt #Removes old all_logs.txt if already exists. starting_directory=$PWD #Saves current directory for further use. for current_directory in */*/ ; do ( #For every directory (2 hops, with that i mean 1 hop is going to channel1, channel2, channel3 etc... and second hop is going into core1, core2, core3 etc... (it does not matter how many channels you have or how many cores you have.)) it will collect syserr file contents and append it to all_logs.txt. cd "$current_directory" if [ -f syserr ]; then echo "*************************" >> $starting_directory/all_logs.txt echo "* Logs of $current_directory" >> $starting_directory/all_logs.txt echo "*************************" >> $starting_directory/all_logs.txt cat syserr >> $starting_directory/all_logs.txt fi ); done clear #Cleaning console after job has been done. if [ -f all_logs.txt ]; then #Checks if there is or not a all_logs.txt created. echo -e "\033[32mall_logs.txt created successfully in $starting_directory!\033[0m" else echo -e "\033[32mServer is error free, none syserr found!\033[0m" fi Save, go to console --> sh show_all_syserr.sh --> Wait for it to finish --> You are ready to examine the errors.
  4. Hello, Whenever i logged in on my test-server i wanted to be more like X-Men movies (Welcome Professor!!! famous quote), so i wanted to create a human friendly environment, of course you can modify this to your needs, but this is my script that i want to share with you. Final result will be this: What does it do: Only after you successfully login in FreeBSD it will: Clear console so it will be clean and shiny! Print a welcome message. Print weather automatically parsed from your location (you need to set your location, i will show you how, it is very easy). Change directory (cd) to your desirable location (in my case i wanted to change directory in my start.sh location so i don't have to make the same command every time i login.). Of course you can do whatever else you want it to do. How to make this happen: Login press the following command ee ~/.login Notice that this command is not guaranteed to work on every FreeBSD version but should work on most cases Append the following commands: cd /usr/home/game #Where the change directory should go clear #Clear console after login echo "Welcome $USER!" #Welcome message ($USER variable is the current user logged in) curl -s http://wttr.in/thessaloniki | head -7 | tail -5 #This is the weather info, change "thessaloniki" with the city of your choice. Now press ctrl + C and "exit" (Without quotes, this will save the above information and exit to command line.). Now reboot or logout and login again and see the difference, much cleaner, isn't it?
×