Managing service #1

This commit is contained in:
xdrm-brackets 2017-01-24 18:29:16 +01:00
parent 9550c6be38
commit d1b08e4e0c
3 changed files with 50 additions and 14 deletions

View File

@ -66,8 +66,6 @@ step2(){
test $confirm_format != "y" && echo "<<< aborting" && exit; test $confirm_format != "y" && echo "<<< aborting" && exit;
# (2) Init gpt entry # # (2) Init gpt entry #
# echo " ))) replace by real code (((";
echo -e "g\nw" | sudo fdisk $DEV 2> /dev/null > /dev/null; echo -e "g\nw" | sudo fdisk $DEV 2> /dev/null > /dev/null;
echo "<<< done"; echo "<<< done";
@ -125,12 +123,12 @@ step5(){
# (1) Removing pi entry # # (1) Removing pi entry #
echo " (.) Remove pi entry" echo " (.) Remove pi user entry"
echo " > /etc/shadow"; echo " > /etc/shadow";
sudo cat /mnt/etc/shadow | grep -vE "^pi:" | tee ./tmp/shadow > /dev/null; sudo cat /mnt/etc/shadow | grep -vE "^pi:" | tee ./tmp/shadow > /dev/null;
# (2) Adding 'sats' user and new pi entry # # (2) Adding 'sats' user and new pi entry #
echo " (.) Adding 'sats' user and updated pi entry"; echo " (.) Adding 'sats' user and updated 'pi'";
echo " > /etc/shadow"; echo " > /etc/shadow";
cat ./utility/shadow_append | tee -a ./tmp/shadow > /dev/null; cat ./utility/shadow_append | tee -a ./tmp/shadow > /dev/null;
cat ./tmp/shadow | sudo tee /mnt/etc/shadow | sudo tee /mnt/etc/shadow- > /dev/null; cat ./tmp/shadow | sudo tee /mnt/etc/shadow | sudo tee /mnt/etc/shadow- > /dev/null;
@ -270,20 +268,32 @@ step9(){
#========================================================# #========================================================#
step10(){ step10(){
echo "\n>>> [10] Set up SATS daemon"; echo "\n>>> [10] Set up SATS operating folder";
# (1) Create daemon folder # # (1) Create operating folder #
echo " (.) Create daemon folder"; echo " (.) Create operating folder";
sudo mkdir -p /mnt/home/sats/satsd; sudo mkdir -p /mnt/home/sats/satsd/source;
sudo mkdir -p /mnt/home/sats/satsd/log;
sudo mkdir -p /mnt/home/sats/satsd/conf;
sudo touch /mnt/home/sats/satsd/first_install;
# (2) Init git repository with ssh url # # (2) Set up SATS botting script #
echo " (.) Clone git repo with server's ssh url"; echo " (.) Set up SATS booting script";
sudo git clone --depth=1 ssh://smmp-server/home/gw/satsd /mnt/home/sats/satsd; cat ./utility/booting_script | sudo tee /mnt/home/sats/satsd/boot;
# (3) Set up git pull with good key # # (3) Set up service unit #
echo " (.) Set up \`git pull\` with registered ssh key"; echo " (.) Set up service unit (sats.service)";
cd /mnt/home/sats/git pull origin master; cat ./utility/service_unit | sudo tee /mnt/lib/systemd/system/sats.service;
# (4) Enable startup service unit #
echo " (.) Emulate \`systemctl enable sats.service\`";
sudo ln -fs /lib/systemd/system/sats.service /mnt/etc/systemd/system/sats.service;
# (5) Adjust permissions #
echo " (.) Adjust permissions";
sudo chown -R 666:666 /mnt/home/sats/satsd;
sudo chmod -R 770 /mnt/home/sats/satsd;
echo "<<< done"; echo "<<< done";

View File

@ -0,0 +1,15 @@
#!/bin/sh
# [1] first install (install source code)
if [ -e /home/sats/satsd/first_install ]; then
# install source code
git clone ssh://smmp-server/satsd /mnt/home/sats/satsd/source \
&& rm /home/sats/satsd/first_install \
|| exit;
fi
# [2] Propagate script
sh /home/sats/satsd/source/boot $*;

View File

@ -0,0 +1,11 @@
[Unit]
Description=SATS (Secure Authentication and Tracking SYSTEM) Daemon
After=multi-user.target
[Service]
Type=idle
ExecStart=-/bin/sh /home/sats/satsd/boot service 2>> /home/sats/satsd/log/boot.log >> /home/sats/satsd/log/boot.log
User=sats
[Install]
WantedBy=multi-user.target