Compare commits

..

53 Commits

Author SHA1 Message Date
e6d65c9348 update readme 2026-04-21 19:58:52 +00:00
0a8d3b2426 stump tweaks 2026-04-20 19:27:09 +00:00
b8286725af remove kavita 2026-04-19 02:11:36 +00:00
9aaba3452e cleanup caddyfile comments 2026-04-16 06:25:07 +00:00
6f0df113c2 working book and caddy 2026-04-16 06:21:50 +00:00
0a8d754365 gitignore stumpdir 2026-04-13 22:28:38 +00:00
c34789a631 fix stump compose 2026-04-13 22:27:48 +00:00
49d08e8f42 Merge branch 'caddy' of https://gut.oily.dad/finn/site into caddy 2026-04-13 14:30:03 -07:00
fb5fc705dc add stump 2026-04-13 14:27:29 -07:00
f63ee28d2b pre fuse checkpoint 2026-04-13 18:08:52 +00:00
b780c043fa sshtun add rev tunnel keys 2026-04-13 00:50:58 -07:00
fa73ccbc90 Switch to Caddy 2026-04-12 18:09:30 -07:00
345d66b5c9 fix py3 back compat failure 2026-03-19 19:24:44 -07:00
b6ccb0c859 stop gitea regs 2026-03-19 21:18:01 +00:00
42a12d7ced also update example compose files 2026-01-04 08:03:22 +00:00
a329511464 set up admin-allowed registration 2026-01-04 08:01:10 +00:00
fc927eef63 add long staged emoji changes 2025-08-30 08:38:45 +00:00
7ed3b07ab4 Merge pull request 'Fixed typo.' (#7) from oily.mom/site:typo-fix into master
Reviewed-on: #7
Massive.
2025-08-30 04:46:38 +00:00
JustinOros
0f2ab58f00 Fixed typo. 2025-08-25 09:32:28 -07:00
950c9a6aea gitea ui tweaks 2025-01-02 02:22:57 +00:00
414c300b41 recenter gitea link 2024-09-05 20:24:47 -07:00
a5ac19a2a4 Merge pull request 'remove hard tabs oops' (#5) from tab_to_softtab into master
Reviewed-on: #5
2024-09-02 22:48:05 +00:00
78c0895418 disable gitea reg if link on tld 2024-09-02 07:47:47 +00:00
8cbe7eecd3 remove tabs from html 2024-09-02 07:22:23 +00:00
9090da987f gitea link in header 2024-09-02 00:04:58 -07:00
650e77210e move onion address to nginx header 2024-08-20 19:40:33 +00:00
16a45c495d restart always incomp with env switch 2024-08-10 06:30:54 -07:00
08ae04a154 ssh tunnel env switch and logging 2024-08-10 06:12:26 -07:00
78384a31fb Merge pull request 'initial working ssh entry' (#4) from ssh_in into master
Reviewed-on: #4
2024-08-10 02:18:05 +00:00
60280917c6 set default to prod 2024-08-10 02:08:35 +00:00
8f8c0c1401 fix composes 2024-08-09 18:58:40 -07:00
979adc3b13 initial working ssh entry 2024-08-09 18:47:22 -07:00
619ce9b0bd long username titles 2024-08-08 18:44:49 +00:00
bcec5d05c8 fix titles 2024-08-08 18:28:57 +00:00
71f8ff967c minor title fix profile 2024-08-08 11:25:28 -07:00
d61fd3bb2c fix post wrapping 2024-08-08 11:12:36 -07:00
234230c14a restorve dev values for env example checked safe 2024-08-08 10:14:31 -07:00
a22c1a4e1e minor color 2024-08-08 16:51:06 +00:00
51693a7860 add registration switch env composes 2024-08-08 16:14:28 +00:00
8f95303d11 add registration switch env 2024-08-08 16:10:43 +00:00
92b314623a appearance tweaks 2024-08-08 15:14:44 +00:00
1c6293fda3 alpine for tor 2024-08-08 04:42:12 -07:00
c295d52520 Merge pull request 'add tor entrypoint' (#3) from hstor into master
Reviewed-on: #3
2024-08-08 11:14:18 +00:00
4e948af492 add tor env switch 2024-08-08 02:57:33 -07:00
b9a432b356 working tor 2024-08-08 02:17:49 -07:00
1ced0d8b24 fix db backup script 2024-08-07 13:51:46 +00:00
d1d64b181a db root localhost only 2024-08-06 16:27:32 +00:00
cd61c513c7 add prod/local compose 2024-08-06 09:03:17 -07:00
bd5b04eeae db user restrict access to container 2024-08-06 09:01:04 -07:00
2ba3fe0a7e navbar current decorator 2024-08-05 09:09:51 -07:00
82baefb3d2 ro certs 2024-08-05 14:55:38 +00:00
7c286e1235 uwsgi and thread don't play nice 2024-08-05 14:22:32 +00:00
b65daf3784 prod cleanup for live c10 2024-08-05 09:55:47 +00:00
47 changed files with 1086 additions and 417 deletions

10
.gitignore vendored
View File

@@ -1,6 +1,10 @@
gitea/ gitea
.env .env
pmb-pf/ pmb-pf
stump
kavita
venv venv
zapp.db zapp.db
db/bu
tor/hidden_service
sshtun/oilykey

View File

@@ -19,15 +19,18 @@ Install? PROBABLY NOT, this runs entirely in alpine and would be nice to isolate
### Admin general: ### Admin general:
usermod -aG docker finn - `usermod -aG docker finn`
- edit `/etc/systemd/journald.conf`
- set or append `SystemMaxUse=500M`
### Admin firewall: ### Admin firewall:
```
ufw default deny incoming ufw default deny incoming
ufw default allow outgoing ufw default allow outgoing
ufw allow "OpenSSH" ufw allow "OpenSSH"
ufw allow "WWW Full" ufw allow "WWW Full"
ufw enable ufw enable
```
### Admin dns: ### Admin dns:
@@ -69,6 +72,12 @@ Find in proxy/conf.\
Find in gitea conf.\ Find in gitea conf.\
Rebuild images. Rebuild images.
### MariaDB backup:
```
mariadb-dump -uroot -pxxxx gitea > /bu/19840101.sql
mariadb -uroot -pxxxx gitea < /bu/19840101.sql
```
### Todo: ### Todo:
- gitea subdomain will require wildcard cert -- therefore "*.oily.dad" AND "oily.dad" DONE - gitea subdomain will require wildcard cert -- therefore "*.oily.dad" AND "oily.dad" DONE
- move more stuff from backend config into root .env - move more stuff from backend config into root .env

View File

@@ -11,12 +11,14 @@ def send_email(subject, sender, recipients, text_body, html_body):
msg = Message(subject, sender=sender, recipients=recipients) msg = Message(subject, sender=sender, recipients=recipients)
msg.body = text_body msg.body = text_body
msg.html = html_body msg.html = html_body
Thread(target=send_async_email, args=(app, msg)).start() mail.send(msg)
# Thread works surprisingly badly behind uwsgi, just let a uwsgi worker do its thing instead.
#Thread(target=send_async_email, args=(app, msg)).start()
def send_password_reset_email(user): def send_password_reset_email(user):
token = user.get_reset_password_token() token = user.get_reset_password_token()
hostname = app.config['REAL_HOSTNAME'] hostname = app.config['REAL_HOSTNAME']
send_email('[Blog] Reset Password', send_email('reset oily password',
sender=app.config['ADMINS'][0], sender=app.config['ADMINS'][0],
recipients=[user.email], recipients=[user.email],
text_body=render_template('email/reset_password.txt', hostname=hostname, user=user, token=token), text_body=render_template('email/reset_password.txt', hostname=hostname, user=user, token=token),

View File

@@ -7,7 +7,7 @@ from app.models import User
class LoginForm(FlaskForm): class LoginForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()]) username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Pasword', validators=[DataRequired()]) password = PasswordField('Password', validators=[DataRequired()])
remember_me = BooleanField('Remember Me') remember_me = BooleanField('Remember Me')
submit = SubmitField('Sign In') submit = SubmitField('Sign In')
@@ -51,7 +51,7 @@ class ResetPasswordRequestForm(FlaskForm):
submit = SubmitField('Request Password Reset') submit = SubmitField('Request Password Reset')
class PostForm(FlaskForm): class PostForm(FlaskForm):
post = TextAreaField('Post:', validators=[DataRequired(), Length(min=1, max=140)]) post = TextAreaField('Post', validators=[DataRequired(), Length(min=1, max=140)])
submit = SubmitField('Submit') submit = SubmitField('Submit')
class EmptyForm(FlaskForm): class EmptyForm(FlaskForm):

View File

@@ -66,7 +66,7 @@ class User(UserMixin, db.Model):
'#5000FF', '#5000FF',
'#FF0030'] '#FF0030']
background = '#151515' background = '#030303'
digest = hashlib.md5(self.email.lower().encode('utf-8')).hexdigest() digest = hashlib.md5(self.email.lower().encode('utf-8')).hexdigest()
basedir = os.path.abspath(os.path.dirname(__file__)) basedir = os.path.abspath(os.path.dirname(__file__))

View File

@@ -37,18 +37,19 @@ def index():
next_url = url_for('index', page=posts.next_num) if posts.has_next else None next_url = url_for('index', page=posts.next_num) if posts.has_next else None
prev_url = url_for('index', page=posts.prev_num) if posts.has_prev else None prev_url = url_for('index', page=posts.prev_num) if posts.has_prev else None
return render_template('index.html', title='Home', form=form, posts=posts.items, next_url=next_url, prev_url=prev_url) return render_template('index.html', title='oily home', form=form, posts=posts.items, next_url=next_url, prev_url=prev_url)
@app.route('/explore') @app.route('/explore')
@login_required @login_required
def explore(): def explore():
query = sa.select(Post).order_by(Post.timestamp.desc()) query = sa.select(Post).order_by(Post.timestamp.desc())
page = request.args.get('page', 1, type=int) page = request.args.get('page', 1, type=int)
posts = db.paginate(query, page=page, per_page=app.config['POSTS_PER_PAGE'], error_out=False) ppp = app.config['POSTS_PER_PAGE'] * 2
posts = db.paginate(query, page=page, per_page=ppp, error_out=False)
next_url = url_for('explore', page=posts.next_num) if posts.has_next else None next_url = url_for('explore', page=posts.next_num) if posts.has_next else None
prev_url = url_for('explore', page=posts.prev_num) if posts.has_prev else None prev_url = url_for('explore', page=posts.prev_num) if posts.has_prev else None
return render_template('index.html', title='Explore', posts=posts.items, next_url=next_url, prev_url=prev_url) return render_template('explore.html', title='oily explore', posts=posts.items, next_url=next_url, prev_url=prev_url)
@app.route('/login', methods=['GET', 'POST']) @app.route('/login', methods=['GET', 'POST'])
def login(): def login():
@@ -65,7 +66,7 @@ def login():
if not next_page or urlsplit(next_page).netloc != '': if not next_page or urlsplit(next_page).netloc != '':
next_page = url_for('index') next_page = url_for('index')
return redirect(next_page) return redirect(next_page)
return render_template('login.html', title='Sign In', form=form) return render_template('login.html', title='oily sign in', form=form)
@app.route('/logout') @app.route('/logout')
def logout(): def logout():
@@ -76,6 +77,9 @@ def logout():
def register(): def register():
if current_user.is_authenticated: if current_user.is_authenticated:
return redirect(url_for('index')) return redirect(url_for('index'))
if not app.config['ALLOW_REGISTRATION'] == "true":
flash('Registration temporarily disabled.')
return redirect(url_for('login'))
form = RegistrationForm() form = RegistrationForm()
if form.validate_on_submit(): if form.validate_on_submit():
user = User(username=form.username.data, email=form.email.data) user = User(username=form.username.data, email=form.email.data)
@@ -85,7 +89,7 @@ def register():
#user.gen_avatar() #user.gen_avatar()
flash('User has been created.') flash('User has been created.')
return redirect(url_for('login')) return redirect(url_for('login'))
return render_template('register.html', title='Register', form=form) return render_template('register.html', title='oily register', form=form)
@app.route('/reset_password/<token>', methods=['GET', 'POST']) @app.route('/reset_password/<token>', methods=['GET', 'POST'])
def reset_password(token): def reset_password(token):
@@ -107,6 +111,7 @@ def reset_password(token):
@login_required @login_required
def user(username): def user(username):
user = db.first_or_404(sa.select(User).where(User.username == username)) user = db.first_or_404(sa.select(User).where(User.username == username))
shortname = (current_user.username[:10] + '...') if len(current_user.username) > 14 else current_user.username
page = request.args.get('page', 1, type=int) page = request.args.get('page', 1, type=int)
query = user.posts.select().order_by(Post.timestamp.desc()) query = user.posts.select().order_by(Post.timestamp.desc())
posts = db.paginate(query, page=page, per_page=app.config['POSTS_PER_PAGE'], error_out=False) posts = db.paginate(query, page=page, per_page=app.config['POSTS_PER_PAGE'], error_out=False)
@@ -114,12 +119,13 @@ def user(username):
prev_url = url_for('user', username=user.username, page=posts.prev_num) if posts.has_prev else None prev_url = url_for('user', username=user.username, page=posts.prev_num) if posts.has_prev else None
form = EmptyForm() form = EmptyForm()
return render_template('user.html', user=user, posts=posts.items, next_url=next_url, prev_url=prev_url, form=form) return render_template('user.html', title='oily profile - '+shortname, user=user, posts=posts.items, next_url=next_url, prev_url=prev_url, form=form)
@app.route('/edit_profile', methods=['GET', 'POST']) @app.route('/edit_profile', methods=['GET', 'POST'])
@login_required @login_required
def edit_profile(): def edit_profile():
form = EditProfileForm(current_user.username) form = EditProfileForm(current_user.username)
shortname = (current_user.username[:10] + '...') if len(current_user.username) > 14 else current_user.username
if form.validate_on_submit(): if form.validate_on_submit():
current_user.username = form.username.data current_user.username = form.username.data
current_user.about_me = form.about_me.data current_user.about_me = form.about_me.data
@@ -129,7 +135,7 @@ def edit_profile():
elif request.method == 'GET': elif request.method == 'GET':
form.username.data = current_user.username form.username.data = current_user.username
form.about_me.data = current_user.about_me form.about_me.data = current_user.about_me
return render_template('edit_profile.html', title='Edit Profile', form=form) return render_template('edit_profile.html', title='oily edit profile - '+shortname, form=form)
@app.route('/follow/<username>', methods=['POST']) @app.route('/follow/<username>', methods=['POST'])
@login_required @login_required
@@ -180,6 +186,6 @@ def reset_password_request():
send_password_reset_email(user) send_password_reset_email(user)
flash('Password reset sent.') flash('Password reset sent.')
return redirect(url_for('login')) return redirect(url_for('login'))
return render_template('reset_password_request.html', title='Reset Password', form=form) return render_template('reset_password_request.html', title='oily password reset', form=form)

View File

@@ -0,0 +1 @@
eee

View File

@@ -2,7 +2,7 @@
{% block content %} {% block content %}
<h1>File Not Found</h1> <h2>File Not Found</h1>
<p><a href="{{ url_for('index') }}">Back</a></p> <p><a href="{{ url_for('index') }}">Back</a></p>
{% endblock %} {% endblock %}

View File

@@ -2,7 +2,7 @@
{% block content %} {% block content %}
<h1>An unexpected error has occurred.</h1> <h2>An unexpected error has occurred.</h1>
<p>Administrator has been notified.</p> <p>Administrator has been notified.</p>
<p><a href="{{ url_for('index') }}">Back</a></p> <p><a href="{{ url_for('index') }}">Back</a></p>

View File

@@ -1,13 +1,11 @@
<table>
<tr style="vertical-align: top;"> <tr style="vertical-align: top;">
<td style="vertical-align: middle; width: 60px;"> <td style="vertical-align: middle; width: 60px;">
<img style="vertical-align: middle; width: 40px;" src="data:image/png;base64,{{ post.author.gen_avatar(write_png=False) }}"> <img style="vertical-align: middle; width: 40px;" src="data:image/png;base64,{{ post.author.gen_avatar(write_png=False) }}">
</td> </td>
<td> <td style="word-break: break-word;">
<a href="{{ url_for('user', username=post.author.username) }}"> <a href="{{ url_for('user', username=post.author.username) }}">
{{ post.author.username }} {{ post.author.username }}
</a> says:<br> </a> says:<br>
{{ post.body }} {{ post.body }}
</td> </td>
</tr> </tr>
</table>

View File

@@ -0,0 +1,14 @@
<div>
{% if prev_url %}
<a class="button" href="{{ prev_url }}">Newer</a>
{% else %}
<a class="button" aria-disabled=true>Newer</a>
{% endif %}
{% if next_url %}
<a class="button" href="{{ next_url }}">Older</a>
{% else %}
<a class="button" aria-disabled=true>Older</a>
{% endif %}
</div>

View File

@@ -3,26 +3,28 @@
<head> <head>
<link rel="stylesheet" href="{{ url_for('static', filename='simple.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='simple.css') }}">
{% if title %} {% if title %}
<title>{{ title }} - blogpage</title> <title>{{ title }}</title>
{% else %} {% else %}
<title>Welcome to blog.</title> <title>oily page</title>
{% endif %} {% endif %}
</head> </head>
<body> <body>
<header> <header>
<nav> <nav>
<a href="{{ url_for('index') }}">home</a> <a {% block indexcurrent %}{% endblock %} href="{{ url_for('index') }}">home</a>
<a href="{{ url_for('explore') }}">explore</a> <a {% block explorecurrent %}{% endblock %} href="{{ url_for('explore') }}">explore</a>
{% if current_user.is_anonymous %} {% if current_user.is_anonymous %}
<a href="{{ url_for('login') }}">login</a> <a {% block logincurrent %}{% endblock %} href="{{ url_for('login') }}">login</a>
{% else %} {% else %}
<a href="{{ url_for('user', username=current_user.username) }}">profile</a> <a {% block profilecurrent %}{% endblock %} href="{{ url_for('user', username=current_user.username) }}">profile</a>
<a href="{{ url_for('logout') }}">logout</a> <a href="{{ url_for('logout') }}">logout</a>
{% endif %} {% endif %}
<a href="https://gut.oily.dad/explore/repos">
<img style="vertical-align: middle; horizontal-align: center; height: 22px" src="https://gut.oily.dad/assets/img/logo.svg" alt="Logo" aria-hidden="true">
</a>
</nav> </nav>
<h1>oily.dad</h1>
<h4>destroy me</h4> <h2>oily.dad</h2>
</header> </header>
<hr> <hr>
{% with messages = get_flashed_messages() %} {% with messages = get_flashed_messages() %}

View File

@@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<h1>Edit Profile</h1> <h2>Edit Profile</h1>
<form action="" method="post"> <form action="" method="post">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
<p> <p>

View File

@@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block explorecurrent %}class="current"{% endblock %}
{% block content %}
{% if form %}
<form action="" method="post">
{{ form.hidden_tag() }}
<p>
{{ form.post.label }}
{{ form.post(cols=32, rows=4) }}
{% for error in form.post.errors %}
<span style="color: red;">[{{ error }}]</span>
{% endfor %}
</p>
<p>{{ form.submit() }}</p>
</form>
{% endif %}
<table>
{% for post in posts %}
{% include '_post.html' %}
{% endfor %}
</table>
{% include '_postnav.html' %}
{% endblock %}

View File

@@ -1,7 +1,8 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block indexcurrent %}class="current"{% endblock %}
{% block content %} {% block content %}
<h1>Hello, {{ current_user.username }}!</h1>
{% if form %} {% if form %}
<form action="" method="post"> <form action="" method="post">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
@@ -15,11 +16,13 @@
<p>{{ form.submit() }}</p> <p>{{ form.submit() }}</p>
</form> </form>
{% endif %} {% endif %}
<table>
{% for post in posts %} {% for post in posts %}
{% include '_post.html' %} {% include '_post.html' %}
{% endfor %} {% endfor %}
{% if prev_url %}<a href="{{ prev_url }}">Newer Posts</a>{% endif %} </table>
{% if next_url %}<a href="{{ next_url }}">Older Posts</a>{% endif %}
{% include '_postnav.html' %}
{% endblock %} {% endblock %}

View File

@@ -1,7 +1,9 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block logincurrent %}class="current"{% endblock %}
{% block content %} {% block content %}
<h1>Sign In</h1> <h2>Sign In</h1>
<form action="" method="post" novalidate> <form action="" method="post" novalidate>
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
<p> <p>
@@ -19,10 +21,12 @@
{% endfor %} {% endfor %}
</p> </p>
<p>{{ form.remember_me() }} {{ form.remember_me.label }}</p> <p>{{ form.remember_me() }} {{ form.remember_me.label }}</p>
<p>{{ form.submit }}</p> <p>
{{ form.submit }}
<a class="button" href="{{ url_for('register') }}">Register</a>
</p>
</form> </form>
<p><a href="{{ url_for('register') }}">Register Here</a></p>
<p><a href="{{ url_for('reset_password_request') }}">Reset Password</a></p> <p><a href="{{ url_for('reset_password_request') }}">Reset Password</a></p>

View File

@@ -2,7 +2,7 @@
{% block content %} {% block content %}
<h1>Register</h1> <h2>Register</h1>
<form action="" method="post"> <form action="" method="post">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
<p> <p>

View File

@@ -2,7 +2,7 @@
{% block content %} {% block content %}
<h1>Reset Your Password</h1> <h2>Reset Your Password</h1>
<form action="" method="post"> <form action="" method="post">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
<p> <p>

View File

@@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<h1>Reset Password</h1> <h2>Reset Password</h1>
<form action="" method="post"> <form action="" method="post">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
<p> <p>

View File

@@ -1,19 +1,17 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block profilecurrent %}class="current"{% endblock %}
{% block content %} {% block content %}
<table> <article>
<tr valign="top"> <h2>
<td style="vertical-align: middle; text-align: center;"> <img style="vertical-align: middle; width: 60px;" src="data:image/png;base64,{{ user.gen_avatar(write_png=False) }}">
<img style="vertical-align: middle;" src="data:image/png;base64,{{ user.gen_avatar(write_png=False) }}"> User: {{ user.username }}
</td> </h2>
<td>
<h1>User: {{ user.username }}</h1>
<h1>CUdebug: {{ current_user }}</h1>
<h1>Udebug: {{ user }}</h1>
{% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %} {% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %}
{% if user.last_seen %}<p>Last activity:{{ user.last_seen }}</p>{% endif %} {% if user.last_seen %}<p>Last activity: {{ user.last_seen }}</p>{% endif %}
{% if user == current_user %} {% if user == current_user %}
<p><a href="{{ url_for('edit_profile') }}">Edit Profile</a></p> <p><a class="button" href="{{ url_for('edit_profile') }}">Edit Profile</a></p>
{% elif not current_user.is_following(user) %} {% elif not current_user.is_following(user) %}
<p> <p>
<form action="{{ url_for('follow', username=user.username) }}" method="post"> <form action="{{ url_for('follow', username=user.username) }}" method="post">
@@ -29,17 +27,16 @@
</form> </form>
</p> </p>
{% endif %} {% endif %}
</article>
</td>
</tr>
</table>
<hr> <hr>
<table>
{% for post in posts %} {% for post in posts %}
{% include '_post.html' %} {% include '_post.html' %}
{% endfor %} {% endfor %}
{% if prev_url %}<a href="{{ prev_url }}">Newer Posts</a>{% endif %} </table>
{% if next_url %}<a href="{{ next_url }}">Older Posts</a>{% endif %}
{% include '_postnav.html' %}
{% endblock %} {% endblock %}

View File

@@ -16,6 +16,7 @@ class Config:
ADMINS = [os.environ.get('DOTENV_ADMIN_EMAIL')] ADMINS = [os.environ.get('DOTENV_ADMIN_EMAIL')]
FROM_ADDRESS = os.environ.get('DOTENV_FROM_ADDRESS') FROM_ADDRESS = os.environ.get('DOTENV_FROM_ADDRESS')
REAL_HOSTNAME = os.environ.get('DOTENV_REAL_HOSTNAME') REAL_HOSTNAME = os.environ.get('DOTENV_REAL_HOSTNAME')
ALLOW_REGISTRATION = os.environ.get('DOTENV_ALLOW_REGISTRATION')
DC_LOGGING = True DC_LOGGING = True

View File

@@ -1,28 +1,28 @@
alembic==1.13.2 alembic
blinker==1.8.2 blinker
click==8.1.7 click
dnspython==2.6.1 dnspython
email_validator==2.2.0 email_validator
Flask==3.0.3 Flask
Flask-Login==0.6.3 Flask-Login
Flask-Mail==0.10.0 Flask-Mail
Flask-Migrate==4.0.7 Flask-Migrate
Flask-SQLAlchemy==3.1.1 Flask-SQLAlchemy
Flask-WTF==1.2.1 Flask-WTF
greenlet==3.0.3 greenlet
idna==3.7 idna
itsdangerous==2.2.0 itsdangerous
Jinja2==3.1.4 Jinja2
Mako==1.3.5 Mako
mariadb==1.1.10 mariadb
MarkupSafe==2.1.5 MarkupSafe
packaging==24.1 packaging
pillow==10.4.0 pillow
pydenticon==0.3.1 pydenticon
PyJWT==2.9.0 PyJWT
python-dotenv==1.0.1 python-dotenv
SQLAlchemy==2.0.31 SQLAlchemy
typing_extensions==4.12.2 typing_extensions
uWSGI==2.0.26 uWSGI
Werkzeug==3.0.3 Werkzeug
WTForms==3.1.2 WTForms

View File

@@ -0,0 +1,28 @@
alembic==1.13.2
blinker==1.8.2
click==8.1.7
dnspython==2.6.1
email_validator==2.2.0
Flask==3.0.3
Flask-Login==0.6.3
Flask-Mail==0.10.0
Flask-Migrate==4.0.7
Flask-SQLAlchemy==3.1.1
Flask-WTF==1.2.1
greenlet==3.0.3
idna==3.7
itsdangerous==2.2.0
Jinja2==3.1.4
Mako==1.3.5
mariadb==1.1.10
MarkupSafe==2.1.5
packaging==24.1
pillow==10.4.0
pydenticon==0.3.1
PyJWT==2.9.0
python-dotenv==1.0.1
SQLAlchemy==2.0.31
typing_extensions==4.12.2
uWSGI==2.0.28
Werkzeug==3.0.3
WTForms==3.1.2

View File

@@ -1,25 +1,23 @@
services: services:
db: db:
image: mariadb:lts image: mariadb:lts
command: "--skip-name-resolve=OFF"
restart: always restart: always
healthcheck: healthcheck:
#test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 --password="${DOTENV_MYSQL_ROOT_PASSWORD}" --silent']
test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized'] test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
interval: 10s interval: 10s
retries: 5 retries: 5
timeout: 5s timeout: 5s
start_period: 10s start_period: 5s
volumes: volumes:
- db-data:/var/lib/mysql - db-data:/var/lib/mysql
- ./db/init:/docker-entrypoint-initdb.d/ - ./db/init:/docker-entrypoint-initdb.d/
- ./db/bu:/bu
networks: networks:
- backnet - backnet
environment: environment:
#- MYSQL_DATABASE=gitea - MARIADB_ROOT_HOST=localhost
#- MYSQL_USER=gitea - MARIADB_ROOT_PASSWORD=${DOTENV_MYSQL_ROOT_PASSWORD}
#- MYSQL_PASSWORD=gitea
#- MYSQL_ROOT_PASSWORD=rootpass
- MYSQL_ROOT_PASSWORD=${DOTENV_MYSQL_ROOT_PASSWORD}
expose: expose:
- 3306 - 3306
- 33060 - 33060
@@ -29,11 +27,12 @@ services:
context: backend context: backend
target: builder target: builder
# Next two are only debug, used without restart # Next two are only debug, used without restart
stdin_open: true #stdin_open: true
tty: true #tty: true
#restart: always restart: always
# Comment following line to use flask (1worker, dev), uncomment to use uwsgi (wsgi) # Comment following line to use flask (1worker, dev), uncomment to use uwsgi (wsgi)
#command: ["uwsgi", "--http", "0.0.0.0:8000", "--master", "-p", "4", "-w", "microblog:app"] #command: ["uwsgi", "--http", "0.0.0.0:8000", "--master", "-p", "4", "--buffer-size", "16384", "--limit-as", "2048", "-w", "microblog:app"]
container_name: backend
environment: environment:
- MYSQL_USER=flasku - MYSQL_USER=flasku
#- MYSQL_PASSWORD=flaskp #- MYSQL_PASSWORD=flaskp
@@ -45,6 +44,7 @@ services:
- DOTENV_FROM_ADDRESS=${FLASK_MAIL_FROM} - DOTENV_FROM_ADDRESS=${FLASK_MAIL_FROM}
- DOTENV_JWT_PHRASE=${FLASK_JWT_PHRASE} - DOTENV_JWT_PHRASE=${FLASK_JWT_PHRASE}
- DOTENV_REAL_HOSTNAME=${FLASK_REAL_HOSTNAME} - DOTENV_REAL_HOSTNAME=${FLASK_REAL_HOSTNAME}
- DOTENV_ALLOW_REGISTRATION=${ALLOW_REGISTRATION}
#ports: #ports:
# - 8000:8000 # - 8000:8000
expose: expose:
@@ -75,10 +75,13 @@ services:
- GITEA__mailer__PROTOCOL=smtp - GITEA__mailer__PROTOCOL=smtp
- GITEA__mailer__SMTP_ADDR=pmb - GITEA__mailer__SMTP_ADDR=pmb
- GITEA__mailer__SMTP_PORT=25 - GITEA__mailer__SMTP_PORT=25
- GITEA__service__REGISTER_EMAIL_CONFIRM=true - GITEA__service__REGISTER_EMAIL_CONFIRM=false
- GITEA__service__REGISTER_MANUAL_CONFIRM=true
- GITEA__service__ENABLE_NOTIFY_MAIL=true - GITEA__service__ENABLE_NOTIFY_MAIL=true
- GITEA__server__LANDING_PAGE=explore
- GITEA__ui__REACTIONS="+1, -1, fu, heart, laugh, confused, hooray, eyes, gun, boom, poop, kiss, rocket, bomb, chart_with_downwards_trend, eggplant"
# To disable new users after setup: # To disable new users after setup:
#- GITEA__service__DISABLE_REGISTRATION=false - GITEA__service__DISABLE_REGISTRATION=true
networks: networks:
- backnet - backnet
- frontnet - frontnet
@@ -96,12 +99,22 @@ services:
proxy: proxy:
build: proxy build: proxy
restart: always restart: always
#volumes: volumes:
# - /home/finn/d/cert/var/lib/letsencrypt:/var/lib/letsencrypt - /home/finn/d/cert/var/lib/letsencrypt:/var/lib/letsencrypt:ro
# - /home/finn/d/cert/etc/letsencrypt:/etc/letsencrypt - /home/finn/d/cert/etc/letsencrypt:/etc/letsencrypt:ro
ports: ports:
- 80:80 - "80:80"
- 443:443 - "443:443"
depends_on:
- backend
networks:
- frontnet
hs:
container_name: tor_service
build:
context: tor
environment:
- USE_TOR=${USE_TOR}
depends_on: depends_on:
- backend - backend
networks: networks:
@@ -125,10 +138,54 @@ services:
networks: networks:
- backnet - backnet
stump:
image: aaronleopold/stump
#image: aaronleopold/stump:nightly
container_name: stump
# Replace my paths (prior to the colons) with your own
volumes:
- ./stump:/config
#- /mnt/hub/rocky-remote/st/rockybookshare/:/rocky-remote
#- /mnt/hub/rocky-remote/st/briebookshare/:/rocky-redundant
#- /mnt/hub/brie-remote/st/bookshare:/brie-remote
- /home/armbian/mnt/gouda/st/data/:/bookshare/gouda
- /home/armbian/mnt/rocky/st/data/:/bookshare/rocky
#ports:
# - 10801:10801
environment:
- PUID=1000
- PGID=1000
- STUMP_ENABLE_UPLOAD=true
- ENABLE_KOREADER_SYNC=true
- ENABLE_OPDS_PROGRESSION=true
- STUMP_MAX_SCANNER_CONCURRENCY=2
- STUMP_MAX_THUMBNAIL_CONCURRENCY=1
- STUMP_VERBOSITY=1
restart: unless-stopped
networks:
- frontnet
- backnet
sshtun:
build:
context: sshtun
dockerfile: Dockerfile
restart: on-failure
environment:
- USE_TUN=${USE_TUN}
ports:
- "22222:22"
expose:
- "11112"
networks:
- frontnet
volumes: volumes:
db-data: db-data:
pmb-root: pmb-root:
networks: networks:
backnet: backnet:
name: backnet
frontnet: frontnet:
name: frontnet

View File

@@ -1,25 +1,23 @@
services: services:
db: db:
image: mariadb:lts image: mariadb:lts
command: "--skip-name-resolve=OFF"
restart: always restart: always
healthcheck: healthcheck:
#test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 --password="${DOTENV_MYSQL_ROOT_PASSWORD}" --silent']
test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized'] test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
interval: 10s interval: 10s
retries: 5 retries: 5
timeout: 5s timeout: 5s
start_period: 10s start_period: 5s
volumes: volumes:
- db-data:/var/lib/mysql - db-data:/var/lib/mysql
- ./db/init:/docker-entrypoint-initdb.d/ - ./db/init:/docker-entrypoint-initdb.d/
- ./db/bu:/bu
networks: networks:
- backnet - backnet
environment: environment:
#- MYSQL_DATABASE=gitea - MARIADB_ROOT_HOST=localhost
#- MYSQL_USER=gitea - MARIADB_ROOT_PASSWORD=${DOTENV_MYSQL_ROOT_PASSWORD}
#- MYSQL_PASSWORD=gitea
#- MYSQL_ROOT_PASSWORD=rootpass
- MYSQL_ROOT_PASSWORD=${DOTENV_MYSQL_ROOT_PASSWORD}
expose: expose:
- 3306 - 3306
- 33060 - 33060
@@ -29,11 +27,12 @@ services:
context: backend context: backend
target: builder target: builder
# Next two are only debug, used without restart # Next two are only debug, used without restart
stdin_open: true #stdin_open: true
tty: true #tty: true
#restart: always restart: always
# Comment following line to use flask (1worker, dev), uncomment to use uwsgi (wsgi) # Comment following line to use flask (1worker, dev), uncomment to use uwsgi (wsgi)
#command: ["uwsgi", "--http", "0.0.0.0:8000", "--master", "-p", "4", "-w", "microblog:app"] #command: ["uwsgi", "--http", "0.0.0.0:8000", "--master", "-p", "4", "-w", "microblog:app"]
container_name: backend
environment: environment:
- MYSQL_USER=flasku - MYSQL_USER=flasku
#- MYSQL_PASSWORD=flaskp #- MYSQL_PASSWORD=flaskp
@@ -45,6 +44,7 @@ services:
- DOTENV_FROM_ADDRESS=${FLASK_MAIL_FROM} - DOTENV_FROM_ADDRESS=${FLASK_MAIL_FROM}
- DOTENV_JWT_PHRASE=${FLASK_JWT_PHRASE} - DOTENV_JWT_PHRASE=${FLASK_JWT_PHRASE}
- DOTENV_REAL_HOSTNAME=${FLASK_REAL_HOSTNAME} - DOTENV_REAL_HOSTNAME=${FLASK_REAL_HOSTNAME}
- DOTENV_ALLOW_REGISTRATION=${ALLOW_REGISTRATION}
#ports: #ports:
# - 8000:8000 # - 8000:8000
expose: expose:
@@ -75,10 +75,13 @@ services:
- GITEA__mailer__PROTOCOL=smtp - GITEA__mailer__PROTOCOL=smtp
- GITEA__mailer__SMTP_ADDR=pmb - GITEA__mailer__SMTP_ADDR=pmb
- GITEA__mailer__SMTP_PORT=25 - GITEA__mailer__SMTP_PORT=25
- GITEA__service__REGISTER_EMAIL_CONFIRM=true - GITEA__service__REGISTER_EMAIL_CONFIRM=false
- GITEA__service__REGISTER_MANUAL_CONFIRM=true
- GITEA__service__ENABLE_NOTIFY_MAIL=true - GITEA__service__ENABLE_NOTIFY_MAIL=true
- GITEA__server__LANDING_PAGE=explore
- GITEA__ui__REACTIONS="+1, -1, fu, heart, laugh, confused, hooray, eyes, gun, boom, poop, kiss, rocket, bomb, chart_with_downwards_trend, eggplant"
# To disable new users after setup: # To disable new users after setup:
#- GITEA__service__DISABLE_REGISTRATION=false - GITEA__service__DISABLE_REGISTRATION=false
networks: networks:
- backnet - backnet
- frontnet - frontnet
@@ -97,11 +100,21 @@ services:
build: proxy build: proxy
restart: always restart: always
#volumes: #volumes:
# - /home/finn/d/cert/var/lib/letsencrypt:/var/lib/letsencrypt # - /home/finn/d/cert/var/lib/letsencrypt:/var/lib/letsencrypt:ro
# - /home/finn/d/cert/etc/letsencrypt:/etc/letsencrypt # - /home/finn/d/cert/etc/letsencrypt:/etc/letsencrypt:ro
ports: ports:
- 80:80 - "80:80"
- 443:443 - "443:443"
depends_on:
- backend
networks:
- frontnet
hs:
container_name: tor_service
build:
context: tor
environment:
- USE_TOR=${USE_TOR}
depends_on: depends_on:
- backend - backend
networks: networks:
@@ -125,10 +138,26 @@ services:
networks: networks:
- backnet - backnet
sshtun:
build:
context: sshtun
dockerfile: Dockerfile
restart: on-failure
environment:
- USE_TUN=${USE_TUN}
ports:
- "22222:22"
expose:
- "11112"
networks:
- frontnet
volumes: volumes:
db-data: db-data:
pmb-root: pmb-root:
networks: networks:
backnet: backnet:
name: backnet
frontnet: frontnet:
name: frontnet

View File

@@ -1,25 +1,23 @@
services: services:
db: db:
image: mariadb:lts image: mariadb:lts
command: "--skip-name-resolve=OFF"
restart: always restart: always
healthcheck: healthcheck:
#test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 --password="${DOTENV_MYSQL_ROOT_PASSWORD}" --silent']
test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized'] test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
interval: 10s interval: 10s
retries: 5 retries: 5
timeout: 5s timeout: 5s
start_period: 10s start_period: 5s
volumes: volumes:
- db-data:/var/lib/mysql - db-data:/var/lib/mysql
- ./db/init:/docker-entrypoint-initdb.d/ - ./db/init:/docker-entrypoint-initdb.d/
- ./db/bu:/bu
networks: networks:
- backnet - backnet
environment: environment:
#- MYSQL_DATABASE=gitea - MARIADB_ROOT_HOST=localhost
#- MYSQL_USER=gitea - MARIADB_ROOT_PASSWORD=${DOTENV_MYSQL_ROOT_PASSWORD}
#- MYSQL_PASSWORD=gitea
#- MYSQL_ROOT_PASSWORD=rootpass
- MYSQL_ROOT_PASSWORD=${DOTENV_MYSQL_ROOT_PASSWORD}
expose: expose:
- 3306 - 3306
- 33060 - 33060
@@ -34,6 +32,7 @@ services:
restart: always restart: always
# Comment following line to use flask (1worker, dev), uncomment to use uwsgi (wsgi) # Comment following line to use flask (1worker, dev), uncomment to use uwsgi (wsgi)
command: ["uwsgi", "--http", "0.0.0.0:8000", "--master", "-p", "4", "-w", "microblog:app"] command: ["uwsgi", "--http", "0.0.0.0:8000", "--master", "-p", "4", "-w", "microblog:app"]
container_name: backend
environment: environment:
- MYSQL_USER=flasku - MYSQL_USER=flasku
#- MYSQL_PASSWORD=flaskp #- MYSQL_PASSWORD=flaskp
@@ -45,6 +44,7 @@ services:
- DOTENV_FROM_ADDRESS=${FLASK_MAIL_FROM} - DOTENV_FROM_ADDRESS=${FLASK_MAIL_FROM}
- DOTENV_JWT_PHRASE=${FLASK_JWT_PHRASE} - DOTENV_JWT_PHRASE=${FLASK_JWT_PHRASE}
- DOTENV_REAL_HOSTNAME=${FLASK_REAL_HOSTNAME} - DOTENV_REAL_HOSTNAME=${FLASK_REAL_HOSTNAME}
- DOTENV_ALLOW_REGISTRATION=${ALLOW_REGISTRATION}
#ports: #ports:
# - 8000:8000 # - 8000:8000
expose: expose:
@@ -75,10 +75,13 @@ services:
- GITEA__mailer__PROTOCOL=smtp - GITEA__mailer__PROTOCOL=smtp
- GITEA__mailer__SMTP_ADDR=pmb - GITEA__mailer__SMTP_ADDR=pmb
- GITEA__mailer__SMTP_PORT=25 - GITEA__mailer__SMTP_PORT=25
- GITEA__service__REGISTER_EMAIL_CONFIRM=true - GITEA__service__REGISTER_EMAIL_CONFIRM=false
- GITEA__service__REGISTER_MANUAL_CONFIRM=true
- GITEA__service__ENABLE_NOTIFY_MAIL=true - GITEA__service__ENABLE_NOTIFY_MAIL=true
- GITEA__server__LANDING_PAGE=explore
- GITEA__ui__REACTIONS="+1, -1, fu, heart, laugh, confused, hooray, eyes, gun, boom, poop, kiss, rocket, bomb, chart_with_downwards_trend, eggplant"
# To disable new users after setup: # To disable new users after setup:
#- GITEA__service__DISABLE_REGISTRATION=false - GITEA__service__DISABLE_REGISTRATION=false
networks: networks:
- backnet - backnet
- frontnet - frontnet
@@ -96,12 +99,22 @@ services:
proxy: proxy:
build: proxy build: proxy
restart: always restart: always
#volumes: volumes:
# - /home/finn/d/cert/var/lib/letsencrypt:/var/lib/letsencrypt - /home/finn/d/cert/var/lib/letsencrypt:/var/lib/letsencrypt:ro
# - /home/finn/d/cert/etc/letsencrypt:/etc/letsencrypt - /home/finn/d/cert/etc/letsencrypt:/etc/letsencrypt:ro
ports: ports:
- 80:80 - "80:80"
- 443:443 - "443:443"
depends_on:
- backend
networks:
- frontnet
hs:
container_name: tor_service
build:
context: tor
environment:
- USE_TOR=${USE_TOR}
depends_on: depends_on:
- backend - backend
networks: networks:
@@ -125,10 +138,26 @@ services:
networks: networks:
- backnet - backnet
sshtun:
build:
context: sshtun
dockerfile: Dockerfile
restart: on-failure
environment:
- USE_TUN=${USE_TUN}
ports:
- "22222:22"
expose:
- "11112"
networks:
- frontnet
volumes: volumes:
db-data: db-data:
pmb-root: pmb-root:
networks: networks:
backnet: backnet:
name: backnet
frontnet: frontnet:
name: frontnet

View File

@@ -3,10 +3,10 @@ CREATE DATABASE IF NOT EXISTS `gitea`;
CREATE DATABASE IF NOT EXISTS `flask`; CREATE DATABASE IF NOT EXISTS `flask`;
-- create root user and grant rights -- create root user and grant rights
CREATE USER 'gitea' IDENTIFIED BY 'giteap'; CREATE USER 'gitea'@'gitea.backnet' IDENTIFIED BY 'giteap';
CREATE USER 'flasku' IDENTIFIED BY 'flaskp'; CREATE USER 'flasku'@'backend.backnet' IDENTIFIED BY 'flaskp';
--CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'gitea'; --CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'gitea';
--GRANT ALL ON `gitea` TO 'gitea'@'localhost'; --GRANT ALL ON `gitea` TO 'gitea'@'localhost';
GRANT ALL ON gitea.* TO 'gitea'; GRANT ALL ON gitea.* TO 'gitea'@'gitea.backnet';
GRANT ALL ON flask.* TO 'flasku'; GRANT ALL ON flask.* TO 'flasku'@'backend.backnet';

33
dotenv
View File

@@ -1,27 +1,34 @@
# Example .env file # Example .env file
DOTENV_MYSQL_ROOT_PASSWORD_OLD=rootp DOTENV_MYSQL_ROOT_PASSWORD_OLD="rootp"
DOTENV_MYSQL_ROOT_PASSWORD=rootp DOTENV_MYSQL_ROOT_PASSWORD="rootp"
DOTENV_MYSQL_GITEA_PASSWORD=giteap DOTENV_MYSQL_GITEA_PASSWORD="giteap"
DOTENV_MYSQL_FLASK_PASSWORD=flaskp DOTENV_MYSQL_FLASK_PASSWORD="flaskp"
GITEA_MAIL_FROM="git@changeme" GITEA_MAIL_FROM="git@aaa"
# Build ARG GPG_PP. May still need to be empty to avoid breakage. # Build ARG GPG_PP. May still need to be empty to avoid breakage.
BUILD_GPG_PP= BUILD_GPG_PP=
# Tor:
# true/false:
USE_TOR=false
# SSH Tun:
# true/false:
USE_TUN=false
# Backend: # Backend:
FLASK_SECRET_KEY="flaskkey"
FLASK_SECRET_KEY="changeme"
# Inconsequential token: minimal inconvenience if exposed # Inconsequential token: minimal inconvenience if exposed
FLASK_TOKEN_I=dti FLASK_TOKEN_I="dti"
# Consequential token: protect # Consequential token: protect
FLASK_TOKEN_C=dtc FLASK_TOKEN_C="dtc"
# true/false:
FLASK_MAIL_FROM="git@changeme" ALLOW_REGISTRATION=true
FLASK_MAIL_FROM="git@aaa"
# admin email must be valid send from with mail subsystem # admin email must be valid send from with mail subsystem
FLASK_ADMIN_EMAIL="git@changeme" FLASK_ADMIN_EMAIL="git@aaa"
FLASK_JWT_PHRASE="jwtphrase" FLASK_JWT_PHRASE="jwtphrase"
FLASK_REAL_HOSTNAME="localhost" FLASK_REAL_HOSTNAME="localhost"

5
ls_rclone.sh Normal file
View File

@@ -0,0 +1,5 @@
rclone ls :sftp: \
--sftp-host=localhost \
--sftp-port=11111 \
--sftp-user=armbian \
--sftp-key-file=/home/armbian/.ssh/armbian-brie-202604

27
other/dbbu.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
# dump sql db backups
#
if [[ -z $1 ]] ; then
echo "dbbu.sh <gitea|flask|all>"
exit 0
fi
source ../.env
source .env
TIMESTAMP=$(date +%s)
if [[ $1 == "gitea" || $1 == "all" ]] ; then
docker-compose exec db bash -c "mariadb-dump -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD gitea > /bu/gitea_bu_$TIMESTAMP.sql"
docker-compose exec db chmod a+rw /bu/gitea_bu_$TIMESTAMP.sql
docker-compose exec db chown ubuntu:ubuntu /bu/gitea_bu_$TIMESTAMP.sql
fi
if [[ $1 == "flask" || $1 == "all" ]] ; then
docker-compose exec db echo $DOTENV_MYSQL_ROOT_PASSWORD
docker-compose exec db bash -c "mariadb-dump -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD flask > /bu/flask_bu_$TIMESTAMP.sql"
docker-compose exec db chmod a+rw /bu/flask_bu_$TIMESTAMP.sql
docker-compose exec db chown ubuntu:ubuntu /bu/flask_bu_$TIMESTAMP.sql
fi

View File

@@ -19,10 +19,10 @@ echo "Changing app db passwords in 5 seconds..."
sleep 6 sleep 6
# Flask # Flask
docker-compose exec db mariadb --database=mysql -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD_OLD -e "ALTER USER 'flasku' IDENTIFIED BY '"$DOTENV_MYSQL_FLASK_PASSWORD"';" docker-compose exec db mariadb --database=mysql -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD_OLD -e "ALTER USER 'flasku'@'backend.backnet' IDENTIFIED BY '"$DOTENV_MYSQL_FLASK_PASSWORD"';"
# Gitea # Gitea
docker-compose exec db mariadb --database=mysql -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD_OLD -e "ALTER USER 'gitea' IDENTIFIED BY '"$DOTENV_MYSQL_GITEA_PASSWORD"';" docker-compose exec db mariadb --database=mysql -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD_OLD -e "ALTER USER 'gitea'@'gitea.backnet' IDENTIFIED BY '"$DOTENV_MYSQL_GITEA_PASSWORD"';"
docker-compose exec db mariadb --database=mysql -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD_OLD -e "FLUSH PRIVILEGES;" docker-compose exec db mariadb --database=mysql -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD_OLD -e "FLUSH PRIVILEGES;"

72
proxy/Caddyfile Normal file
View File

@@ -0,0 +1,72 @@
# Global options
{
# Disable auto HTTPS since we're using existing certificates
auto_https off
}
# HTTP to HTTPS redirect
:80 {
redir https://{host}{uri} permanent
}
# Main domain - oily.dad and www.oily.dad
oily.dad, www.oily.dad {
# Root directory (not strictly needed for reverse proxy)
root * /var/www/html
# Use existing SSL certificates
tls /etc/letsencrypt/live/oily.dad/fullchain.pem /etc/letsencrypt/live/oily.dad/privkey.pem
# Onion-Location header
header Onion-Location http://oilydada7ckiseinkbeathsefwgkvjrce743xy7x7iiybkuxh4vheead.onion{path}
# Reverse proxy to backend
reverse_proxy http://backend:8000 {
# Preserve original host header
header_up Host {host}
header_up X-Real-IP {remote}
# X-Forwarded-For and X-Forwarded-Proto are set automatically by Caddy
}
}
# Subdomain for Gitea - gut.oily.dad
gut.oily.dad {
# Use existing SSL certificates
tls /etc/letsencrypt/live/oily.dad/fullchain.pem /etc/letsencrypt/live/oily.dad/privkey.pem
# Reverse proxy to Gitea
reverse_proxy http://gitea:3000 {
# WebSocket support for Gitea
header_up Connection {>Connection}
header_up Upgrade {>Upgrade}
# Preserve original headers
header_up Host {host}
header_up X-Real-IP {remote}
# X-Forwarded-For and X-Forwarded-Proto are set automatically by Caddy
}
}
# Subdomain for Stump - stump.oily.dad
stump.oily.dad {
# kavita supports gzip seems to work with stump
encode gzip
# Use existing SSL certificates
tls /etc/letsencrypt/live/oily.dad/fullchain.pem /etc/letsencrypt/live/oily.dad/privkey.pem
# Reverse proxy to Stump
reverse_proxy http://stump:10801 {
#reverse_proxy http://kavita:5000 {
# WebSocket support for Stump (if needed)
header_up Connection {>Connection}
header_up Upgrade {>Upgrade}
# Preserve original headers
header_up Host {host}
header_up X-Real-IP {remote}
# X-Forwarded-For and X-Forwarded-Proto are set automatically by Caddy
}
}

65
proxy/Caddyfile.maybeno Normal file
View File

@@ -0,0 +1,65 @@
# Global options
{
# Disable auto HTTPS since we're using existing certificates
auto_https off
}
# HTTP to HTTPS redirect
:80 {
redir https://{host}{uri} permanent
}
# Main domain - oily.dad and www.oily.dad
oily.dad, www.oily.dad {
# Root directory (not strictly needed for reverse proxy)
root * /var/www/html
# Use existing SSL certificates
tls /etc/letsencrypt/live/oily.dad/fullchain.pem /etc/letsencrypt/live/oily.dad/privkey.pem
# Onion-Location header
header Onion-Location http://oilydada7ckiseinkbeathsefwgkvjrce743xy7x7iiybkuxh4vheead.onion{path}
# Reverse proxy to backend
reverse_proxy http://backend:8000 {
# Preserve original host header
header_up Host {host}
header_up X-Real-IP {remote}
# X-Forwarded-For and X-Forwarded-Proto are set automatically by Caddy
}
}
# Subdomain for Gitea - gut.oily.dad
gut.oily.dad {
# Root directory (not strictly needed for reverse proxy)
root * /var/www/html
# Use existing SSL certificates
tls /etc/letsencrypt/live/oily.dad/fullchain.pem /etc/letsencrypt/live/oily.dad/privkey.pem
# Reverse proxy to Gitea
reverse_proxy http://gitea:3000 {
# WebSocket support for Gitea
header_up Connection {>Connection}
header_up Upgrade {>Upgrade}
# Preserve original headers
header_up Host {host}
header_up X-Real-IP {remote}
# X-Forwarded-For and X-Forwarded-Proto are set automatically by Caddy
}
}
# Subdomain for Stump (comics/books) - book.oily.dad
book.oily.dad {
# Root directory (not strictly needed for reverse proxy)
root * /var/www/html
# Use existing SSL certificates
tls /etc/letsencrypt/live/oily.dad/fullchain.pem /etc/letsencrypt/live/oily.dad/privkey.pem
# Reverse proxy to Stump
#reverse_proxy http://stump:10801 {
reverse_proxy http://kavita:5000
}

74
proxy/Caddyfile.old Normal file
View File

@@ -0,0 +1,74 @@
# Global options
{
# Disable auto HTTPS since we're using existing certificates
auto_https off
}
# HTTP to HTTPS redirect
:80 {
redir https://{host}{uri} permanent
}
# Main domain - oily.dad and www.oily.dad
oily.dad, www.oily.dad {
# Root directory (not strictly needed for reverse proxy)
root * /var/www/html
# Use existing SSL certificates
tls /etc/letsencrypt/live/oily.dad/fullchain.pem /etc/letsencrypt/live/oily.dad/privkey.pem
# Onion-Location header
header Onion-Location http://oilydada7ckiseinkbeathsefwgkvjrce743xy7x7iiybkuxh4vheead.onion{path}
# Reverse proxy to backend
reverse_proxy http://backend:8000 {
# Preserve original host header
header_up Host {host}
header_up X-Real-IP {remote}
# X-Forwarded-For and X-Forwarded-Proto are set automatically by Caddy
}
}
# Subdomain for Gitea - gut.oily.dad
gut.oily.dad {
# Root directory (not strictly needed for reverse proxy)
root * /var/www/html
# Use existing SSL certificates
tls /etc/letsencrypt/live/oily.dad/fullchain.pem /etc/letsencrypt/live/oily.dad/privkey.pem
# Reverse proxy to Gitea
reverse_proxy http://gitea:3000 {
# WebSocket support for Gitea
header_up Connection {>Connection}
header_up Upgrade {>Upgrade}
# Preserve original headers
header_up Host {host}
header_up X-Real-IP {remote}
# X-Forwarded-For and X-Forwarded-Proto are set automatically by Caddy
}
}
# Subdomain for Stump (comics/books) - book.oily.dad
book.oily.dad {
# Root directory (not strictly needed for reverse proxy)
root * /var/www/html
# Use existing SSL certificates
tls /etc/letsencrypt/live/oily.dad/fullchain.pem /etc/letsencrypt/live/oily.dad/privkey.pem
# Reverse proxy to Stump
#reverse_proxy http://stump:10801 {
reverse_proxy http://kavita:5000 {
# WebSocket support for Stump (if needed)
header_up Connection {>Connection}
header_up Upgrade {>Upgrade}
# Preserve original headers
header_up Host {host}
header_up X-Real-IP {remote}
# X-Forwarded-For and X-Forwarded-Proto are set automatically by Caddy
}
}

View File

@@ -1,2 +1,10 @@
FROM nginx:alpine FROM caddy:alpine
COPY conf /etc/nginx/conf.d/default.conf
# Copy Caddyfile configuration
COPY Caddyfile /etc/caddy/Caddyfile
# Create directory for www root
RUN mkdir -p /var/www/html
# Caddy runs as non-root user by default
# Ports 80 and 443 are exposed by the base image

View File

@@ -1,12 +0,0 @@
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://backend:8000;
}
location /gutty{
proxy_pass http://gitea:3000;
}
}

View File

@@ -1,12 +0,0 @@
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://backend:8000;
}
location /gutty {
proxy_pass http://gitea:3000;
}
}

View File

@@ -1,52 +0,0 @@
#server {
# listen 80;
# server_name localhost;
# location / {
# proxy_pass http://backend:8000;
# }
# always redirect to https
server {
listen 80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
# use the certificates
ssl_certificate /etc/letsencrypt/live/oily.dad/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oily.dad/privkey.pem;
server_name oily.dad www.oily.dad;
root /var/www/html;
index index.php index.html index.htm;
location / {
proxy_pass http://backend:8000/;
}
}
server {
listen 443 ssl http2;
# use the certificates
ssl_certificate /etc/letsencrypt/live/oily.dad/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oily.dad/privkey.pem;
server_name gut.oily.dad;
root /var/www/html;
index index.php index.html index.htm;
location / {
client_max_body_size 512M;
#proxy_pass http://localhost:3000;
proxy_set_header Connection $http_connection;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://gitea:3000/;
}
}

23
sshtun/Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
FROM debian:13-slim
RUN apt update
RUN apt install -y \
openssh-server \
socat
RUN adduser --disabled-password --gecos "" armbian
# ssh:
RUN mkdir /home/armbian/.ssh
# only one pubkey -- wildcard just to conceal filename
COPY ./oilykey/*.pub /home/armbian/.ssh/authorized_keys
COPY ./oilykey/* /home/armbian/.ssh/
RUN chown -R armbian:armbian /home/armbian/.ssh/
RUN chmod 600 /home/armbian/.ssh/*
#RUN mkdir /var/run/sshd
RUN echo "PermitRootLogin no" >> /etc/ssh/sshd_config
RUN echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
COPY ./entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]

14
sshtun/entrypoint.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
# Container goal: egress
# first: physical_box$ autossh -N -R 11111:localhost:11434 -i sshtun/oilykey/<SOMEKEY> -p 22222 <rem_vps_url>
# will forward rem_c_port:physical_box:physical_box_port ...some args... rem_vps_p rem_vps_url
# then: frontnet_c$ curl sshtun.frontnet:11112 --> physical_box:11434
if $USE_TUN ; then
echo "@@@@@@@@@@ SSH TUNNEL ENABLED BY ENV"
nohup socat TCP-LISTEN:11112,fork TCP:localhost:11111 &
/usr/sbin/sshd -De
else
echo "@@@@@@@@@@ SSH TUNNEL DISABLED BY ENV"
fi

8
sshtun/manual_rclone.sh Executable file
View File

@@ -0,0 +1,8 @@
rclone mount :sftp: /armbian/briemount \
--sftp-host=localhost \
--sftp-port=11111 \
--sftp-user=armbian \
--sftp-key-file=/home/armbian/.ssh/armbian-brie-202604 \
--vfs-cache-mode off \
--allow-other \
--daemon

20
tor/Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
FROM alpine
RUN adduser --disabled-password --gecos "" tor
RUN apk update && apk add tor
COPY hidden_service /hidden_service
COPY torrc /etc/tor/torrc
COPY entrypoint.sh /
RUN chown -R tor /etc/tor
RUN chown -R tor /hidden_service
RUN chown -R tor /entrypoint.sh
RUN chmod -R go-rwx /etc/tor
RUN chmod -R go-rwx /hidden_service
USER tor
ENTRYPOINT ["/entrypoint.sh"]

5
tor/README.md Normal file
View File

@@ -0,0 +1,5 @@
## Tor entry:
Untracked in this dir, a directory called "hidden_service".
This dir is sensitive, and requires manual backup strategy.

8
tor/entrypoint.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/ash
if $USE_TOR ; then
echo "@@@@@@@@@@ TOR ENABLED BY ENV"
exec /usr/bin/tor
else
echo "@@@@@@@@@@ TOR DISABLED BY ENV"
fi

195
tor/torrc Normal file
View File

@@ -0,0 +1,195 @@
## Configuration file for a typical Tor user
## Last updated 9 October 2013 for Tor 0.2.5.2-alpha.
## (may or may not work for much older or much newer versions of Tor.)
##
## Lines that begin with "## " try to explain what's going on. Lines
## that begin with just "#" are disabled commands: you can enable them
## by removing the "#" symbol.
##
## See 'man tor', or https://www.torproject.org/docs/tor-manual.html,
## for more options you can use in this file.
##
## Tor will look for this file in various places based on your platform:
## https://www.torproject.org/docs/faq#torrc
## Tor opens a socks proxy on port 9050 by default -- even if you don't
## configure one below. Set "SocksPort 0" if you plan to run Tor only
## as a relay, and not make any local application connections yourself.
#SocksPort 9050 # Default: Bind to localhost:9050 for local connections.
#SocksPort 192.168.0.1:9100 # Bind to this address:port too.
## Entry policies to allow/deny SOCKS requests based on IP address.
## First entry that matches wins. If no SocksPolicy is set, we accept
## all (and only) requests that reach a SocksPort. Untrusted users who
## can access your SocksPort may be able to learn about the connections
## you make.
#SocksPolicy accept 192.168.0.0/16
#SocksPolicy reject *
## Logs go to stdout at level "notice" unless redirected by something
## else, like one of the below lines. You can have as many Log lines as
## you want.
##
## We advise using "notice" in most cases, since anything more verbose
## may provide sensitive information to an attacker who obtains the logs.
##
## Send all messages of level 'notice' or higher to /var/log/tor/notices.log
#Log notice file /var/log/tor/notices.log
## Send every possible message to /var/log/tor/debug.log
#Log debug file /var/log/tor/debug.log
## Use the system log instead of Tor's logfiles
#Log notice syslog
## To send all messages to stderr:
#Log debug stderr
## Uncomment this to start the process in the background... or use
## --runasdaemon 1 on the command line. This is ignored on Windows;
## see the FAQ entry if you want Tor to run as an NT service.
#RunAsDaemon 1
## The directory for keeping all the keys/etc. By default, we store
## things in $HOME/.tor on Unix, and in Application Data\tor on Windows.
#DataDirectory /var/lib/tor
## The port on which Tor will listen for local connections from Tor
## controller applications, as documented in control-spec.txt.
#ControlPort 9051
## If you enable the controlport, be sure to enable one of these
## authentication methods, to prevent attackers from accessing it.
#HashedControlPassword 16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C
#CookieAuthentication 1
############### This section is just for location-hidden services ###
## Once you have configured a hidden service, you can look at the
## contents of the file ".../hidden_service/hostname" for the address
## to tell people.
##
## HiddenServicePort x y:z says to redirect requests on port x to the
## address y:z.
HiddenServiceDir /hidden_service/
HiddenServicePort 80 backend:8000
#HiddenServiceDir /var/lib/tor/hidden_service/
#HiddenServicePort 80 127.0.0.1:80
#HiddenServiceDir /var/lib/tor/other_hidden_service/
#HiddenServicePort 80 127.0.0.1:80
#HiddenServicePort 22 127.0.0.1:22
################ This section is just for relays #####################
#
## See https://www.torproject.org/docs/tor-doc-relay for details.
## Required: what port to advertise for incoming Tor connections.
#ORPort 9001
## If you want to listen on a port other than the one advertised in
## ORPort (e.g. to advertise 443 but bind to 9090), you can do it as
## follows. You'll need to do ipchains or other port forwarding
## yourself to make this work.
#ORPort 443 NoListen
#ORPort 127.0.0.1:9090 NoAdvertise
## The IP address or full DNS name for incoming connections to your
## relay. Leave commented out and Tor will guess.
#Address noname.example.com
## If you have multiple network interfaces, you can specify one for
## outgoing traffic to use.
# OutboundBindAddress 10.0.0.5
## A handle for your relay, so people don't have to refer to it by key.
#Nickname ididnteditheconfig
## Define these to limit how much relayed traffic you will allow. Your
## own traffic is still unthrottled. Note that RelayBandwidthRate must
## be at least 20 KB.
## Note that units for these config options are bytes per second, not bits
## per second, and that prefixes are binary prefixes, i.e. 2^10, 2^20, etc.
#RelayBandwidthRate 100 KB # Throttle traffic to 100KB/s (800Kbps)
#RelayBandwidthBurst 200 KB # But allow bursts up to 200KB/s (1600Kbps)
## Use these to restrict the maximum traffic per day, week, or month.
## Note that this threshold applies separately to sent and received bytes,
## not to their sum: setting "4 GB" may allow up to 8 GB total before
## hibernating.
##
## Set a maximum of 4 gigabytes each way per period.
#AccountingMax 4 GB
## Each period starts daily at midnight (AccountingMax is per day)
#AccountingStart day 00:00
## Each period starts on the 3rd of the month at 15:00 (AccountingMax
## is per month)
#AccountingStart month 3 15:00
## Administrative contact information for this relay or bridge. This line
## can be used to contact you if your relay or bridge is misconfigured or
## something else goes wrong. Note that we archive and publish all
## descriptors containing these lines and that Google indexes them, so
## spammers might also collect them. You may want to obscure the fact that
## it's an email address and/or generate a new address for this purpose.
#ContactInfo Random Person <nobody AT example dot com>
## You might also include your PGP or GPG fingerprint if you have one:
#ContactInfo 0xFFFFFFFF Random Person <nobody AT example dot com>
## Uncomment this to mirror directory information for others. Please do
## if you have enough bandwidth.
#DirPort 9030 # what port to advertise for directory connections
## If you want to listen on a port other than the one advertised in
## DirPort (e.g. to advertise 80 but bind to 9091), you can do it as
## follows. below too. You'll need to do ipchains or other port
## forwarding yourself to make this work.
#DirPort 80 NoListen
#DirPort 127.0.0.1:9091 NoAdvertise
## Uncomment to return an arbitrary blob of html on your DirPort. Now you
## can explain what Tor is if anybody wonders why your IP address is
## contacting them. See contrib/tor-exit-notice.html in Tor's source
## distribution for a sample.
#DirPortFrontPage /etc/tor/tor-exit-notice.html
## Uncomment this if you run more than one Tor relay, and add the identity
## key fingerprint of each Tor relay you control, even if they're on
## different networks. You declare it here so Tor clients can avoid
## using more than one of your relays in a single circuit. See
## https://www.torproject.org/docs/faq#MultipleRelays
## However, you should never include a bridge's fingerprint here, as it would
## break its concealability and potentionally reveal its IP/TCP address.
#MyFamily $keyid,$keyid,...
## A comma-separated list of exit policies. They're considered first
## to last, and the first match wins. If you want to _replace_
## the default exit policy, end this with either a reject *:* or an
## accept *:*. Otherwise, you're _augmenting_ (prepending to) the
## default exit policy. Leave commented to just use the default, which is
## described in the man page or at
## https://www.torproject.org/documentation.html
##
## Look at https://www.torproject.org/faq-abuse.html#TypicalAbuses
## for issues you might encounter if you use the default exit policy.
##
## If certain IPs and ports are blocked externally, e.g. by your firewall,
## you should update your exit policy to reflect this -- otherwise Tor
## users will be told that those destinations are down.
##
## For security, by default Tor rejects connections to private (local)
## networks, including to your public IP address. See the man page entry
## for ExitPolicyRejectPrivate if you want to allow "exit enclaving".
##
#ExitPolicy accept *:6660-6667,reject *:* # allow irc ports but no more
#ExitPolicy accept *:119 # accept nntp as well as default exit policy
#ExitPolicy reject *:* # no exits allowed
## Bridge relays (or "bridges") are Tor relays that aren't listed in the
## main directory. Since there is no complete public list of them, even an
## ISP that filters connections to all the known Tor relays probably
## won't be able to block all the bridges. Also, websites won't treat you
## differently because they won't know you're running Tor. If you can
## be a real relay, please do; but if not, be a bridge!
#BridgeRelay 1
## By default, Tor will advertise your bridge to users through various
## mechanisms like https://bridges.torproject.org/. If you want to run
## a private bridge, for example because you'll give out your bridge
## address manually to your friends, uncomment this line:
#PublishServerDescriptor 0