Improvements
This commit is contained in:
@ -9,6 +9,8 @@ class Hotfix
|
||||
|
||||
protected $signer;
|
||||
|
||||
protected $keyId;
|
||||
|
||||
protected $header;
|
||||
|
||||
protected $body;
|
||||
@ -16,7 +18,8 @@ class Hotfix
|
||||
public function __construct($hotfix, $signer)
|
||||
{
|
||||
$this->load($hotfix);
|
||||
$this->signer = $signer;
|
||||
$this->signer = $signer[0];
|
||||
$this->keyId = $signer[1];
|
||||
}
|
||||
|
||||
protected function load($hotfix)
|
||||
@ -31,6 +34,11 @@ class Hotfix
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function apply()
|
||||
{
|
||||
if (!array_key_exists('lang', $this->header)) {
|
||||
@ -40,9 +48,12 @@ class Hotfix
|
||||
}
|
||||
|
||||
$script = null;
|
||||
$head = null;
|
||||
$foot = null;
|
||||
switch ($lang) {
|
||||
case 'bash':
|
||||
$exec = "/bin/bash";
|
||||
$head = file_get_contents(__DIR__."/../stubs/bash.stub");
|
||||
break;
|
||||
case 'php':
|
||||
$exec = "/usr/bin/env php";
|
||||
@ -53,7 +64,7 @@ class Hotfix
|
||||
}
|
||||
$tmpfile = sys_get_temp_dir()."/hotfix_".sha1($this->header['hotfix']);
|
||||
|
||||
file_put_contents($tmpfile, $this->body);
|
||||
file_put_contents($tmpfile, $head."\n".$this->body."\n".$foot);
|
||||
passthru($exec." ".$tmpfile);
|
||||
unlink($tmpfile);
|
||||
}
|
||||
@ -68,6 +79,11 @@ class Hotfix
|
||||
$this->signer['uids'][0]['email']
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeyId()
|
||||
{
|
||||
return $this->keyId;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
|
Reference in New Issue
Block a user