Skip to content

Commit 42c409e

Browse files
committed
- Added basic documentation
- Switch from buildpackage.sh to Makefile
1 parent 4a830bf commit 42c409e

File tree

11 files changed

+262
-8
lines changed

11 files changed

+262
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: build and publish documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
submodules: true # Fetch Hugo themes (true OR recursive)
16+
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
17+
18+
- name: Setup Sphinx
19+
run: |
20+
apt update && apt install -y python3-pip build-essential
21+
pip install sphinx_rtd_theme
22+
23+
- name: Build
24+
run: |
25+
cd docs
26+
sphinx-build . ../public/
27+
28+
- name: Deploy
29+
uses: peaceiris/actions-gh-pages@v3
30+
if: github.ref == 'refs/heads/main'
31+
with:
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
publish_dir: ./public

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
uses: actions/checkout@v2
1818

1919
- name: Install dependencies
20-
run: sudo apt update && sudo apt install debhelper -y
20+
run: sudo apt update && sudo apt install debhelper build-essential -y
2121

2222
- name: Build
23-
run: ./buildpackage.sh
23+
run: make deb
2424

2525
- name: Copy artifacts
2626
run: mkdir package && cp ../linuxmuster-linuxclient7_* ./package

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ debian/files
88
debian/linuxmuster-linuxclient7.debhelper.log
99
debian/linuxmuster-linuxclient7.substvars
1010
debian/linuxmuster-linuxclient7/
11+
__pycache__
12+
/public

Makefile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.PHONY: help deb docs
2+
3+
help:
4+
@echo "Options:"
5+
@echo " deb Build debian package"
6+
@echo " docs Build Sphinx documentation"
7+
@echo " clean Remove built files"
8+
9+
deb:
10+
dpkg-buildpackage -rfakeroot -tc -sa -us -uc -I".directory" -I".git" -I"buildpackage.sh"
11+
12+
docs:
13+
cd docs && sphinx-build . ../public
14+
15+
clean:
16+
rm -r public

buildpackage.sh

-5
This file was deleted.

docs/_static/logo.png

17.6 KB
Loading

docs/_static/theme_overrides.css

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.wy-nav-side, .wy-side-nav-search, .wy-nav-top {
2+
background-color: #233c4c;
3+
}
4+
5+
div.rtd-pro.wy-menu, div.rst-pro.wy-menu {
6+
display: none;
7+
}
8+
9+
.wy-side-nav-search > div.version {
10+
color: #f49e00;
11+
font-size: 1.2em;
12+
font-weight: bold;
13+
}
14+
15+
.wy-menu-vertical p.caption {
16+
color: #f49e00;
17+
}
18+
19+
.wy-menu-vertical a {
20+
color: #ffffff
21+
}
22+
23+
.wy-menu-vertical a:hover {
24+
background-color: #f49e00
25+
}

docs/conf.py

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
import os
5+
import sys
6+
import builtins
7+
8+
import sphinx_rtd_theme
9+
10+
sys.path.insert(0, "../usr/lib/python3/dist-packages/")
11+
12+
# Fix gettext syntax
13+
builtins._ = lambda x:x
14+
15+
extensions = ['sphinx.ext.autodoc',
16+
'sphinx.ext.intersphinx',
17+
'sphinx.ext.ifconfig',
18+
'sphinx.ext.viewcode',
19+
'sphinx.ext.autosummary']
20+
autosummary_generate = True
21+
22+
templates_path = ['_templates']
23+
source_suffix = '.rst'
24+
master_doc = 'index'
25+
26+
# General information about the project.
27+
project = 'linuxmuster-linuxclient7'
28+
copyright = '2020, Dorian Zedler'
29+
author = 'Dorian Zedler'
30+
31+
def setup(app):
32+
app.add_css_file("theme_overrides.css")
33+
34+
version = "unknown"
35+
with open("../debian/changelog") as changelogFile:
36+
changelog = changelogFile.read()
37+
version = changelog.split("\n")[0].split("(")[1].split(")")[0]
38+
39+
release = version
40+
41+
language = 'en_GB'
42+
exclude_patterns = []
43+
pygments_style = 'sphinx'
44+
todo_include_todos = False
45+
46+
html_theme = 'sphinx_rtd_theme'
47+
html_logo = '_static/logo.png'
48+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
49+
html_static_path = ['_static']
50+
html_sidebars = {
51+
'**': [
52+
'relations.html', # needs 'show_related': True theme option to display
53+
'searchbox.html',
54+
]
55+
}
56+
57+
htmlhelp_basename = 'linuxmuster-linuxclient7doc'
58+
59+
latex_elements = {
60+
# The paper size ('letterpaper' or 'a4paper').
61+
#
62+
# 'papersize': 'letterpaper',
63+
64+
# The font size ('10pt', '11pt' or '12pt').
65+
#
66+
# 'pointsize': '10pt',
67+
68+
# Additional stuff for the LaTeX preamble.
69+
#
70+
# 'preamble': '',
71+
72+
# Latex figure (float) alignment
73+
#
74+
# 'figure_align': 'htbp',
75+
}
76+
77+
latex_documents = [
78+
(master_doc, 'linuxmuster-7.tex', 'linuxmuster-linuxclient7 Documentation',
79+
'Dorian Zedler', 'manual'),
80+
]
81+
82+
man_pages = [
83+
(master_doc, 'linuxmuster-linuxclient7', 'linuxmuster-linuxclient7 Documentation',
84+
[author], 1)
85+
]
86+
87+
88+
texinfo_documents = [
89+
(master_doc, 'linuxmuster-linuxclient7', 'linuxmuster-linuxclient7 Documentation',
90+
author, 'linuxmuster-linuxclient7', 'One line description of project.',
91+
'Miscellaneous'),
92+
]
93+
94+
intersphinx_mapping = {'https://docs.python.org/': None}

docs/index.rst

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.. linuxmuster-linuxclient7 documentation
2+
3+
Linuxmuster-linuxclient7's developer documentation
4+
==================================================
5+
6+
.. autosummary::
7+
:toctree: _autosummary
8+
:recursive:
9+
:caption: Contents:
10+
11+
About
12+
-----
13+
14+
Welcome in this API reference documentation !
15+
16+
Linuxmuster-linuxclient7 is a part of the `linuxmuster.net <https://www.linuxmuster.net/de/home/>`_'s project which provides a complete environment for school network management.
17+
18+
You can find the whole description of the install process on the `official documentation page <https://docs.linuxmuster.net/de/latest/>`_ of the project.
19+
20+
In particularly, some `appliances (Proxmox, XCP-ng and KVM) are prepared <https://docs.linuxmuster.net/de/latest/getting-started/installoptions/index.html>`_ in order to permit a fast deployment for test use.
21+
22+
.. toctree::
23+
:maxdepth: 1
24+
:caption: Users
25+
:hidden:
26+
27+
28+
.. toctree::
29+
:maxdepth: 1
30+
:caption: Linuxclient7 Python API
31+
:hidden:
32+
33+
python/shares.rst

docs/python/shares.rst

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Module: shares
2+
**************
3+
4+
This is used to deal with mounting and unmounting samba shares.
5+
6+
Shares API
7+
============
8+
.. automodule:: linuxmusterLinuxclient7.shares
9+
:members:

usr/lib/python3/dist-packages/linuxmusterLinuxclient7/shares.py

+48-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
from pathlib import Path
44

55
def mountShare(networkPath, shareName = None, hiddenShare = False, username = None):
6+
"""
7+
Mount a given path of a samba share
8+
9+
:param networkPath: Network path of the share
10+
:type networkPath: str
11+
:param shareName: The name of the share (name of the folder the share is being mounted to)
12+
:type shareName: str
13+
:param hiddenShare: If the share sould be visible in Nautilus
14+
:type hiddenShare: bool
15+
:param username: The user in whoms context the share should be mounted
16+
:type username: str
17+
:return: Tuple: (success, mountpoint)
18+
:rtype: tuple
19+
"""
620
networkPath = networkPath.replace("\\", "/")
721
username = _getDefaultUsername(username)
822
shareName = _getDefaultShareName(networkPath, shareName)
@@ -15,6 +29,23 @@ def mountShare(networkPath, shareName = None, hiddenShare = False, username = No
1529
return _mountShareWithoutRoot(networkPath, shareName, hiddenShare), mountpoint
1630

1731
def getMountpointOfRemotePath(remoteFilePath, hiddenShare = False, username = None, autoMount = True):
32+
"""
33+
Get the local path of a remote samba share path.
34+
This function automatically checks if the shares is already mounted.
35+
It optionally automatically mounts the top path of the remote share:
36+
If the remote path is `//server/sysvol/linuxmuster.lan/Policies` it mounts `//server/sysvol`
37+
38+
:param remoteFilePath: Remote path
39+
:type remoteFilePath: str
40+
:param hiddenShare: If the share sould be visible in Nautilus
41+
:type hiddenShare: bool
42+
:param username: The user in whoms context the share should be mounted
43+
:type username: str
44+
:parama autoMount: If the share should be mouted automatically if it is not already mounted
45+
:type autoMount: bool
46+
:return: Tuple: (success, mountpoint)
47+
:rtype: tuple
48+
"""
1849
remoteFilePath = remoteFilePath.replace("\\", "/")
1950
username = _getDefaultUsername(username)
2051

@@ -41,6 +72,14 @@ def getMountpointOfRemotePath(remoteFilePath, hiddenShare = False, username = No
4172
return True, localFilePath
4273

4374
def unmountAllSharesOfUser(username):
75+
"""
76+
Unmount all shares of a given user and safely delete the mountpoints and the parent directory.
77+
78+
:param username: The username of the user
79+
:type username: str
80+
:return: True or False
81+
:rtype: bool
82+
"""
4483
logging.info("=== Trying to unmount all shares of user {0} ===".format(username))
4584
for basedir in [constants.shareMountBasepath, constants.hiddenShareMountBasepath]:
4685
shareMountBasedir = basedir.format(username)
@@ -56,7 +95,7 @@ def unmountAllSharesOfUser(username):
5695

5796
if len(os.listdir(shareMountBasedir)) > 0:
5897
logging.warning("* Mount basedir {} is not empty so not removed!".format(shareMountBasedir))
59-
return
98+
return False
6099
else:
61100
# Delete the directory
62101
logging.info("Deleting {0}...".format(shareMountBasedir))
@@ -65,10 +104,18 @@ def unmountAllSharesOfUser(username):
65104
except Exception as e:
66105
logging.error("FAILED!")
67106
logging.exception(e)
107+
return False
68108

69109
logging.info("===> Finished unmounting all shares of user {0} ===".format(username))
110+
return True
70111

71112
def getLocalSysvolPath():
113+
"""
114+
Get the local mountpoint of the sysvol
115+
116+
:return: Full path of the mountpoint
117+
:rtype: str
118+
"""
72119
rc, networkConfig = config.network()
73120
if not rc:
74121
return False, None

0 commit comments

Comments
 (0)