fixes certbot script

This commit is contained in:
Akshay Nair
2021-09-02 13:37:34 +05:30
parent 75127dc02e
commit 0619f909ee
4 changed files with 2985 additions and 3054 deletions

View File

@@ -3,7 +3,7 @@ let
inherit (nixpkgs) pkgs;
nixPackages = with pkgs; [
nodejs-15_x
nodejs-16_x
yarn
docker-compose
dnsutils

View File

@@ -32,16 +32,28 @@ update_record() {
echo "
const { domainService } = require('./utils/domain-service');
const { ENV, DOMAIN_DOMAIN } = require('./utils/constants');
const record = {
name: '$name',
type: '$type',
address: '$address',
ttl: $ttl,
};
console.log('Uploading $name to', DOMAIN_DOMAIN, '(', ENV, ')...');
domainService.$method(record)()
.then(d => console.log(d.cpanelresult ? d.cpanelresult.data : d))
.catch(console.error);
const method = '$method';
const name = '$name';
const type = '$type';
const record = { name, type, address: '$address', ttl: $ttl };
async function main() {
if (method === 'removeZoneRecord') {
const data = await domainService.get({ customonly: 0, name: '$name.is-a.dev.', type });
if (data.length > 0) {
record.id = data[0].line;
} else {
throw new Error('Unable to find record');
}
}
console.log('Uploading $name to', DOMAIN_DOMAIN, '(', ENV, ')...');
const data = await domainService[method](record)();
console.log(data.cpanelresult ? data.cpanelresult.data : data);
}
main().catch(console.error);
" | node -
}

View File

@@ -95,13 +95,13 @@ const getDomainService = ({ cpanel }) => {
Promise.all([fetchZoneRecords(), fetchRedirections()]).then(R.flatten);
const addRecords = R.compose(batchLazyTasks(BATCH_SIZE), R.filter(Boolean), R.map(R.cond([
[ R.propEq('name', 'www'), R.always(null) ], // Ignore www
[ R.propEq('type', 'URL'), addRedirection ],
[ R.T, addZoneRecord ],
[R.propEq('name', 'www'), R.always(null)], // Ignore www
[R.propEq('type', 'URL'), addRedirection],
[R.T, addZoneRecord],
])));
const removeRecords = R.compose(batchLazyTasks(BATCH_SIZE), R.map(R.cond([
[ R.propEq('type', 'URL'), removeRedirection ],
[ R.T, removeZoneRecord ],
[R.propEq('type', 'URL'), removeRedirection],
[R.T, removeZoneRecord],
])));
const updateHosts = async hosts => {
@@ -115,7 +115,7 @@ const getDomainService = ({ cpanel }) => {
return { added: add.length, removed: remove.length };
};
return { getHosts, addZoneRecord, removeZoneRecord, updateHosts };
return { getHosts, get: cpanel.zone.fetch, addZoneRecord, removeZoneRecord, updateHosts };
};
const domainService = getDomainService({ cpanel });

5993
yarn.lock

File diff suppressed because it is too large Load Diff