Hype-2/README.md

115 lines
2.6 KiB
Markdown
Raw Normal View History

2023-10-17 08:03:51 +00:00
# Hype²
```mermaid
graph LR
Webpage[Web page] <--Flask--> Server[Server]
Server[Server] <----> Qemu((Qemu))
Server[Server] <----> LXC((LXC))
```
## Install requirement
1 - Update and Install packages :
```sh
apt-get update -y -qq
apt-get install lxc lxcfs lxc-templates qemu qemu-utils qemu-kvm virtinst bridge-utils virt-manager libvirt-daemon libvirt-daemon-system virt-viewer libvirt-clients libosinfo-bin websockify sqlite3 novnc
apt-get install python3 python3-flask python3-flask-login python3-flask-sqlalchemy python3-requests python3-lxc python3-libvirt python3-psutil python3-werkzeug python3-websockify python3-novnc
```
2 - Configure Libvirst to start on boot
```sh
systemctl --quiet enable --now libvirtd
systemctl --quiet start libvirtd
```
3 - Create a bridge nework
```sh
cp ./bridged.xml /usr/share/libvirt/networks/
virsh net-define bridged.xml
virsh net-start bridged
virsh net-autostart bridged
```
2023-10-17 12:44:18 +00:00
## Database for users
A default Database is provided in the git (db.db.admin_example), the default user is admin / admin.
To use this database, just change the name from db.db.admin_example to db.db.
If you want to create this database by yourself, you can :
### Create Database for users
2023-10-17 08:03:51 +00:00
```sh
sqlite3 db.db
2023-10-17 12:44:18 +00:00
CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT, username NVARCHAR(200) NULL, email NVARCHAR(200) NULL, password NVARCHAR(200) NULL);
2023-10-17 08:03:51 +00:00
```
2023-10-17 12:44:18 +00:00
### Create first user
2023-10-17 08:03:51 +00:00
1 - Generate encrypted password :
```sh
python3
import app
app.encrypt('Password')
```
2 - Fill Database with user info :
```sh
sqlite3 db.db
INSERT INTO user (id,username,email,password) VALUES (1,'<you_username>','<your_email>','<your_previous_encrypted_password');
```
## Configure Reverse Proxy to get access to Consoles
```sh
ProxyPass /websockify ws://<server_ip>:6080/websockify retry=3
ProxyPassReverse /websockify ws://<server_ip>:6080/websockify retry=3
ProxyPass /socket.io ws://<server_ip>:5008/socket.io retry=3
ProxyPassReverse /socket.io ws://<server_ip>:5008/socket.io retry=3
```
## Run and use
```sh
python3 app
and go to https://<server_ip>:5007 with your credentials (mail and normal password)
```
## Systemd
You can manage hype using Systemd management:
```sh
[Unit]
Description= Hype2 service
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3 <path_to_change>/app.py
[Install]
WantedBy=multi-user.target
```
put this file in /etc/systemd/system/ and you can then enable it for autostart on boot and/or start/stop the app.
## Configuration
You can also change some configuration in the file *configuration.py* such as flask port, storage location...use it at your own risk.