cjdns.paketlendi

This commit is contained in:
milisman 2016-07-01 01:34:22 +03:00
parent f8e6096032
commit e2bbf58c84
5 changed files with 353 additions and 0 deletions

View File

@ -0,0 +1,3 @@
mkdir -p /dev/net &&
mknod /dev/net/tun c 10 200 &&
chmod 0666 /dev/net/tun

View File

@ -0,0 +1,165 @@
#!/usr/bin/env bash
# This script is licensed under the GPL2 and includes modified content from the GPL2 licensed /etc/rc.d/functions script that used to be included in Archlinux
### Modified selection from the now deprecated /etc/rc.d/functions ###
calc_columns () {
STAT_COL=80
if [[ ! -t 1 ]]; then
USECOLOR=""
elif [[ -t 0 ]]; then
# stty will fail when stdin isn't a terminal
STAT_COL=$(stty size)
# stty gives "rows cols"; strip the rows number, we just want columns
STAT_COL=${STAT_COL##* }
elif tput cols &>/dev/null; then
# is /usr/share/terminfo already mounted, and TERM recognized?
STAT_COL=$(tput cols)
fi
if (( STAT_COL == 0 )); then
# if output was 0 (serial console), set default width to 80
STAT_COL=80
USECOLOR=""
fi
# we use 13 characters for our own stuff
STAT_COL=$(( STAT_COL - 13 ))
if [[ -t 1 ]]; then
SAVE_POSITION="\e[s"
RESTORE_POSITION="\e[u"
DEL_TEXT="\e[$(( STAT_COL + 4 ))G"
else
SAVE_POSITION=""
RESTORE_POSITION=""
DEL_TEXT=""
fi
}
calc_columns
# disable colors on broken terminals
TERM_COLORS=$(tput colors 2>/dev/null)
if (( $? != 3 )); then
case $TERM_COLORS in
*[!0-9]*) USECOLOR="";;
[0-7]) USECOLOR="";;
'') USECOLOR="";;
esac
fi
unset TERM_COLORS
deltext() {
printf "${DEL_TEXT}"
}
stat_busy() {
printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} "
printf "${SAVE_POSITION}"
deltext
printf " ${C_OTHER}[${C_BUSY}BUSY${C_OTHER}]${C_CLEAR} "
}
stat_done() {
deltext
printf " ${C_OTHER}[${C_DONE}DONE${C_OTHER}]${C_CLEAR} \n"
}
stat_fail() {
deltext
printf " ${C_OTHER}[${C_FAIL}FAIL${C_OTHER}]${C_CLEAR} \n"
}
status_started() {
deltext
echo -ne "$C_OTHER[${C_STRT}STARTED$C_OTHER]$C_CLEAR "
}
status_stopped() {
deltext
echo -ne "$C_OTHER[${C_STRT}STOPPED$C_OTHER]$C_CLEAR "
}
# Return PID of $1
get_pid() {
pidof -o %PPID $1 || return 1
}
# set colors
if [[ $USECOLOR != [nN][oO] ]]; then
if tput setaf 0 &>/dev/null; then
C_CLEAR=$(tput sgr0) # clear text
C_MAIN=${C_CLEAR}$(tput bold) # main text
C_OTHER=${C_MAIN}$(tput setaf 4) # prefix & brackets
C_SEPARATOR=${C_MAIN}$(tput setaf 0) # separator
C_BUSY=${C_CLEAR}$(tput setaf 6) # busy
C_FAIL=${C_MAIN}$(tput setaf 1) # failed
C_DONE=${C_MAIN} # completed
C_BKGD=${C_MAIN}$(tput setaf 5) # backgrounded
C_H1=${C_MAIN} # highlight text 1
C_H2=${C_MAIN}$(tput setaf 6) # highlight text 2
else
C_CLEAR="\e[m" # clear text
C_MAIN="\e[;1m" # main text
C_OTHER="\e[1;34m" # prefix & brackets
C_SEPARATOR="\e[1;30m" # separator
C_BUSY="\e[;36m" # busy
C_FAIL="\e[1;31m" # failed
C_DONE=${C_MAIN} # completed
C_BKGD="\e[1;35m" # backgrounded
C_H1=${C_MAIN} # highlight text 1
C_H2="\e[1;36m" # highlight text 2
fi
fi
PREFIX_REG="::"
### CJDNS service ###
. /etc/default/cjdns
PID=$(get_pid $CJDROUTE)
case "$1" in
start)
stat_busy "Starting cjdns"
#START CJDNS AND ENABLE THE DAEMON IF IT SUCCEEDS
if [ -z "$PID" ]; then
cjdns.sh start &> /dev/null
if [ $? -gt 0 ]; then
stat_busy "Unable to start the daemon"
stat_fail
exit 1
else
stat_done
fi
else
stat_busy "The daemon is already running"
stat_fail
exit 1
fi
;;
stop)
stat_busy "Stopping cjdns"
cjdns.sh stop
if [ $? -gt 0 ]; then
stat_busy "The daemon was not running"
stat_fail
else
stat_done
fi
;;
restart)
$0 stop
while [ ! -z "$PID" -a -d "/proc/$PID" ]; do sleep 1; done
$0 start
;;
status)
stat_busy "The daemon is currently..."
if [ $(cjdns.sh status | grep -c not) = 0 ]; then status_started; else status_stopped; fi
;;
*)
echo "usage: $0 {start|stop|restart|status}"
esac
exit 0

View File

@ -0,0 +1,14 @@
# /etc/default/cjdns
# This is the config file for cjdns.sh and the system v init script
# Path to the cjdroute binary. Defaults to the current directory: "$(dirname $0)"
CJDPATH="/usr/bin"
# Full path to the cjdroute binary. Defaults to: "${CJDPATH}/cjdns/cjdroute"
CJDROUTE="${CJDPATH}/cjdroute"
# Full path to the configuration file. Defaults to: "${CJDPATH}/cjdroute.conf"
CONF="/etc/cjdroute.conf"
# Path to the log file. Defaults to disabled logging: "/dev/null"
LOGTO="/dev/null"

138
talimatname/genel/cjdns/cjdns.sh Executable file
View File

@ -0,0 +1,138 @@
#!/usr/bin/env bash
#
# You may redistribute this program and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
# cjdns.sh
#
# Copy this script to the desired location, then add the following to the cjdns user's crontab
# */5 * * * * /path/to/cjdns.sh check >>/dev/null 2>>/dev/null
#
# Start cjdns if it isn't already running (and set the above cronjob to restart failed processes):
# ./cjdns.sh start
#
# Stop cjdns if it's currently running (and set the above cronjob not to restart failed processes):
# ./cjdns.sh stop
#
# Check whether cjdns is currently running:
# ./cjdns.sh status
#
# Restart cjdns after upgrades and changes to the config:
# ./cjdns.sh restart
##
if [ -f /etc/default/cjdns ]; then
. /etc/default/cjdns
fi
# path to the cjdns source tree, no trailing slash
if [ -z "$CJDPATH" ]; then CJDPATH=`dirname $0`; fi
# full path to the cjdroute binary
if [ -z "$CJDROUTE" ]; then CJDROUTE="${CJDPATH}/cjdns/cjdroute"; fi
# full path to the configuration file
if [ -z "$CONF" ]; then CONF="${CJDPATH}/cjdroute.conf"; fi
# path to the log file.
if [ -z "$LOGTO" ]; then LOGTO="/dev/null"; fi
load_pid()
{
PID=$(pgrep -d " " -f "$CJDROUTE")
}
load_pid
stop()
{
if [ -z "$PID" ]; then
echo "cjdns is not running"
return 1
else
kill $PID &> /dev/null
while [ -n "$(pgrep -d " " -f "$CJDROUTE")" ]; do
echo "* Waiting for cjdns to shut down..."
sleep 1;
done
if [ $? -gt 0 ]; then return 1; fi
fi
}
start()
{
if [ -z "$PID" ]; then
[ -e "$CONF" ] || $CJDROUTE --genconf > $CONF
$CJDROUTE < $CONF &>> $LOGTO
if [ $? -gt 0 ]; then
echo "Failed to start cjdns"
return 1
fi
else
echo "cjdns is already running"
return 1
fi
}
status()
{
echo -n "* cjdns is "
if [ -z "$PID" ]; then
echo "not running"
exit 1
else
echo "running"
exit 0
fi
}
update()
{
if [ -d ${CJDPATH}/cjdns/.git ]; then
cd ${CJDPATH}/cjdns
git pull
./do || echo "Failed to update!" && exit 1
echo "* Update complete, restarting cjdns"
stop
load_pid
start
else
echo "The cjdns source directory does not exist"
return 1
fi
}
case "$1" in
"start" )
start
;;
"restart" )
stop
load_pid
start
;;
"stop" )
stop
;;
"status" )
status
;;
"check" )
ps aux | grep -v 'grep' | grep 'cjdns core' > /dev/null 2>/dev/null || start
;;
"update" )
update
;;
*)
echo "usage: $0 {start|stop|restart|check|update}"
esac

View File

@ -0,0 +1,33 @@
# Description: A routing engine designed for security, scalability, speed and ease of use
# URL: https://github.com/cjdelisle/cjdns
# Packager: milisarge
# Depends on : node python
name=cjdns
hesap=cjdelisle
version=master
release=1
source=(cjdns.servis cjdns.rc.d cjdns.sh)
build () {
if [ ! -d $DERLEME_KAYNAKDIZIN/$name ];then
git clone https://github.com/$hesap/$name $DERLEME_KAYNAKDIZIN/$name
else
cd $DERLEME_KAYNAKDIZIN/$name
git pull
cd -
fi
cp -r $DERLEME_KAYNAKDIZIN/$name $SRC/
cd $SRC/$name
bash 'do'
install -Dm755 cjdroute "$PKG/usr/bin/cjdroute"
install -Dm755 contrib/sh/run-cjdroute.sh "$PKG/usr/bin/run-cjdroute"
install -Dm644 $SRC/cjdns.servis $PKG/etc/default/cjdns
install -Dm755 $SRC/cjdns.sh $PKG/usr/bin/cjdns.sh
install -Dm755 $SRC/cjdns.rc.d $PKG/etc/rc.d/init.d/cjdns
}