Skip to content

Commit

Permalink
patchler işlenmiş hali.
Browse files Browse the repository at this point in the history
  • Loading branch information
mthnzbk committed Jul 24, 2016
0 parents commit bc14b65
Show file tree
Hide file tree
Showing 91 changed files with 11,271 additions and 0 deletions.
109 changes: 109 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Project name
PROJECT (comar)

# CMake 2.6 required
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

# Python is required
FIND_PACKAGE(PythonLibs)

FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES (DBUS REQUIRED dbus-1)

# Application name
SET (APP_NAME "comar")
SET (APP_SUFFIX "3")

# Uncomment this for production releases.
SET (VERSION_SUFFIX "")
#SET (FLAGS "-g -O0 -Werror -Wcast-align -Wno-uninitialized -Wall -fstrict-aliasing")

# Uncomment this for gprof profiling
# SET (FLAGS "-g -O0 -Werror -Wcast-align -Wno-uninitialized -Wall -fstrict-aliasing -fprofile-arcs -ftest-coverage")
#SET (CMAKE_C_FLAGS "${FLAGS}")
# Uncomment this for sparse building
# SET (CMAKE_C_COMPILER cgcc)

# Append name suffix, if specified
IF (APP_SUFFIX)
SET (APP_NAME "${APP_NAME}${APP_SUFFIX}")
ENDIF (APP_SUFFIX)

# Define version, config dir, data dir and log file.
ADD_DEFINITIONS (
-D'PID_FILE="/run/${APP_NAME}.pid"'
-D'DATA_DIR="/var/lib/${APP_NAME}"'
-D'LOG_DIR="/var/log/${APP_NAME}"')

# Set standard sources
SET (SOURCES src/main.c
src/bus.c
src/config.c
src/db.c
src/iksemel.c
src/log.c
src/loop.c
src/process.c
src/policy.c
src/pydbus.c
src/script.c
src/utils.c)

# Set standard libraries
SET (LIBS ${PYTHON_LIBRARIES}
dbus-1)

# Include standard headers
INCLUDE_DIRECTORIES (include/
${PYTHON_INCLUDE_DIRS}
${DBUS_INCLUDE_DIRS})

# Compile comar from specified sources
ADD_EXECUTABLE (comar ${SOURCES})

# Link comar to specified libraries
TARGET_LINK_LIBRARIES(comar ${LIBS} )

# Install comar to /usr/sbin/<app-name>
INSTALL (PROGRAMS comar
DESTINATION /usr/sbin)

# Install Models
INSTALL (DIRECTORY
models
DESTINATION /var/db/${APP_NAME}
PATTERN ".svn" EXCLUDE)

# Install Modules
INSTALL (DIRECTORY
modules
DESTINATION /var/db/${APP_NAME}
PATTERN ".svn" EXCLUDE)

# Install service activation config under /usr/share/dbus-1/system-services/
INSTALL (FILES
config/tr.org.pardus.comar.service
config/tr.org.pardus.comar2.service
DESTINATION /usr/share/dbus-1/system-services/)

# Install polkit policies
INSTALL (DIRECTORY
policy/
DESTINATION /usr/share/polkit-1/actions
FILES_MATCHING PATTERN "*.policy"
PATTERN ".svn" EXCLUDE)

# Install system bus policy under /etc/dbus-1/system.d/
INSTALL (FILES
config/tr.org.pardus.comar.conf
DESTINATION /etc/dbus-1/system.d)

# Install hav to /usr/bin/hav
INSTALL (PROGRAMS tools/hav.py
DESTINATION /usr/bin
RENAME hav)

# Install hav to /usr/bin/comar2to3
INSTALL (PROGRAMS tools/comar2to3.py
DESTINATION /usr/bin
RENAME comar2to3)
23 changes: 23 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Requirements
=============

Python 2.5
DBus
polkit


Installation
=============

Build:

$ cmake .
$ make

Install:

# make install DESTDIR=/

Import Comar 2.0 scripts (optional):

# comar2to3
24 changes: 24 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- CSL methods
- log_*()
- model_apps()
- Move core methods into script.c
- Execute onRegister/onRemove methods after registering/removing script
/ Logging to file
? Logging errors and traceback to seperate file
- Policy files
- Models use COMAR 2.0 policy action IDs, fix them
+ Script for importing COMAR 2.0 scripts
/ Get signature from introspection.xml
+ Variant type support
- Numeric type tests
- Raise an exception on conversion error
- Make hav.py use COMAR API
? Switch to polkit 0.96

----------------------------------------------------------------------

Legend:
? Not sure
/ Incomplete
- Missing
+ Done
17 changes: 17 additions & 0 deletions config/tr.org.pardus.comar.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>
<policy user="root">
<allow own="tr.org.pardus.comar"/>
<allow own="tr.org.pardus.comar2"/>
<allow own="tr.org.pardus.comar.updated"/>
</policy>

<policy context="default">
<allow send_destination="tr.org.pardus.comar"/>
<allow send_destination="tr.org.pardus.comar2"/>
<allow send_destination="tr.org.pardus.comar.updated"/>
</policy>
</busconfig>
4 changes: 4 additions & 0 deletions config/tr.org.pardus.comar.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[D-BUS Service]
Name=tr.org.pardus.comar
Exec=/usr/sbin/comar
User=root
4 changes: 4 additions & 0 deletions config/tr.org.pardus.comar2.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[D-BUS Service]
Name=tr.org.pardus.comar2
Exec=/usr/sbin/comar -i -b tr.org.pardus.comar2
User=root
89 changes: 89 additions & 0 deletions docs/en/api/service.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
Service Scripts
===============

Service scripts are Python scripts used by COMAR to manage system services and comes with PiSi packages. Any System.Service call made to Comar (start, stop, info, ...) will be handled by service scripts.

Service script, is a Python file like below. There are three methods. Two for starting and stopping service, one for giving status of service. Implementation of these three scripts is up to package maintainer. However, COMAR API package provides Service API, which contains useful methods for writing service scripts.

serviceType = "server"
serviceDesc = _({"en": "Server",
"tr": "Sunucu"})

from comar.service import *

@synchronized
def start():
startService(command="/usr/bin/myserver",
args="start",
pidfile="/var/run/sunucu.pid",
donotify=True)

@synchronized
def stop():
stopService(command="/usr/bin/myserver",
args="stop",
donotify=True)

def status():
return isServiceRunning("/var/run/myserver.pid")


serviceType
-----------

Possible values:

local: Local services
server: Servers
script: Scripts

This value is used to group services only.


serviceDesc
-----------

serviceDesc = _({"en": "My Server",
"tr": "Sunucum"})

This value is used by System.Service GUIs. _() is used for localization.


@synchronized Decorator
-----------------------

In boot sequence, service scripts can start other services. To prevent any race condition, @synchronized decorator should be used.

Service API
-----------

startService():

Arguments:

command : Application to execute [str]
args : Arguments (optional) [str]
pidfile : PID file for application. (optional) [str]
(Application won't be started if it's already running.)
makepid : If application doesn't create any PID file, API creates one. Generally used with ''detach'' argument (optional) [True/False]
nice : Niceness of process (optional) [int]
chuid : Owner of the process. Format: user:group (optional) [str:str]
detach : Fork process (optional) [True/False]
donotify : Emit a System.Service.changed signal and notify all GUIs (optional) [True/False]
(This should be used. It's optional because some service scripts start more than one process.)

stopService():

Arguments:

pidfile : PID file of the running process (optional) [str]
command : Application to stop (optional) [str]
(Scans /proc and kills all running applications having that /path/to/name)
args : Arguments (To stop application by calling it with an argument) (optional) [str]
(/proc won't be scanned, <command args> will be executed)
chuid : Owner of the process. Format: user:group (optional) [str:str]
user : Username associated with process. (optional) [str]
signalno : Signal to be sent to running process (optional) [int]
donotify : Emit a System.Service.changed signal and notify all GUIs (optional) [True/False]
(This should be used. It's optional because some service scripts stop more than one process.)

89 changes: 89 additions & 0 deletions docs/en/models/Disk.Manager.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
Disk.Manager
============

getDevices():
Returns a list of disks.

Function should return something like that:

01 [
02 "/dev/sda",
03 "/dev/sdb",
04 ]


getDeviceParts(device):
Returns list of partitions of specified device.

Function should return something like that:

01 [
02 "/dev/sda1",
03 "/dev/sda2",
04 "/dev/sda3",
05 ]


getMounted():
Returns a list of mounted partitions.

Function should return something like that:

01 [
02 "/dev/sda1",
03 "/dev/sda3",
04 ]


getDeviceByLabel(label):
Returns device name that has specified label.

Function should return something like that:

01 "/dev/sda1"


mount(device, path):
Mounts device to the specified path.


umount(device):
Unmounts device.


listEntries():
Returns a list of entries in fstab

Function should return something like that:

01 [
02 "/dev/sda1",
03 "LABEL=PARDUS_ROOT",
04 "/dev/sda3",
05 ]


addEntry(device, path, fsType, options):
Adds an entry to fstab. First argument is device path, second argument
is mount point, third argument is filesystem type, fourth argument is
dictionary of options.


getEntry(device):
Returns mount point, filesystem type and options of an entry.

Function should return something like that:

01 (
02 "/mnt/sda1",
03 "ext3",
04 {"noatime": "", "defaults": ""},
05 (


removeEntry(device):
Removes an entry from fstab.


Signals:
changed: Fired when an entry is updated in fstab.
Loading

0 comments on commit bc14b65

Please sign in to comment.