Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Added Rules ; Some Fixes for the .service file ; Create installation script for Debian 9 #119

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ananicy.d/00-default/ark.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ark KDE archiver
{"name": "ark", "type": "BG_CPUIO"}

2 changes: 2 additions & 0 deletions ananicy.d/00-default/bash.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Bash
{ "name": "bash", "type": "Doc-View" }
2 changes: 2 additions & 0 deletions ananicy.d/00-default/konsole.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Konsole
{ "name": "konsole", "type": "Doc-View" }
2 changes: 2 additions & 0 deletions ananicy.d/00-default/minidlna.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# minidlna
{ "name": "minidlnad", "type": "Chat" }
2 changes: 2 additions & 0 deletions ananicy.d/00-default/okular.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Okular PDF KDE reader
{ "name": "okular", "type": "Doc-View" }
3 changes: 3 additions & 0 deletions ananicy.d/00-default/packaged.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PackageManager
{ "name": "packaged", "type": "BG_CPUIO" }
{ "name": "packagemanagerd", "type": "BG_CPUIO" }
2 changes: 2 additions & 0 deletions ananicy.d/00-default/unbound.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Unbound DNS cache system
{ "name": "unbound", "type": "Doc-View" }
5 changes: 5 additions & 0 deletions ananicy.d/00-default/unison.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Unison
{ "name": "unison", "type": "BG_CPUIO" }
{ "name": "unison-gtk", "type": "BG_CPUIO" }
{ "name": "unison-2.48.3", "type": "BG_CPUIO" }
{ "name": "unison-2.48.3-gtk", "type": "BG_CPUIO" }
7 changes: 7 additions & 0 deletions ananicy.d/00-default/update.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# system updaters
{ "name": "apt-get", "type": "BG_CPUIO" }
{ "name": "aptitude", "type": "BG_CPUIO" }
{ "name": "zypper", "type": "BG_CPUIO" }

{ "name": "rpm", "type": "BG_CPUIO" }
{ "name": "dpkg", "type": "BG_CPUIO" }
3 changes: 3 additions & 0 deletions ananicy.d/00-default/vscode.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# VisualStudio Code
{ "name": "code", "type": "Doc-View" }
{ "name": "vscode", "type": "Doc-View" }
8 changes: 4 additions & 4 deletions ananicy.service
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ ExecStart=/usr/bin/ananicy start
Nice=19
SuccessExitStatus=143
OOMScoreAdjust=-999
Restart=always
Restart=on-failure
CPUAccounting=true
MemoryHigh=16M
MemoryMax=64M
#MemoryHigh=16M
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK systemd ignore key which not supported, or i misunderstood something?

#MemoryMax=64M
ProtectSystem=true
ProtectHome=true
#ProtectHome=true
PrivateTmp=yes

[Install]
Expand Down
79 changes: 79 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
# Copywright - Andre L. R. Madureira - 2018
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copywright? : D

# Install dependencies to make Ananicy work inside a Linux Distribution
#
# To add a new distro, just add it below the declare -A
# and type in the command to update and install
# dependencies. If you want to specify different
# dependencies based on the ARCH of the system, just
# type in SUPPORTED_DISTROS[distroname_arch]. Ex:
# SUPPORTED_DISTROS[debian_x86_64]="apt-get ..."
declare -A SUPPORTED_DISTROS

SUPPORTED_DISTROS[debian]="
apt-get update &&
apt-get install coreutils schedtool make python3"

SUPPORTED_DISTROS[ubuntu]="
apt-get update &&
apt-get install coreutils schedtool make python3"

# check if the distro supports systemctl
SERVICE_NAME=ananicy
SYSTEMCTL=$(whereis systemctl | cut -d':' -f2 | tr -s ' ' | xargs | cut -d\ -f1)

DISTRO=""
ARCH=""

[ "$(whoami)" != "root" ] && echo -e "\n\tRUN this script as ROOT. Exiting...\n" && exit 1

check_distro(){
# find the distro running
local SUPP_DIST=$(echo ${!SUPPORTED_DISTROS[@]} | tr ' ' '|')
DISTRO=$(
(lsb_release -a ; cat /etc/issue* /etc/*release /proc/version) 2> /dev/null |
tr '[:upper:]' '[:lower:]' |
grep -o -P "($SUPP_DIST)" |
head -n 1
)
# check distro architecture
if uname -a | grep -i -P '(amd64|x86_64)' &> /dev/null; then
ARCH=x86_64
else
ARCH=i386
fi
}

install_deps(){
local PKT_TOOLS=${SUPPORTED_DISTROS[${DISTRO}_${ARCH}]}
if [ -z "$PKT_TOOLS" ]; then
PKT_TOOLS=${SUPPORTED_DISTROS[${DISTRO}]}
fi
eval $PKT_TOOLS
}

set_autostart(){
local LOCAL_STATUS=0
if [ -n "$SYSTEMCTL" ]; then
# use systemctl to autostart ananicy
systemctl daemon-reload &&
systemctl enable "$SERVICE_NAME" &&
systemctl start "$SERVICE_NAME"
LOCAL_STATUS=$(($LOCAL_STATUS+$?))
else
# TODO, create SYS V INIT script and remove the
# LOCAL_STATUS=1 below
LOCAL_STATUS=1
fi
return $LOCAL_STATUS
}

check_distro
install_deps &&
make -j4 install &&
set_autostart &&
echo -e '\n\tAll went fine, Ananicy Installed with SUCCESS\n' || (
echo -e '\n\tAnanicy Installation - ERROR\n'
exit 1
)