diff options
author | Eugene Lamskoy | 2022-02-03 20:42:36 +0200 |
---|---|---|
committer | Eugene Lamskoy | 2022-02-03 20:42:36 +0200 |
commit | 022812fa41ddc6e6a2c665f7961eade3c4ffe846 (patch) | |
tree | 59120ae4cfd6726ad5a461347728101f0b540f58 /pear-config-patcher.php | |
parent | cdeefa925911841f044d9f551f03694877f25b9a (diff) | |
download | aur-022812fa41ddc6e6a2c665f7961eade3c4ffe846.tar.gz |
new version
Diffstat (limited to 'pear-config-patcher.php')
-rw-r--r-- | pear-config-patcher.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/pear-config-patcher.php b/pear-config-patcher.php new file mode 100644 index 000000000000..ac6a1254282b --- /dev/null +++ b/pear-config-patcher.php @@ -0,0 +1,42 @@ +<?php +if (!isset($argv, $argc)) { + echo "No command line args provided\n"; + exit(1); +} +if ($argc < 3) { + echo "Not all command line args provided\n"; + exit(2); +} +$targetFile = $confFile = $argv[1]; +$varPath = $argv[2]; + +$data = ''; +$file = fopen($confFile, "r"); + +if ($file !== false) { + while(!feof($file)) { + $line = fgets($file); + $serialized = @unserialize($line); + if (is_array($serialized)) { + $serialized['temp_dir'] = "{$varPath}/temp"; + $serialized['cache_dir'] = "{$varPath}/cache"; + $serialized['download_dir'] = "{$varPath}/download"; + $serialized['metadata_dir'] = "{$varPath}/metadata"; + $data .= @serialize($serialized); + $data .= "\n"; + } else { + $data .= $line; + } + } + fclose($file); + if (false !== file_put_contents($targetFile, $data)) { + echo "Written to $targetFile\n"; + } else { + echo "Failed to write to $targetFile\n"; + exit(3); + } +} else { + echo "File was not found {$confFile}\n"; + exit(4); +} +exit(0); |