Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rcfiles
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
rcfiles
Commits
e01afcc6
Commit
e01afcc6
authored
8 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
- I may have gone a little overboard with this one.
parent
f4c069c8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Documents/train-wifi.sh
+52
-5
52 additions, 5 deletions
Documents/train-wifi.sh
with
52 additions
and
5 deletions
Documents/train-wifi.sh
+
52
−
5
View file @
e01afcc6
#!/bin/sh
#!/bin/sh
set
-eu
set
-eu
# The MIT License (MIT)
#
# Copyright (c) 2016 Adar Nimrod <nimrod@shore.co.il>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Logs in to the Israeli train's wifi.
# Logs in to the Israeli train's wifi.
# Requires: cURL, sh, awk, logger.
# To install run:
# To install run:
# sudo cp --preserve=mode
"$HOME/Documents/
train-wifi.sh
" "
/etc/NetworkManager/dispatcher.d/90trainwifi
"
# sudo cp --preserve=mode train-wifi.sh
/etc/NetworkManager/dispatcher.d/90trainwifi
die
()
{
echo
$@
| logger
exit
1
}
debug
()
{
[
-n
${
DEBUG
:+x
}
]
&&
echo
$@
| logger
}
if
[
$#
-ne
2
]
then
echo
"Usage:
$0
interface action"
exit
1
else
interface
=
"
$1
"
interface
=
"
$1
"
status
=
"
$2
"
action
=
"
$2
"
fi
which curl
>
/dev/null
||
die
"Can't login to the train wifi, cURL is not installed."
which
awk
>
/dev/null
||
die
"Can't login to the train wifi, awk is not installed."
which logger
>
/dev/null
||
dir
"Can't login to the train wifi, logger is not installed."
if
[
"
$interface
"
=
"ISRAEL-RAILWAYS"
]
&&
[
"
$
status
"
=
"up"
]
if
[
"
$interface
"
=
"ISRAEL-RAILWAYS"
]
&&
[
"
$
action
"
=
"up"
]
then
then
curl http://10.5.4.1/loginHandler.php?allowAccess
=
true
redirect_url
=
"
$(
curl
--output
/dev/null
--silent
--write-out
'%{redirect_url}'
http://google.com/
)
"
debug
"Train wifi redirect url:
$redirect_url
"
login_url
=
"
$(
echo
"
$redirect_url
"
|
awk
-F
\?
'{printf("%s?allowAccess=true", $1)}'
)
"
debug
"Train wifi login url:
$login_url
"
curl
"
$login_url
"
else
debug
"Interface isn't ISRAEL-RAILWAYS or action isn't up, not signing in to the train wifi."
fi
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment