Permalink
Browse files

+ Apt support

  • Loading branch information...
atnartur committed Aug 17, 2015
1 parent 20ac249 commit 04a573465a68a0899e225102494a6338ae0a1ff4
Showing with 43 additions and 5 deletions.
  1. +2 −1 start.js
  2. +32 −0 tasks/apt.js
  3. +9 −4 tasks/base.js
View
@@ -7,7 +7,8 @@ var async = require('async');
// задачи
var tasks = {
bashrc: require('./tasks/bashrc'),
chrome: require('./tasks/chrome')
chrome: require('./tasks/chrome'),
apt: require('./tasks/apt')
}
// загрузка конфигурации
View
@@ -0,0 +1,32 @@
var fs = require('fs');
var path = require('path');
var base = require('./base');
module.exports = {
check: base.check,
write: base.write,
remove: base.remove,
label_str: base.label_str,
get_path: function(){
return path.normalize('/etc/apt/apt.conf.d/00cliendproxy');
},
before_write: this.remove,
get_code: function(){
var str = "http://" + global.config.edu_login + ":" + global.config.edu_pass + "@" + global.config.proxy_host + ":" + global.config.proxy_port + "/";
var full =
this.label_str + "\n" +
"Acquire::http::proxy \"" + str + "\";\n" +
"Acquire::https::proxy \"" + str + "\";\n" +
"Acquire::ftp::proxy \"" + str + "\";\n" +
"Acquire::socks::proxy \"" + str + "\";\n" +
"Acquire::::Proxy \"true\";\n" +
this.label_str + "\n";
return full;
},
remove: function(){
var filepath = this.get_path();
fs.unlinkSync(filepath);
return true;
}
}
View
@@ -25,12 +25,17 @@ module.exports = {
if (this.check())
return true;
else{
if(typeof this.before_write !== 'undefined')
this.before_write();
var filepath = this.get_path();
if (!fs.existsSync(filepath)) {
if(!fs.writeFileSync(filepath, "\n")){
console.error("Не удалось создать файл", filepath, '. Запустите скрипт с правами администратора');
return false;
if(!fs.writeFileSync(filepath, "")){
if(!fs.writeFileSync(filepath, "")){
console.error("Не удалось создать файл", filepath, '. Запустите скрипт с правами администратора');
return false;
}
}
}
@@ -65,4 +70,4 @@ module.exports = {
}
return true;
}
}
}

0 comments on commit 04a5734

Please sign in to comment.