Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Typo3 class as library and add new command for showing current si…
…te configuration
- Loading branch information
Showing
2 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
class Typo3 | ||
attr_reader :sitename,:username, :password, :host, :dbname, :install_password | ||
|
||
def initialize | ||
get_TYPO3_details | ||
|
||
# look at somehow making this more automatically specific to environment | ||
@port = 3306 | ||
|
||
@socket = `locate -l 1 mysql.sock`.to_s.strip | ||
end | ||
|
||
def show_config | ||
config = %{ | ||
TYPO3 Sitename: #{@sitename} | ||
DB Username: #{@username} | ||
DB Password: #{@password} | ||
DB Host: #{@host} | ||
DB Name: #{@dbname} | ||
Install Tool: #{@install_password} | ||
} | ||
|
||
print config | ||
end | ||
|
||
def with_db | ||
dbh = Mysql.real_connect(self.host,self.username,self.password,self.dbname,@port,@socket) | ||
|
||
begin | ||
yield dbh | ||
ensure | ||
dbh.close | ||
end | ||
end | ||
|
||
private | ||
def get_TYPO3_details | ||
localconf = FileList['**/localconf.php'] | ||
|
||
localconf.each do |t| | ||
conf = IO.read(t) | ||
@sitename = conf.scan(/\$TYPO3_CONF_VARS\[\'SYS\'\]\[\'sitename\'\]\s+=\s+\'(.*)\'\;/).last.to_s ||= '' | ||
@username = conf.scan(/\$typo_db_username\s+=\s+\'(.*)\'\;/).last.to_s ||= '' | ||
@password = conf.scan(/\$typo_db_password\s+=\s+\'(.*)\'\;/).last.to_s ||= '' | ||
@host = conf.scan(/\$typo_db_host\s+=\s+\'(.*)\'\;/).last.to_s ||= '' | ||
@dbname = conf.scan(/\$typo_db\s+=\s+\'(.*)\'\;/).last.to_s ||= '' | ||
@install_password = conf.scan(/\$TYPO3_CONF_VARS\[\'BE\'\]\[\'installToolPassword\'\]\s+=\s+\'(.*)\'\;/).last.to_s ||= '' | ||
end | ||
|
||
end | ||
end |