diff --git a/perl-script/conf/lingyin.rc b/perl-script/conf/lingyin.rc new file mode 100644 index 0000000..ac98543 --- /dev/null +++ b/perl-script/conf/lingyin.rc @@ -0,0 +1,17 @@ +#!/bin/ksh +# +# lingyind + +daemon="cd /tilde/lyadmin/ && . /tilde/lyadmin/venv/bin/activate && python3 /tilde/lyadmin/app.py &" +daemon_user="lingyind" + +. /etc/rc.d/rc.subr + +pexp="python3 /tilde/lyadmin/app.py" +rc_reload=NO + +rc_stop() { + pkill -f "^${pexp}" +} + +rc_cmd $1 diff --git a/perl-script/provision.pl b/perl-script/provision.pl index d38c2f7..00a2e2b 100644 --- a/perl-script/provision.pl +++ b/perl-script/provision.pl @@ -71,6 +71,11 @@ printf("generating virtual enviornment...\n"); system("su $SVC_ACCT -c 'python3 -m venv venv'"); system("su $SVC_ACCT -c '. ./venv/bin/activate && pip3 install -r requirements.txt'"); +system("cp ./perl-script/conf/lingyin.rc /etc/rc.d/lingyind"); +system("chmod 755 /etc/rc.d/lingyind"); +system("rcctl enable lingyind"); +system("rcctl start lingyind"); + system("pkg_add p5-JSON"); # Install apache @@ -95,14 +100,16 @@ system("sed -i -e 's/\\(<\\/Directory>\\)/ Options -Indexes\\ # Change the port to 5001 system("sed -i -e 's/^\\(.\\)*Listen *80/\\1Listen 5001/' /etc/apache2/httpd2.conf"); # rev up those apache processes! +system("rcctl enable apache2"); system("rcctl start apache2"); - # Install and config haproxy system("pkg_add haproxy"); printf("configuring haproxy\n"); system("cp ./perl-script/conf/haproxy.cfg /etc/haproxy/haproxy.cfg"); +system("rcctl enable haproxy"); system("rcctl start haproxy"); + printf("dont forget to setup your ssh pub key at /home/$admin_un/.ssh/authorized_keys\n");