MerlinMan Posted January 7, 2014 Share Posted January 7, 2014 Hello, I was wondering if anyone had or knows how to make a script in TCAdmin that created a MySQL username and password/database so the client can run their gamemodes like HL2RP for Garry's Mod. I was also looking into scripts that would allow clients to automatically install SVN links onto their servers. Any help would be appreciated. I can pay for a coder if necessary. Regards, Robert Hicks Link to comment Share on other sites More sharing options...
dimitrifrom31 Posted January 9, 2014 Share Posted January 9, 2014 (edited) "Path_to_your_bin_folder\mysql.exe" -h localhost -u root -pYour_Root_Pass -e "CREATE USER '%ThisUser_UserName%'@'%%'" "Path_to_your_bin_folder\mysql.exe" -h localhost -u root -pYour_Root_Pass -e "SET PASSWORD FOR '%ThisUser_UserName%'@'%%' = PASSWORD('%ThisUser_Password%')" "Path_to_your_bin_folder\mysql.exe" -h localhost -u root -pYour_Root_Pass -e "GRANT USAGE ON * . * TO '%ThisUser_UserName%'@'%%' IDENTIFIED BY '%ThisUser_Password%' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0" "Path_to_your_bin_folder\mysql.exe" -h localhost -u root -pYour_Root_Pass -e "CREATE DATABASE IF NOT EXISTS `%ThisService_IpAddress%:%ThisService_GamePort%`" "Path_to_your_bin_folder\mysql.exe" -h localhost -u root -pYour_Root_Pass -e "GRANT ALL PRIVILEGES ON `%ThisService_IpAddress%:%ThisService_GamePort%` . * TO '%ThisUser_UserName%'@'%%'" The above will create a database named serverip:serverport on localhost User will be set using tca user name and password. It allows remote mysql connection. You can edit the script to match your needs if they are specific. Note that this is a conversion of a script Im using in v1 so it may require testing. Edited January 12, 2014 by dimitrifrom31 fixed wrong variable names Link to comment Share on other sites More sharing options...
Dennis Posted January 11, 2014 Share Posted January 11, 2014 Do you also have a script that drops the MySQL user when the service is deleted? Link to comment Share on other sites More sharing options...
dimitrifrom31 Posted January 12, 2014 Share Posted January 12, 2014 Do you also have a script that drops the MySQL user when the service is deleted? "Path_to_your_bin_folder\mysql.exe" -h localhost -u root -pYour_Root_Pass -e "DROP USER '%ThisUser_UserName%'@'%%'" "Path_to_your_bin_folder\mysql.exe" -h localhost -u root -pYour_Root_Pass -e "DROP DATABASE IF EXISTS `%ThisService_IpAddress%:%ThisService_GamePort%`" Link to comment Share on other sites More sharing options...
Dennis Posted January 13, 2014 Share Posted January 13, 2014 I've been trying to get the first script (the one that creates the MySQL database) working, but nothing happens. It doesn't give any errors. I'm on Linux btw. Link to comment Share on other sites More sharing options...
Raizio Posted January 14, 2014 Share Posted January 14, 2014 I imagine linux to use a different executable and possibly slightly different syntax. Link to comment Share on other sites More sharing options...
Dennis Posted January 14, 2014 Share Posted January 14, 2014 I also did use another executable Link to comment Share on other sites More sharing options...
dimitrifrom31 Posted January 15, 2014 Share Posted January 15, 2014 try replacing the variables by actual values in your script and run it manually to see if you get any error. Link to comment Share on other sites More sharing options...
Dennis Posted January 18, 2014 Share Posted January 18, 2014 It doesn't give me anything. I tried doing this, but nothing happens: "/path/to/mysql" -h localhost -u root -ppass -e "CREATE USER 'Dennis'@'localhost'" If I execute the command from SSH, then it works. Link to comment Share on other sites More sharing options...
Dennis Posted January 18, 2014 Share Posted January 18, 2014 I realized I was editing the Windows version instead of the Linux version... Anyhow, this is what happens when I try doing it: System.Net.Sockets.SocketException: Connection refused at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0 at System.Net.Sockets.TcpClient.Connect (System.Net.IPEndPoint remoteEP) [0x00000] in <filename unknown>:0 at System.Net.Sockets.TcpClient.Connect (System.Net.IPAddress[] ipAddresses, Int32 port) [0x00000] in <filename unknown>:0 - Parameters: minecraft, XX.XXX.XXX.XX, 25585, /home/tcagame_svc267/Dennis/267/, 267 Link to comment Share on other sites More sharing options...
Dennis Posted January 18, 2014 Share Posted January 18, 2014 Okay, I got this far: #!/bin/bash "/opt/lampp/bin/mysql" -h localhost -u root -pMyPassword-e "CREATE USER '${ThisUser_UserName}'@'%%'" "/opt/lampp/bin/mysql" -h localhost -u root -pMyPassword-e "SET PASSWORD FOR '${ThisUser_UserName}'@'%%' = PASSWORD('${ThisUser_Password}')" "/opt/lampp/bin/mysql" -h localhost -u root -pMyPassword-e "GRANT USAGE ON * . * TO '${ThisUser_UserName}'@'%%' IDENTIFIED BY '${ThisUser_Password}' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0" As soon as I insert this line, the script doesn't work: "/opt/lampp/bin/mysql" -h localhost -u root -pMyPassword-e "CREATE DATABASE IF NOT EXISTS ${ThisService_IpAddress}" It doesn't work with any variable. Only if I input clean text. Can anyone help me? Link to comment Share on other sites More sharing options...
Dennis Posted May 4, 2014 Share Posted May 4, 2014 (edited) Bump... Still can't create any databases with a variable. Got it working. I had to declare a variable with the TCAdmin service id variable, and then load that variable. Edited May 4, 2014 by DennisMidjord Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now