Managing service #1
This commit is contained in:
parent
9550c6be38
commit
d1b08e4e0c
38
clone/clone
38
clone/clone
|
@ -66,8 +66,6 @@ step2(){
|
|||
test $confirm_format != "y" && echo "<<< aborting" && exit;
|
||||
|
||||
# (2) Init gpt entry #
|
||||
# echo " ))) replace by real code (((";
|
||||
|
||||
echo -e "g\nw" | sudo fdisk $DEV 2> /dev/null > /dev/null;
|
||||
|
||||
echo "<<< done";
|
||||
|
@ -125,12 +123,12 @@ step5(){
|
|||
|
||||
|
||||
# (1) Removing pi entry #
|
||||
echo " (.) Remove pi entry"
|
||||
echo " (.) Remove pi user entry"
|
||||
echo " > /etc/shadow";
|
||||
sudo cat /mnt/etc/shadow | grep -vE "^pi:" | tee ./tmp/shadow > /dev/null;
|
||||
|
||||
# (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";
|
||||
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;
|
||||
|
@ -270,21 +268,33 @@ step9(){
|
|||
#========================================================#
|
||||
step10(){
|
||||
|
||||
echo "\n>>> [10] Set up SATS daemon";
|
||||
echo "\n>>> [10] Set up SATS operating folder";
|
||||
|
||||
|
||||
# (1) Create daemon folder #
|
||||
echo " (.) Create daemon folder";
|
||||
sudo mkdir -p /mnt/home/sats/satsd;
|
||||
# (1) Create operating folder #
|
||||
echo " (.) Create operating folder";
|
||||
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 #
|
||||
echo " (.) Clone git repo with server's ssh url";
|
||||
sudo git clone --depth=1 ssh://smmp-server/home/gw/satsd /mnt/home/sats/satsd;
|
||||
# (2) Set up SATS botting script #
|
||||
echo " (.) Set up SATS booting script";
|
||||
cat ./utility/booting_script | sudo tee /mnt/home/sats/satsd/boot;
|
||||
|
||||
# (3) Set up git pull with good key #
|
||||
echo " (.) Set up \`git pull\` with registered ssh key";
|
||||
cd /mnt/home/sats/git pull origin master;
|
||||
# (3) Set up service unit #
|
||||
echo " (.) Set up service unit (sats.service)";
|
||||
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";
|
||||
|
||||
|
|
|
@ -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 $*;
|
|
@ -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
|
Loading…
Reference in New Issue