Comments (6)
You can achieve this kind of behaviour by developping your own plugin and integrating it in Ajenti.
It's also possible to set different permissions for the users.
Regards
Arnaud
from ajenti.
Arnaud, at first look through the demo plugins it seems a bit complicated - I only know shell scripting.
Could you show a starting point? I could then clone and multiply to all commands that I need.
An example with running system command "/usr/bin/systemctl restart someservice" and printing it's output would be sufficiently exactly what I need.
from ajenti.
Hello @mailinglists35
Sorry for the late reply, I did not see your answer !
There's some demo plugin with minimal examples here : https://github.com/ajenti/demo-plugins
I think it's a goog starting point for understanding how it is working. Just ask if you need help ! (i will follow your answers ;) )
Arnaud
from ajenti.
yes, about those demo plugins I was referring them as too difficult to start with for someone with only bash scripting skills
from ajenti.
Each plugin contains a frontend part (javascript) and a backend part (python).
I will take an example with https://github.com/ajenti/demo-plugins/blob/master/demo_4_http/views.py, and say you want to write a new plugin named myplugin
You will need to copy the whole demo_4_http
directory and replace each reference to demo_4_http
into myplugin
(e.g. https://github.com/ajenti/demo-plugins/blob/master/demo_4_http/plugin.yml).
But in order to achieve this, you will need ajenti-dev-multitool
in order to build the javascript part (follow the readme https://github.com/ajenti/demo-plugins/tree/master ).
The backend part for your request could simply be:
import time
import subprocess
from jadi import component
from aj.api.http import url, HttpPlugin
from aj.api.endpoint import endpoint, EndpointError, EndpointReturn
@component(HttpPlugin)
class Handler(HttpPlugin):
def __init__(self, context):
self.context = context
@url(r'/api/myplugin/someservice/restart')
@endpoint(api=True)
def handle_api_calculate(self, http_context):
try:
subprocess.check_output(['systemctl', 'restart', 'someservice'])
return "Success"
except Exception as e:
raise EndpointError(e)
For the frontend:
- write a function which call the new API endpoint in https://github.com/ajenti/demo-plugins/blob/master/demo_4_http/resources/js/controllers/index.controller.coffee, like:
$scope.restart_my_service = () ->
$http.get("/api/myplugin/someservice/restart").success (data) ->
$scope.result = data
.error (err) ->
notify.error 'Restart failed', err.message
$scope.result = null
- put a button in the html file https://github.com/ajenti/demo-plugins/blob/master/demo_4_http/resources/partial/index.html linked to this new javascript function:
<a ng:click="restart_my_service()" class="btn btn-default">Restart my service</a>
I hope it helps.
Arnaud
from ajenti.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days unless you comment.
Thank you for your contributions.
from ajenti.
Related Issues (20)
- Connecting to ajenti on Ubuntu 22.04 HOT 2
- Does this project provide commercial support? HOT 2
- “Available plugins” take a long time to load on Debian 11.7 HOT 2
- Docker images and containers are not shown in the plugin - venv incompatibility? HOT 3
- Nginx configuration HOT 4
- Error: $q is not defined HOT 2
- crash-2024-01-01-20h39.txt HOT 2
- Ntg
- cara mengatasi ini di debian 10 (how to solve this problem on debian10) HOT 2
- Ajenti not catching IP Tables root permissions error HOT 1
- Error upgrading from 2.2.7 to 2.2.9 HOT 1
- fail to install debian bookworm HOT 7
- unmet dependencies python HOT 1
- Feature request: installing and running ajenti as its own user in a venv HOT 1
- curl https://raw.githubusercontent.com/ajenti/ajenti/master/scripts/install.sh | sudo bash -s -
- ajenti crash report HOT 1
- is there any way to install ajenti offline ? HOT 1
- Clarification of documentation HOT 1
- Encrypted NTS time servers for datetime plugin HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ajenti.