⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
sbin
/
View File Name :
convert-tsql
#!/bin/bash # Database translation/creation script # Copyright (C) 2009-2011, AllWorldIT # Copyright (C) 2008, LinuxRulz # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. database="$1" file="$2" prefix="$3" # Display usage info display_usage() { echo "Usage: $0 <database type> <file> [prefix]" echo echo "Valid database types:" echo " mysql55 - For MySQL v5.5" echo " mysql4 - For MySQL v4" echo " mysql - For MySQL v5" echo " pgsql - For PostgreSQL" echo " sqlite - For SQLite v3" echo exit } # Check we have our params if [ -z "$database" -o -z "$file" ] then display_usage fi # Check file exists if [ ! -f "$file" ] then echo "ERROR: Cannot open file '$file'" exit 1 fi # Check what we converting for case "$database" in "mysql55") sed \ -e "s/@PREFIX@/$prefix/g" \ -e 's/@PRELOAD@/SET FOREIGN_KEY_CHECKS=0;/' \ -e 's/@POSTLOAD@/SET FOREIGN_KEY_CHECKS=1;/' \ -e 's/@CREATE_TABLE_SUFFIX@/ENGINE=InnoDB CHARACTER SET latin1 COLLATE latin1_bin/' \ -e 's/@SERIAL_TYPE@/SERIAL/' \ -e 's/@BIG_INTEGER_UNSIGNED@/BIGINT UNSIGNED/' \ -e 's/@INT_UNSIGNED@/INT UNSIGNED/' \ -e 's/@TRACK_KEY_LEN@/512/' \ -e 's/@SERIAL_REF_TYPE@/BIGINT UNSIGNED/' < "$file" ;; "mysql4") sed \ -e "s/@PREFIX@/$prefix/g" \ -e 's/@PRELOAD@/SET FOREIGN_KEY_CHECKS=0;/' \ -e 's/@POSTLOAD@/SET FOREIGN_KEY_CHECKS=1;/' \ -e 's/@CREATE_TABLE_SUFFIX@/TYPE=InnoDB CHARACTER SET latin1 COLLATE latin1_bin/' \ -e 's/@SERIAL_TYPE@/SERIAL/' \ -e 's/@BIG_INTEGER_UNSIGNED@/BIGINT UNSIGNED/' \ -e 's/@TRACK_KEY_LEN@/255/' \ -e 's/@SERIAL_REF_TYPE@/BIGINT UNSIGNED/' < "$file" ;; "mysql") sed \ -e "s/@PREFIX@/$prefix/g" \ -e 's/@PRELOAD@/SET FOREIGN_KEY_CHECKS=0;/' \ -e 's/@POSTLOAD@/SET FOREIGN_KEY_CHECKS=1;/' \ -e 's/@CREATE_TABLE_SUFFIX@/TYPE=InnoDB CHARACTER SET latin1 COLLATE latin1_bin/' \ -e 's/@SERIAL_TYPE@/SERIAL/' \ -e 's/@BIG_INTEGER_UNSIGNED@/BIGINT UNSIGNED/' \ -e 's/@TRACK_KEY_LEN@/512/' \ -e 's/@SERIAL_REF_TYPE@/BIGINT UNSIGNED/' < "$file" ;; "pgsql") sed \ -e "s/@PREFIX@/$prefix/g" \ -e 's/@PRELOAD@/SET CONSTRAINTS ALL DEFERRED;/' \ -e 's/@POSTLOAD@//' \ -e 's/@CREATE_TABLE_SUFFIX@//' \ -e 's/@SERIAL_TYPE@/SERIAL PRIMARY KEY/' \ -e 's/@BIG_INTEGER_UNSIGNED@/INT8/' \ -e 's/@TRACK_KEY_LEN@/512/' \ -e 's/@SERIAL_REF_TYPE@/INT8/' < "$file" ;; "sqlite") sed \ -e "s/@PREFIX@/$prefix/g" \ -e 's/@PRELOAD@//' \ -e 's/@POSTLOAD@//' \ -e 's/@CREATE_TABLE_SUFFIX@//' \ -e 's/@SERIAL_TYPE@/INTEGER PRIMARY KEY AUTOINCREMENT/' \ -e 's/@BIG_INTEGER_UNSIGNED@/UNSIGNED BIG INT/' \ -e 's/@TRACK_KEY_LEN@/512/' \ -e 's/@SERIAL_REF_TYPE@/INT8/' < "$file" ;; *) echo "ERROR: Invalid database type '$database'" exit 1 ;; esac