Merge pull request #33 from KasperskyLab/dev
Enabling internet for Internet link.
This commit is contained in:
commit
e3e14ddaf9
@ -24,7 +24,7 @@ TinyCheck can be used in several ways by individuals and entities:
|
|||||||
|
|
||||||
- Over a network - TinyCheck is installed on a network and can be accessed from a workstation via a browser.
|
- Over a network - TinyCheck is installed on a network and can be accessed from a workstation via a browser.
|
||||||
- In kiosk mode - TinyCheck can be used as a kiosk to allow visitors to test their own devices.
|
- In kiosk mode - TinyCheck can be used as a kiosk to allow visitors to test their own devices.
|
||||||
- Fully standalone - By using a powerbank and a small screen, [like in this video](https://twitter.com/felixaime/status/1331535790392946689), you can tap any device anywhere.
|
- Fully standalone - By using a powerbank, two Wi-Fi interfaces or a 4G dongle and a small touch screen [like in this video](https://twitter.com/felixaime/status/1331535790392946689), you can tap any device anywhere.
|
||||||
|
|
||||||
### Few steps to analyze your smartphone
|
### Few steps to analyze your smartphone
|
||||||
|
|
||||||
@ -57,10 +57,12 @@ It is worthy to note that not all configuration options are editable from the ba
|
|||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
Prior the TinyCheck installation, you need to have:
|
Prior the TinyCheck installation, you need to understand how it works. It simply does a bridge between the analyzed device and Internet. For that, you need to have two different network interfaces. The first one, a wireless interface which act as a Wi-Fi Access point and the second one, which will be used for the Internet link. This last one can be a second wireless interface or an Ethernet one.
|
||||||
|
|
||||||
|
To recap', you need to have:
|
||||||
|
|
||||||
- A Raspberry Pi with [Raspberry Pi OS Buster](https://www.raspberrypi.org/documentation/installation/installing-images/) (or any computer with a Debian-like system)
|
- A Raspberry Pi with [Raspberry Pi OS Buster](https://www.raspberrypi.org/documentation/installation/installing-images/) (or any computer with a Debian-like system)
|
||||||
- Two working Wi-Fi interfaces (check their number with `iw list | grep Wiphy | wc -l`).
|
- At least one Wi-Fi which will be used as an Access Point (check their number with `iw list | grep -E "* AP$" | wc -l`).
|
||||||
- A working internet connection
|
- A working internet connection
|
||||||
- (Adviced) A small touchscreen previously installed for the kiosk mode of TinyCheck.
|
- (Adviced) A small touchscreen previously installed for the kiosk mode of TinyCheck.
|
||||||
|
|
||||||
|
@ -7,18 +7,18 @@
|
|||||||
<div class="container interfaces-container">
|
<div class="container interfaces-container">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column col-6">
|
<div class="column col-6">
|
||||||
<span class="interface-label">First interface</span>
|
<span class="interface-label">Wireless AP interface</span>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="btn-group btn-group-block">
|
<div class="btn-group btn-group-block">
|
||||||
<button class="btn btn-sm btn-iface" @click="change_interface('in', iface)" :class="iface == config.network.in ? 'active' : ''" v-for="iface in config.interfaces" :key="iface">{{ iface.toUpperCase() }}</button>
|
<button class="btn btn-sm btn-iface" @click="change_interface('in', iface)" :class="iface == config.network.in ? 'active' : ''" v-for="iface in config.ifaces_in" :key="iface">{{ iface.toUpperCase() }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column col-6">
|
<div class="column col-6">
|
||||||
<span class="interface-label">Second interface</span>
|
<span class="interface-label">Internet link interface</span>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="btn-group btn-group-block">
|
<div class="btn-group btn-group-block">
|
||||||
<button class="btn btn-sm btn-iface" @click="change_interface('out', iface)" :class="iface == config.network.out ? 'active' : ''" v-for="iface in config.interfaces" :key="iface">{{ iface.toUpperCase() }}</button>
|
<button class="btn btn-sm btn-iface" @click="change_interface('out', iface)" :class="iface == config.network.out ? 'active' : ''" v-for="iface in config.ifaces_out" :key="iface">{{ iface.toUpperCase() }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
160
app/frontend/package-lock.json
generated
160
app/frontend/package-lock.json
generated
@ -1806,6 +1806,16 @@
|
|||||||
"integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==",
|
"integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"ansi-styles": {
|
||||||
|
"version": "4.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||||
|
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"color-convert": "^2.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cacache": {
|
"cacache": {
|
||||||
"version": "13.0.1",
|
"version": "13.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/cacache/-/cacache-13.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/cacache/-/cacache-13.0.1.tgz",
|
||||||
@ -1832,6 +1842,34 @@
|
|||||||
"unique-filename": "^1.1.1"
|
"unique-filename": "^1.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"chalk": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"ansi-styles": "^4.1.0",
|
||||||
|
"supports-color": "^7.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-convert": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"color-name": "~1.1.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-name": {
|
||||||
|
"version": "1.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||||
|
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"find-cache-dir": {
|
"find-cache-dir": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
|
||||||
@ -1853,6 +1891,25 @@
|
|||||||
"path-exists": "^4.0.0"
|
"path-exists": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"has-flag": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"loader-utils": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"big.js": "^5.2.2",
|
||||||
|
"emojis-list": "^3.0.0",
|
||||||
|
"json5": "^2.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"locate-path": {
|
"locate-path": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
|
||||||
@ -1917,6 +1974,16 @@
|
|||||||
"minipass": "^3.1.1"
|
"minipass": "^3.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"supports-color": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"has-flag": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"terser-webpack-plugin": {
|
"terser-webpack-plugin": {
|
||||||
"version": "2.3.8",
|
"version": "2.3.8",
|
||||||
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz",
|
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz",
|
||||||
@ -1933,6 +2000,18 @@
|
|||||||
"terser": "^4.6.12",
|
"terser": "^4.6.12",
|
||||||
"webpack-sources": "^1.4.3"
|
"webpack-sources": "^1.4.3"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"vue-loader-v16": {
|
||||||
|
"version": "npm:vue-loader@16.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.1.2.tgz",
|
||||||
|
"integrity": "sha512-8QTxh+Fd+HB6fiL52iEVLKqE9N1JSlMXLR92Ijm6g8PZrwIxckgpqjPDWRP5TWxdiPaHR+alUWsnu1ShQOwt+Q==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"chalk": "^4.1.0",
|
||||||
|
"hash-sum": "^2.0.0",
|
||||||
|
"loader-utils": "^2.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -11257,87 +11336,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vue-loader-v16": {
|
|
||||||
"version": "npm:vue-loader@16.0.0-rc.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-rc.1.tgz",
|
|
||||||
"integrity": "sha512-yR+BS90EOXTNieasf8ce9J3TFCpm2DGqoqdbtiwQ33hon3FyIznLX7sKavAq1VmfBnOeV6It0Htg4aniv8ph1g==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"chalk": "^4.1.0",
|
|
||||||
"hash-sum": "^2.0.0",
|
|
||||||
"loader-utils": "^2.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"ansi-styles": {
|
|
||||||
"version": "4.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
||||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"chalk": {
|
|
||||||
"version": "4.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
|
|
||||||
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"ansi-styles": "^4.1.0",
|
|
||||||
"supports-color": "^7.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-convert": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"color-name": "~1.1.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-name": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"has-flag": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"loader-utils": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"big.js": "^5.2.2",
|
|
||||||
"emojis-list": "^3.0.0",
|
|
||||||
"json5": "^2.1.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"supports-color": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"has-flag": "^4.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vue-router": {
|
"vue-router": {
|
||||||
"version": "3.4.3",
|
"version": "3.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.4.3.tgz",
|
||||||
|
@ -11,13 +11,21 @@ import router from '../router'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'home',
|
name: 'home',
|
||||||
props: { saved_ssid: String, list_ssids: Array, internet: Boolean },
|
props: { saved_ssid: String, iface_out: String, list_ssids: Array, internet: Boolean },
|
||||||
methods: {
|
methods: {
|
||||||
next: function() {
|
next: function() {
|
||||||
var saved_ssid = this.saved_ssid
|
var saved_ssid = this.saved_ssid
|
||||||
var list_ssids = this.list_ssids
|
var list_ssids = this.list_ssids
|
||||||
var internet = this.internet
|
var internet = this.internet
|
||||||
router.push({ name: 'wifi-select', params: { saved_ssid: saved_ssid, list_ssids: list_ssids, internet:internet } });
|
console.log(this.iface_out)
|
||||||
|
if (this.iface_out.charAt(0) == "e"){
|
||||||
|
router.push({ name: 'generate-ap' });
|
||||||
|
} else {
|
||||||
|
router.push({ name: 'wifi-select',
|
||||||
|
params: { saved_ssid: saved_ssid,
|
||||||
|
list_ssids: list_ssids,
|
||||||
|
internet:internet } });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,35 +15,58 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
list_ssids: [],
|
list_ssids: [],
|
||||||
internet: false
|
internet: false,
|
||||||
|
iface_out:""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// Check if the device is already connected to internet.
|
// Check if the device is connected to internet.
|
||||||
internet_check: function() {
|
internet_check: function() {
|
||||||
axios.get(`/api/network/status`, { timeout: 10000 })
|
axios.get(`/api/network/status`, { timeout: 10000 })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.internet) this.internet = true
|
if (response.data.internet){
|
||||||
this.get_wifi_networks()
|
this.internet = true
|
||||||
|
this.load_config()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(err => (console.log(err)))
|
.catch(err => (console.log(err)))
|
||||||
},
|
},
|
||||||
// Get the WiFi networks around the box.
|
// Get the WiFi networks around the box.
|
||||||
get_wifi_networks: function() {
|
get_wifi_networks: function() {
|
||||||
axios.get(`/api/network/wifi/list`, { timeout: 10000 })
|
axios.get(`/api/network/wifi/list`, { timeout: 10000 })
|
||||||
.then(response => (this.append_ssids(response.data.networks)))
|
.then(response => {
|
||||||
|
this.list_ssids = response.data.networks
|
||||||
|
this.goto_home();
|
||||||
|
})
|
||||||
.catch(err => (console.log(err)))
|
.catch(err => (console.log(err)))
|
||||||
},
|
},
|
||||||
// Handle the get_wifi_networks answer and call goto_home.
|
// Forward the view to home, with some props
|
||||||
append_ssids: function(networks) {
|
// such as (SSIDs, internet & interface)
|
||||||
this.list_ssids = networks
|
|
||||||
this.goto_home()
|
|
||||||
},
|
|
||||||
// Pass the list of ssids and the internet status as a prop to the home view.
|
|
||||||
goto_home: function() {
|
goto_home: function() {
|
||||||
var list_ssids = this.list_ssids
|
var list_ssids = this.list_ssids
|
||||||
var internet = this.internet
|
var internet = this.internet
|
||||||
router.replace({ name: 'home', params: { list_ssids: list_ssids, internet: internet } });
|
var iface_out = this.iface_out
|
||||||
|
router.replace({ name: 'home', params: { list_ssids: list_ssids, internet: internet, iface_out : iface_out } });
|
||||||
|
},
|
||||||
|
// Get the network_out from the config
|
||||||
|
// to determine the next steps.
|
||||||
|
load_config: function() {
|
||||||
|
axios.get(`/api/misc/config`, { timeout: 60000 })
|
||||||
|
.then(response => {
|
||||||
|
if(response.data.iface_out){
|
||||||
|
this.iface_out = response.data.iface_out
|
||||||
|
// If ethernet, just goto the homepage.
|
||||||
|
// Else, get wifi networks and then go to home.
|
||||||
|
if(this.iface_out.charAt(0) == "e"){
|
||||||
|
setTimeout(function () { this.goto_home(); }.bind(this), 1000);
|
||||||
|
} else {
|
||||||
|
this.get_wifi_networks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function() {
|
created: function() {
|
||||||
|
98
install.sh
98
install.sh
@ -1,10 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ifaces=()
|
|
||||||
rfaces=()
|
|
||||||
CURRENT_USER="${SUDO_USER}"
|
CURRENT_USER="${SUDO_USER}"
|
||||||
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
HOST="$( hostname )"
|
HOST="$( hostname )"
|
||||||
|
IFACES="$( ifconfig -a | grep -Eo '[a-z0-9]{4,14}\: ' | grep -oE [a-z0-9]+ )"
|
||||||
|
IFACE_OUT=""
|
||||||
|
IFACE_IN=""
|
||||||
|
|
||||||
welcome_screen() {
|
welcome_screen() {
|
||||||
cat << "EOF"
|
cat << "EOF"
|
||||||
@ -148,10 +149,10 @@ WantedBy=multi-user.target
|
|||||||
EOL
|
EOL
|
||||||
|
|
||||||
echo -e "\e[92m [✔] Enabling services\e[39m"
|
echo -e "\e[92m [✔] Enabling services\e[39m"
|
||||||
systemctl enable tinycheck-frontend
|
systemctl enable tinycheck-frontend &> /dev/null
|
||||||
systemctl enable tinycheck-backend
|
systemctl enable tinycheck-backend &> /dev/null
|
||||||
systemctl enable tinycheck-kiosk
|
systemctl enable tinycheck-kiosk &> /dev/null
|
||||||
systemctl enable tinycheck-watchers
|
systemctl enable tinycheck-watchers &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_dnsmask() {
|
configure_dnsmask() {
|
||||||
@ -166,7 +167,7 @@ configure_dnsmask() {
|
|||||||
|
|
||||||
## TinyCheck configuration ##
|
## TinyCheck configuration ##
|
||||||
|
|
||||||
interface=${ifaces[-1]}
|
interface=${IFACE_IN}
|
||||||
dhcp-range=192.168.100.2,192.168.100.3,255.255.255.0,24h
|
dhcp-range=192.168.100.2,192.168.100.3,255.255.255.0,24h
|
||||||
EOL
|
EOL
|
||||||
else
|
else
|
||||||
@ -185,7 +186,7 @@ configure_dhcpcd() {
|
|||||||
|
|
||||||
## TinyCheck configuration ##
|
## TinyCheck configuration ##
|
||||||
|
|
||||||
interface ${ifaces[-1]}
|
interface ${IFACE_IN}
|
||||||
static ip_address=192.168.100.1/24
|
static ip_address=192.168.100.1/24
|
||||||
nohook wpa_supplicant
|
nohook wpa_supplicant
|
||||||
EOL
|
EOL
|
||||||
@ -196,8 +197,8 @@ EOL
|
|||||||
|
|
||||||
update_config(){
|
update_config(){
|
||||||
# Update the configuration
|
# Update the configuration
|
||||||
sed -i "s/iface_out/${ifaces[0]}/g" /usr/share/tinycheck/config.yaml
|
sed -i "s/iface_out/${IFACE_OUT}/g" /usr/share/tinycheck/config.yaml
|
||||||
sed -i "s/iface_in/${ifaces[-1]}/g" /usr/share/tinycheck/config.yaml
|
sed -i "s/iface_in/${IFACE_IN}/g" /usr/share/tinycheck/config.yaml
|
||||||
}
|
}
|
||||||
|
|
||||||
change_hostname() {
|
change_hostname() {
|
||||||
@ -302,23 +303,70 @@ cleaning() {
|
|||||||
sudo apt autoremove -y &> /dev/null
|
sudo apt autoremove -y &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
check_wlan_interfaces() {
|
check_interfaces(){
|
||||||
# Check the presence of two wireless interfaces by using rfkill.
|
|
||||||
# Check if they are recognized by ifconfig, if not unblock them with rfkill.
|
|
||||||
echo -e "\e[39m[+] Checking your wireless interfaces"
|
|
||||||
|
|
||||||
for iface in $(ifconfig | grep -oE "(wlan[0-9]|wlx[a-f0-9]{12})"); do ifaces+=("$iface"); done
|
# Get the current connected interface name.
|
||||||
for iface in $(rfkill list | grep -oE phy[0-9]); do rfaces+=("$iface"); done
|
for iface in $IFACES;
|
||||||
|
do
|
||||||
if [[ "${#rfaces[@]}" > 1 ]]; then
|
config="$(ifconfig $iface)"
|
||||||
echo -e "\e[92m [✔] Two interfaces detected, lets continue!\e[39m"
|
if echo "$config" | grep -q "inet "; then
|
||||||
if [[ "${#ifaces[@]}" < 1 ]]; then
|
ciface=$iface
|
||||||
for iface in rfaces; do rfkill unblock "$iface"; done
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Setup of iface_out which can be any interface,
|
||||||
|
# but needs to be connected now or in the future.
|
||||||
|
echo -n " [?] The interface $ciface is connected. Do you want to use it as a bridge to Internet (network/out) ? [Yes/No] "
|
||||||
|
read answer
|
||||||
|
if [[ "$answer" =~ ^([yY][eE][sS]|[yY])$ ]]
|
||||||
|
then
|
||||||
|
IFACES=( "${IFACES[@]/$ciface}" )
|
||||||
|
IFACE_OUT=$ciface
|
||||||
|
echo -e "\e[92m [✔] $ciface setted as a bridge to the Internet\e[39m"
|
||||||
else
|
else
|
||||||
echo -e "\e[91m [✘] Two wireless interfaces are required."
|
IFACES=( "${IFACES[@]/$ciface}" )
|
||||||
echo -e " Please, check if you have two Wi-Fi interfaces available (with the command iw list | grep Wiphy).\e[39m"
|
for iface in $IFACES;
|
||||||
exit
|
do
|
||||||
|
config="$(ifconfig $iface)"
|
||||||
|
echo -n " [?] Do you want to use $iface as a bridge to Internet (network/out) ? [Y/n] "
|
||||||
|
read answer
|
||||||
|
if [[ "$answer" =~ ^([yY][eE][sS]|[yY])$ ]]
|
||||||
|
then
|
||||||
|
IFACE_OUT=$iface
|
||||||
|
IFACES=( "${IFACES[@]/$iface}" )
|
||||||
|
echo -e "\e[92m [✔] $iface setted as a bridge to the Internet\e[39m"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup of iface_in which can be a only a
|
||||||
|
# Wi-Fi interface with AP mode available.
|
||||||
|
for iface in $IFACES;
|
||||||
|
do
|
||||||
|
if echo "$iface" | grep -Eq "(wlan[0-9]|wl[a-z0-9]{20})"; then
|
||||||
|
config="$(ifconfig $iface)" # Get the iface logic configuration
|
||||||
|
if echo "$config" | grep -qv "inet "; then # Test if not currently connected
|
||||||
|
hw="$(iw $iface info | grep wiphy | cut -d" " -f2)" # Get the iface hardware id.
|
||||||
|
info="$(iw phy$hw info)" # Get the iface hardware infos.
|
||||||
|
if echo "$info" | grep -qE "* AP$"; then # Know if the iface has the AP mode available.
|
||||||
|
echo -n " [?] The interface $iface can be used for the Wi-Fi Access Point. Do you want to use it for the TinyCheck Access Point ? [Yes/No] "
|
||||||
|
read answer
|
||||||
|
if [[ "$answer" =~ ^([yY][eE][sS]|[yY])$ ]]
|
||||||
|
then
|
||||||
|
IFACE_IN="$iface"
|
||||||
|
echo -e "\e[92m [✔] $iface setted as an Access Point\e[39m"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "${IFACE_IN}" != "" ] && [ "${IFACE_OUT}" != "" ]; then
|
||||||
|
echo -e "\e[92m [✔] Network configuration setted!\e[39m"
|
||||||
|
else
|
||||||
|
echo -e "\e[91m [✘] You must select two interfaces, exiting.\e[39m"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +411,7 @@ elif [[ -f /usr/share/tinycheck/config.yaml ]]; then
|
|||||||
else
|
else
|
||||||
welcome_screen
|
welcome_screen
|
||||||
check_operating_system
|
check_operating_system
|
||||||
check_wlan_interfaces
|
check_interfaces
|
||||||
create_directory
|
create_directory
|
||||||
set_credentials
|
set_credentials
|
||||||
check_dependencies
|
check_dependencies
|
||||||
|
@ -32,7 +32,8 @@ class Config(object):
|
|||||||
"""
|
"""
|
||||||
config = yaml.load(
|
config = yaml.load(
|
||||||
open(os.path.join(self.dir, "config.yaml"), "r"), Loader=yaml.SafeLoader)
|
open(os.path.join(self.dir, "config.yaml"), "r"), Loader=yaml.SafeLoader)
|
||||||
config["interfaces"] = self.get_wireless_interfaces()
|
config["ifaces_in"] = self.get_ifaces_in()
|
||||||
|
config["ifaces_out"] = self.get_ifaces_out()
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def write_config(self, cat, key, value):
|
def write_config(self, cat, key, value):
|
||||||
@ -55,10 +56,14 @@ class Config(object):
|
|||||||
|
|
||||||
# Changes for network interfaces.
|
# Changes for network interfaces.
|
||||||
if cat == "network" and key in ["in", "out"]:
|
if cat == "network" and key in ["in", "out"]:
|
||||||
if re.match("^(wlan[0-9]|wlx[a-f0-9]{12})$", value):
|
if re.match("^(wlan[0-9]|wl[a-z0-9]{20})$", value):
|
||||||
if key == "in":
|
if key == "in":
|
||||||
self.edit_configuration_files(value)
|
self.edit_configuration_files(value)
|
||||||
config[cat][key] = value
|
config[cat][key] = value
|
||||||
|
if key == "out":
|
||||||
|
config[cat][key] = value
|
||||||
|
elif re.match("^(eth[0-9]|en[a-z0-9]{20})$", value) and key == "out":
|
||||||
|
config[cat][key] = value
|
||||||
else:
|
else:
|
||||||
return {"status": False,
|
return {"status": False,
|
||||||
"message": "Wrong value specified"}
|
"message": "Wrong value specified"}
|
||||||
@ -114,15 +119,27 @@ class Config(object):
|
|||||||
as_attachment=True,
|
as_attachment=True,
|
||||||
attachment_filename='tinycheck-export-db.sqlite')
|
attachment_filename='tinycheck-export-db.sqlite')
|
||||||
|
|
||||||
def get_wireless_interfaces(self):
|
def get_ifaces_in(self):
|
||||||
"""
|
"""
|
||||||
List the Wireless interfaces installed on the box
|
List the Wireless interfaces on the box
|
||||||
|
which can be used as Access Points.
|
||||||
:return: list of the interfaces
|
:return: list of the interfaces
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return [i for i in os.listdir("/sys/class/net/") if i.startswith(("wlan", "wlx"))]
|
return [i for i in os.listdir("/sys/class/net/") if i.startswith("wl")]
|
||||||
except:
|
except:
|
||||||
return ["Interface not found", "Interface not found"]
|
return ["No wireless interface"]
|
||||||
|
|
||||||
|
def get_ifaces_out(self):
|
||||||
|
"""
|
||||||
|
List the network interfaces on the box
|
||||||
|
which can be used to access to Internet.
|
||||||
|
:return: list of the interfaces
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return [i for i in os.listdir("/sys/class/net/") if i.startswith(("wl", "et"))]
|
||||||
|
except:
|
||||||
|
return ["No network interfaces"]
|
||||||
|
|
||||||
def edit_configuration_files(self, iface):
|
def edit_configuration_files(self, iface):
|
||||||
"""
|
"""
|
||||||
|
@ -56,5 +56,6 @@ def get_config():
|
|||||||
"sparklines": read_config(("frontend", "sparklines")),
|
"sparklines": read_config(("frontend", "sparklines")),
|
||||||
"quit_option": read_config(("frontend", "quit_option")),
|
"quit_option": read_config(("frontend", "quit_option")),
|
||||||
"shutdown_option": read_config(("frontend", "shutdown_option")),
|
"shutdown_option": read_config(("frontend", "shutdown_option")),
|
||||||
"reboot_option": read_config(("frontend", "reboot_option"))
|
"reboot_option": read_config(("frontend", "reboot_option")),
|
||||||
|
"iface_out": read_config(("network", "out"))
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user