Guest User

Untitled

a guest
Jul 4th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.51 KB | None | 0 0
  1. login as: opensips
  2. opensips@192.168.32.57's password:
  3. Linux OpenSIPs 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64
  4.  
  5. The programs included with the Debian GNU/Linux system are free software;
  6. the exact distribution terms for each program are described in the
  7. individual files in /usr/share/doc/*/copyright.
  8.  
  9. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
  10. permitted by applicable law.
  11. Last login: Sat Jul 4 12:54:44 2020
  12. opensips@OpenSIPs:~$ locate opensips.cfg
  13. /usr/local/share/man/man5/opensips.cfg.5
  14. /usr/src/opensips-3.0/opensips.cfg.5
  15. /usr/src/opensips-3.0/etc/opensips.cfg
  16. /usr/src/opensips-3.0/modules/osp/etc/sample-osp-opensips.cfg
  17. /usr/src/opensips-3.0/modules/sipcapture/examples/opensips.cfg
  18. opensips@OpenSIPs:~$ vi /etc/opensips.cfg
  19. opensips@OpenSIPs:~$ vi /usr/src/opensips-3.0/etc/opensips.cfg
  20. if (is_method("REGISTER")) {
  21.  
  22. if (!save("location"))
  23. sl_reply_error();
  24.  
  25. exit;
  26. }
  27.  
  28. if ($rU==NULL) {
  29. # request with no Username in RURI
  30. send_reply(484,"Address Incomplete");
  31. exit;
  32. }
  33.  
  34. # do lookup with method filtering
  35. if (!lookup("location","m")) {
  36. t_reply(404, "Not Found");
  37. exit;
  38. }
  39.  
  40. # when routing via usrloc, log the missed calls also
  41. do_accounting("log","missed");
  42. route(relay);
  43. }
  44.  
  45.  
  46. route[relay] {
  47. # for INVITEs enable some additional helper routes
  48. if (is_method("INVITE")) {
  49. t_on_branch("per_branch_ops");
  50. t_on_reply("handle_nat");
  51. t_on_failure("missed_call");
  52. }
  53.  
  54. if (!t_relay()) {
  55. send_reply(500,"Internal Error");
  56. }
  57. exit;
  58. }
  59.  
  60.  
  61.  
  62.  
  63. branch_route[per_branch_ops] {
  64. xlog("new branch at $ru\n");
  65. }
  66.  
  67.  
  68. onreply_route[handle_nat] {
  69. xlog("incoming reply\n");
  70. }
  71.  
  72.  
  73. failure_route[missed_call] {
  74. if (t_was_cancelled()) {
  75. exit;
  76. }
  77.  
  78. # uncomment the following lines if you want to block client
  79. # redirect based on 3xx replies.
  80. ##if (t_check_status("3[0-9][0-9]")) {
  81. ##t_reply(404,"Not found");
  82. ## exit;
  83. ##}
  84.  
  85.  
  86. }
  87. --------------------------------------------------------------------------------------------------------------------------------------
  88. -------------------------------------------------------------------------------------------------------------------------------------
  89.  
  90. --------------------------------------------------------------------------------------------------------------------------------------
  91. --------------------------------------------------------------------------------------------------------------------------------------
  92. /etc/init.d
  93.  
  94. #!/bin/sh
  95. #
  96. ### BEGIN INIT INFO
  97. # Provides: opensips
  98. # Required-Start: $syslog $network $local_fs $time $remote_fs
  99. # Required-Stop: $syslog $network $local_fs $remote_fs
  100. # Default-Start: 2 3 4 5
  101. # Default-Stop: 0 1 6
  102. # Short-Description: Start the OpenSIPS SIP server
  103. # Description: Start the OpenSIPS SIP server
  104. ### END INIT INFO
  105. #
  106. # TODO:
  107. # The following fields should be added (and completed):
  108. # Should-Start: postgresql mysql radius
  109. # Should-Stop: postgresql mysql radius
  110.  
  111. set -e
  112.  
  113. PATH_EXTRA=
  114. #PATH=/sbin:/bin:/usr/sbin:/usr/bin${PATH_EXTRA:+:${PATH_EXTRA}}
  115. PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
  116. DAEMON=/user/local/sbin/opensips
  117. NAME=opensips
  118. DESC=opensips
  119. CFGFILE=/usr/local/etc/opensips/opensips_trunk.cfg
  120. M4CFGFILE=/etc/opensips/opensips.m4
  121. M4ARCHIVEDIR=/etc/opensips/archive
  122. HOMEDIR=/var/run/opensips
  123. PIDFILE=$HOMEDIR/$NAME.pid
  124. DEFAULTS=/etc/default/opensips
  125. RUN_OPENSIPS=no
  126.  
  127.  
  128. [ -e "/lib/lsb/init-functions" ] && . /lib/lsb/init-functions
  129. test -f $DAEMON || exit 0
  130.  
  131. # Load startup options if available
  132. if [ -f $DEFAULTS ]; then
  133. . $DEFAULTS || true
  134. fi
  135.  
  136. if [ "$RUN_OPENSIPS" != "yes" ]; then
  137. echo "OpenSIPS not yet configured. Edit /etc/default/opensips first."
  138. exit 0
  139. fi
  140.  
  141.  
  142. check_opensips_config ()
  143. {
  144. # Check if opensips configuration is valid before starting the server
  145. set +e
  146. out=$($DAEMON -c -f $CFGFILE 2>&1 > /dev/null)
  147. retcode=$?
  148. set -e
  149. if [ "$retcode" != '0' ]; then
  150. echo "Not starting $DESC: invalid configuration file!"
  151. echo -e "\n$out\n"
  152. exit 1
  153. fi
  154. }
  155.  
  156. create_radius_seqfile ()
  157. {
  158. # Create a radius sequence file to be used by the radius client if
  159. # radius accounting is enabled. This is needed to avoid any issue
  160. # with the file not being writable if opensips first starts as user
  161. # root because DUMP_CORE is enabled and creates this file as user
  162. # root and then later it switches back to user opensips and cannot
  163. # write to the file. If the file exists before opensips starts, it
  164. # won't change it's ownership and will be writable for both root
  165. # and opensips, no matter what options are chosen at install time
  166. RADIUS_SEQ_FILE=/var/run/opensips/opensips_radius.seq
  167. if [ -d /var/run/opensips ]; then
  168. chown ${USER}:${GROUP} /var/run/opensips
  169.  
  170. if [ ! -f $RADIUS_SEQ_FILE ]; then
  171. touch $RADIUS_SEQ_FILE
  172. fi
  173.  
  174. chown ${USER}:${GROUP} $RADIUS_SEQ_FILE
  175. chmod 660 $RADIUS_SEQ_FILE
  176. fi
  177. }
  178.  
  179.  
  180. S_MEMORY=$((`echo $S_MEMORY | sed -e 's/[^0-9]//g'`))
  181. P_MEMORY=$((`echo $P_MEMORY | sed -e 's/[^0-9]//g'`))
  182. [ -z "$USER" ] && USER=opensips
  183. [ -z "$GROUP" ] && GROUP=opensips
  184. [ $S_MEMORY -le 0 ] && S_MEMORY=32
  185. [ $P_MEMORY -le 0 ] && P_MEMORY=32
  186.  
  187. if test "$DUMP_CORE" = "yes" ; then
  188. # set proper ulimit
  189. ulimit -c unlimited
  190.  
  191. # directory for the core dump files
  192. # COREDIR=/home/corefiles
  193. # [ -d $COREDIR ] || mkdir $COREDIR
  194. # chmod 777 $COREDIR
  195. # echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern
  196. fi
  197.  
  198. OPTIONS="-P $PIDFILE -m $S_MEMORY -M $P_MEMORY -u $USER -g $GROUP -f $CFGFILE"
  199.  
  200. case "$1" in
  201. start)
  202. check_opensips_config
  203. create_radius_seqfile
  204.  
  205. # dirs under /var/run will go away on reboot.
  206. mkdir -p "$HOMEDIR"
  207. chmod 775 "$HOMEDIR"
  208. chown "$USER:$GROUP" "$HOMEDIR" >/dev/null 2>&1 || true
  209.  
  210. # Generate config from M4
  211. if [ -f $M4CFGFILE ]; then
  212. m4 -Q $M4CFGFILE >$CFGFILE.tmp
  213. if [ $? != 0 ]; then
  214. echo "Cannot process m4 macro"
  215. rm "$CFGFILE.tmp"
  216. exit 1
  217. fi
  218.  
  219. [ -e $CFGFILE ] || touch $CFGFILE
  220.  
  221. # compare configs
  222. if [ `md5sum $CFGFILE|awk '{print $1}'` != `md5sum $CFGFILE.tmp|awk '{print $1}'` ]; then
  223. mkdir -p "$M4ARCHIVEDIR"
  224. mv "$CFGFILE" "$M4ARCHIVEDIR/$NAME.cfg-`date +%Y%m%d_%H%M%S`"
  225. fi
  226.  
  227.  
  228. mv "$CFGFILE.tmp" "$CFGFILE"
  229. chown $USER:$GROUP $CFGFILE
  230. chmod 640 $CFGFILE
  231. fi
  232.  
  233. log_daemon_msg "Starting $DESC" "$NAME"
  234. start-stop-daemon --start --quiet --pidfile $PIDFILE \
  235. --exec $DAEMON -- $OPTIONS || echo -n " already running"
  236. log_end_msg $?
  237. ;;
  238. stop)
  239. log_daemon_msg "Stopping $DESC" "$NAME"
  240. start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
  241. --exec $DAEMON
  242. log_end_msg $?
  243. ;;
  244. restart|force-reload)
  245. check_opensips_config
  246. create_radius_seqfile
  247.  
  248. log_daemon_msg "Restarting $DESC" "$NAME"
  249. start-stop-daemon --oknodo --stop --quiet --pidfile \
  250. $PIDFILE --exec $DAEMON
  251. sleep 1
  252. start-stop-daemon --start --quiet --pidfile \
  253. $PIDFILE --exec $DAEMON -- $OPTIONS
  254. log_end_msg $?
  255. ;;
  256. status)
  257. status_of_proc -p $PIDFILE "$DAEMON" "$NAME"
  258. ;;
  259. *)
  260. N=/etc/init.d/$NAME
  261. echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
  262. exit 1
  263. ;;
  264. esac
  265.  
  266. exit 0
  267.  
  268. ____________-----
  269.  
  270. _____________________________________________________________________________-----
  271. /etc/default/opensips
  272.  
  273.  
  274. #
  275. # OpenSIPS startup options
  276. #
  277.  
  278. # Set to yes to enable opensips, once configured properly.
  279. RUN_OPENSIPS=yes
  280.  
  281. # User to run as
  282. USER=opensips
  283.  
  284. # Group to run as
  285. GROUP=opensips
  286.  
  287. # Amount of shared memory to allocate for the running OpenSIPS server (in Mb)
  288. S_MEMORY=64
  289.  
  290. # Amount of pkg memory to allocate for the running OpenSIPS server (in Mb)
  291. P_MEMORY=4
  292.  
  293. # Enable the server to leave a core file when it crashes.
  294. # Set this to 'yes' to enable OpenSIPS to leave a core file when it crashes
  295. # or 'no' to disable this feature. This option is case sensitive and only
  296. # accepts 'yes' and 'no' and only in lowercase letters.
  297. # On some systems (e.g. Ubuntu 6.10, Debian 4.0) it is necessary to specify
  298. # a directory for the core files to get a dump. Look into the opensips
  299. # init file for an example configuration.
  300. DUMP_CORE=no
  301.  
  302. # Any additional OpenSIPS options
  303. OPTIONS=""
Add Comment
Please, Sign In to add comment