var pacs = pac.search(); var hive = 'h99'; var password = 'p!' + (new String(Math.random())).substring(2,16) + '!'; function runbash(cmd) { var runtime = java.lang.Runtime.getRuntime(); runtime.exec(["bash", "-c", cmd]); } function mysqldump(pac, db) { var dump = "/home/pacs/" + pac + "/.bak/mysql-" + db + ".dmp.gz"; var cmd = "mysqldump --create-options --flush-logs --force --quote-names --quick --single-transaction " + db + "|gzip --best|secat --user=" + pac + " --group=" + pac + " --umask=007 --output=" + dump; runbash(cmd); } function pgsqldump(pac, db) { var dump = "/home/pacs/" + pac + "/.bak/pgsql-" + db + ".dmp.gz"; var cmd = "export PGUSER=postgres; pg_dump --disable-triggers --oids --compress=0 --format=c " + db + "|gzip --best|secat --user=" + pac + " --group=" + pac + " --umask=007 --output=" + dump; runbash(cmd); } function crontabdump(pac, user) { var dump = "/home/pacs/" + pac + "/.bak/crontab-" + user + ".gz"; var cmd = "crontab -u " + user + " -l" + "|gzip --best|secat --user=" + pac + " --group=" + pac + " --umask=007 --output=" + dump; runbash(cmd); } function shadowdump(pac) { var dump = "/home/pacs/" + pac + "/.bak/shadow.gz"; var cmd = "grep -e '^" + pac + "' /etc/shadow|cut -f1-2 -d':' " + "|gzip --best|secat --user=" + pac + " --group=" + pac + " --umask=007 --output=" + dump; runbash(cmd); } function mysqlaclsdump(pac) { var dump = "/home/pacs/" + pac + "/.bak/mysql_passwd"; var cmd = "mysqldump --no-create-db --skip-opt --no-create-info --replace --where=\"user like '" + pac + "%'\" mysql --tables user > " + dump + " && mysqldump --no-create-db --skip-opt --no-create-info --replace --where=\"db like '" + pac + "%'\" mysql --tables db tables_priv proc >>" + dump; runbash(cmd); } function pgsqlpasswddump(pac) { var dump = "/home/pacs/" + pac + "/.bak/pgsql_passwd.gz"; var cmd = "export PGUSER=postgres; pg_dumpall -r | grep ^ALTER | grep " + pac + "|gzip --best|secat --user=" + pac + " --group=" + pac + " --umask=007 --output=" + dump; runbash(cmd); } if (pacs.length == 1 && hive != 'undef') { var pacname = pacs[0]['name']; var file = new java.io.FileWriter(pacname + '_dump.js'); // Pac file.write('pac.add({set:{\n'); file.write('name: "' + pacs[0]['name'] + '",\n'); file.write('curinetaddr: "' + pacs[0]['curinetaddr'] + '",\n'); file.write('customer: "' + pacs[0]['customer'] + '",\n'); file.write('basepac: "' + pacs[0]['basepac'] + '",\n'); file.write('hive: "' + hive + '",\n'); file.write('password: "' + password + '"\n'); file.write('}});\n'); file.write('pac.update({where:{\n'); file.write('name: "' + pacs[0]['name'] + '"\n'); file.write('},set:{\n'); file.write('components: {\n'); for (var opt in pacs[0]['components']) { file.write(' ' + opt + ': "' + pacs[0]['components'][opt] + '",\n'); } file.write('}}});\n'); // User var unixusers = user.search(); for (idx=0; idx 5) { file.write('user.add({set:{\n'); file.write('name: "' + unixusers[idx]['name'] + '",\n'); file.write('shell: "' + unixusers[idx]['shell'] + '",\n'); file.write('userid: "' + unixusers[idx]['userid'] + '",\n'); file.write('comment: "' + unixusers[idx]['comment'] + '",\n'); file.write('homedir: "' + unixusers[idx]['homedir'] + '",\n'); file.write('quota_hardlimit: "' + unixusers[idx]['quota_hardlimit'] + '",\n'); file.write('quota_softlimit: "' + unixusers[idx]['quota_softlimit'] + '",\n'); file.write('password: "' + password + '"\n'); file.write('}});\n'); } crontabdump(pacname, unixusers[idx]['name']); } // Domain var domains = domain.search(); for (idx=0; idx