-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
94 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,5 +1,4 @@ | |||
{ | { | ||
"proxy_host": "proxy.school.tatar.ru", | "proxy_host": "proxy.school.tatar.ru", | ||
"proxy_port": 8080, | "proxy_port": 8080 | ||
"tasks": ["bashrc", "chrome", "apt"] | |||
} | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,60 @@ | |||
var fs = require('fs'); | |||
var path = require('path'); | |||
|
|||
module.exports = { | |||
label_str: '# ClienD proxy', | |||
get_path: function(){ | |||
return path.normalize(process.env.HOME + '/.bashrc'); | |||
}, | |||
get_code: function(){ | |||
var str = "http://" + global.config.edu_login + ":" + global.config.edu_pass + "@" + global.config.host + ":" + global.config.port + "/"; | |||
|
|||
return | |||
this.label_str + "\n" + | |||
"export http_proxy='" + str + "'\n" + | |||
"export ftp_proxy='" + str + "'\n" + | |||
this.label_str | |||
}, | |||
check: function(){ | |||
var filepath = this.get_path(); | |||
if(!fs.existsSync(filepath)) | |||
return false; | |||
else{ | |||
var content = fs.readFileSync(filepath); | |||
if(content.indexOf(this.label_str) !== -1){ | |||
if(content.indexOf(this.get_code()) !== -1) | |||
return true; | |||
else | |||
return false; | |||
} | |||
else | |||
return false; | |||
} | |||
}, | |||
write: function(){ | |||
if (this.check()) | |||
return true; | |||
else{ | |||
var filepath = this.get_path(); | |||
|
|||
if (!fs.existsSync(filepath)) { | |||
if(!fs.writeFileSync(filepath, "\n")){ | |||
console.error("Не удалось создать файл", filepath, '. Запустите скрипт с правами администратора'); | |||
return false; | |||
} | |||
} | |||
|
|||
if (!fs.accessSync(filepath)) { | |||
console.error('Ошибка: недоступен файл', filepath, '. Запустите скрипт с правами администратора'); | |||
return false; | |||
} | |||
|
|||
fs.appendFileSync(filepath, this.get_code()); | |||
|
|||
return true; | |||
} | |||
}, | |||
remove: function(){ | |||
|
|||
} | |||
} |