Fixed file creation trouble, etc

This commit is contained in:
xdrm-brackets 2017-01-21 16:43:45 +01:00
parent 103f367059
commit cf67b9a7f7
1 changed files with 26 additions and 18 deletions

View File

@ -1,5 +1,11 @@
#!/bin/sh
[ ! -e ./tmp -o ! -d ./tmp ] && mkdir ./tmp;
[ ! -e ./server -o ! -d ./server ] && mkdir ./server;
[ ! -e ./server/maintenance -o ! -d ./server/maintenance ] && mkdir ./server/maintenance;
# [!] Check parameter : device file
#========================================================#
@ -34,7 +40,7 @@ step1(){
read -p " (!) umount $mounted (y/n) [n]" unmount;
test -n "$unmount" && test $unmount = "y" && sudo umount $mounted 2>> /dev/null >> /dev/null && echo " > unmounted";
test -n "$unmount" && test $unmount = "y" && sudo umount $mounted 2> /dev/null > /dev/null && echo " > unmounted";
done;
echo "<<< done";
@ -57,7 +63,7 @@ step2(){
# (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";
@ -166,30 +172,32 @@ step6(){
# [7] Manage SSH keys #
#========================================================#
step7(){
echo "\n>>> [7] Create ssh keys";
echo "\n>>> [7] Manage ssh keys";
# (1) Create ssh key pair #
echo " (.) Create ssh key [ecdsa:521]";
echo -e "\n\n" | ssh-keygen -t ecdsa -b 521 -C "[ECDSA:521] SATS" -f tmp/id_ecdsa;
ssh-keygen -t ecdsa -b 521 -C "[ECDSA:521] SATS" -f ./tmp/id_ecdsa -P "" 2> /dev/null > /dev/null;
# (2) Add public key to server's `authorized_keys` file #
echo " (.) Add public key to server's list";
cat tmp/id_ecdsa.pub >> server/authorized_keys;
test ! -e ./server/authorized_keys && touch ./server/authorized_keys;
cat ./tmp/id_ecdsa.pub >> ./server/authorized_keys;
# (3) Create ssh file system #
echo " (.) init ssh folder (/home/sats-user/.ssh)";
sudo mkdir /mnt/home/sats-user/.ssh;
echo " (.) Init ssh folder (/home/sats-user/.ssh)";
sudo mkdir -p /mnt/home/sats-user/.ssh;
# (4) Add both keys to sats-user files #
echo " (.) add keys to ssh folder";
sudo mv tmp/id_ecdsa /mnt/home/sats-user/.ssh/id_ecdsa;
sudo mv tmp/id_ecdsa.pub /mnt/home/sats-user/.ssh/id_ecdsa.pub;
echo " (.) Add keys to ssh folder";
sudo mv ./tmp/id_ecdsa /mnt/home/sats-user/.ssh/id_ecdsa;
sudo mv ./tmp/id_ecdsa.pub /mnt/home/sats-user/.ssh/id_ecdsa.pub;
# (5) Add maintenance keys #
echo " (.) Add maintenance keys'";
cat server/maintenance/*.pub | sudo tee /mnt/home/sats-user/.ssh/authorized_keys;
sudo touch /mnt/home/sats-user/.ssh/authorized_keys;
cat ./server/maintenance/*.pub | sudo tee /mnt/home/sats-user/.ssh/authorized_keys > /dev/null;
# (6) Set up permissions #
echo " (.) Set up permissions";