Skip to content

Commit de20a9a

Browse files
author
Invers3
committed
Fixed pw.cgi
Fixed updater.sh
1 parent bcd34f7 commit de20a9a

4 files changed

Lines changed: 29 additions & 32 deletions

File tree

etc/init.d/pw

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,11 @@ stop() {
7474
kill $pid
7575
done
7676

77+
}
78+
79+
update() {
80+
81+
/tmp/updater.sh
82+
wait
83+
7784
}

www/assets/js/main.js

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ var appView = Backbone.View.extend({
119119
]}));
120120
});
121121

122-
123-
124122
},
125123
'click button#pppoe_pw': function(){
126124

@@ -156,21 +154,14 @@ var appView = Backbone.View.extend({
156154
});
157155

158156
},
159-
'click button#restart_http': function(event){
157+
'click button#updater_rep': function(event){
158+
159+
var self = this;
160160

161161
$.modal(function(modal){
162-
modal.content($('<div class="preloader center"></div>'));
163-
});
164-
this.model.fetch({
165-
method: 'POST',
166-
data: {
167-
task:'restartHttp',
168-
token:this.webToken
169-
}
170-
}).then(function(res){
171-
$.modal.close();
172-
}).catch(function(err){
173-
$.modal.close();
162+
modal.content(self.templates.msg({message: 'Update PPPwn OpenWrt?', buttons: [
163+
{label:"Yes, Install update", id: "update_rep", onclick:"appweb.update()"}
164+
]}));
174165
});
175166

176167
},
@@ -377,14 +368,12 @@ var appView = Backbone.View.extend({
377368
data: {
378369
task:'update',
379370
token:this.webToken
380-
},
381-
success: this.state.bind(this)
382-
}).then(function(){
371+
}
372+
}).then(function(response){
373+
location.assign("/pppwn.html")
383374
document.cookie = 'token=; path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
384-
$.modal.close();
385375
}).catch(function(err){
386376
$.modal.content(self.templates.msg({message: err.statusText, buttons:[]}));
387-
location.assign("/");
388377
});
389378

390379
},
@@ -447,14 +436,6 @@ var appView = Backbone.View.extend({
447436

448437
var self = this, interfaces = [], data = response.toJSON();
449438

450-
if(data.update){
451-
$.modal.content(self.templates.msg({message: 'Update available.<br>Click in continue to update.', buttons:[
452-
{label:"Yes, continue", id: "update_rep", onclick:"appweb.update()"}
453-
]}));
454-
}else{
455-
$.modal.close();
456-
}
457-
458439
if (this.model.get('stored_token')) {
459440
document.cookie = 'token=; path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
460441
this.cookie('token', this.model.get('stored_token'));
@@ -523,6 +504,8 @@ var appView = Backbone.View.extend({
523504
modal.content(self.templates.msg({message: 'TheOfficialFloW / SiSTR0 / xfangfang', buttons:[]}));
524505
});
525506
});
507+
508+
$.modal.close();
526509

527510
return this;
528511
},

www/cgi-bin/pw.cgi

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ case "$task" in
189189
echo "\"path\":\"$(uci get pw.@params[0].path)\","
190190

191191
if [ "$latest_version" -gt "$current_version" ]; then
192-
"$(wget -O /tmp/updater.sh https://raw.githubusercontent.com/CodeInvers3/codeinvers3.github.io/refs/heads/master/files/updater.sh)"
192+
if ! [ -f /tmp/updater.sh ]; then
193+
"$(wget -O /tmp/updater.sh https://raw.githubusercontent.com/CodeInvers3/codeinvers3.github.io/refs/heads/master/files/updater.sh)"
194+
chmod +x /tmp/updater.sh
195+
fi
193196
echo "\"update\":true,"
194197
else
195198
echo "\"update\":false,"
@@ -353,10 +356,11 @@ case "$task" in
353356
echo "Content-Type: application/json"
354357
echo ""
355358

356-
/tmp/updater.sh
359+
#/etc/init.d/pw update
360+
"$(/tmp/updater.sh)"
357361
wait
358-
359-
echo "{\"output\":\"Update completed\"}"
362+
363+
echo "{\"output\":\"Updated!\"}"
360364

361365
exit 0
362366

www/pppwn.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
<button type="button" id="pppoe_pw" class="btn-form input-attach sec-auto">PPPoe Start</button>
103103
<% } %>
104104
<button type="button" id="remove_rep" class="btn-form input-attach sec-auto">Uninstall</button>
105+
<% if(update){ %>
106+
<button type="button" id="updater_rep" class="btn-form input-attach sec-auto">Update</button>
107+
<% } %>
105108
</div>
106109
</div>
107110
</fieldset>

0 commit comments

Comments
 (0)