2018-11-11 08:19:04 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -ex
|
2018-09-08 19:19:12 -07:00
|
|
|
|
|
|
|
[[ $(uname) = Linux ]] || exit 1
|
|
|
|
[[ $USER = root ]] || exit 1
|
|
|
|
|
2019-07-22 15:13:08 -07:00
|
|
|
if grep -q solana /etc/passwd ; then
|
|
|
|
echo "User solana already exists"
|
|
|
|
else
|
|
|
|
adduser solana --gecos "" --disabled-password --quiet
|
|
|
|
adduser solana sudo
|
|
|
|
adduser solana adm
|
|
|
|
echo "solana ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
|
|
|
id solana
|
2018-09-08 19:19:12 -07:00
|
|
|
|
2019-09-03 17:51:16 -07:00
|
|
|
[[ -r /solana-scratch/id_ecdsa ]] || exit 1
|
|
|
|
[[ -r /solana-scratch/id_ecdsa.pub ]] || exit 1
|
2018-09-08 19:19:12 -07:00
|
|
|
|
2019-07-22 15:13:08 -07:00
|
|
|
sudo -u solana bash -c "
|
2019-10-30 19:41:24 -07:00
|
|
|
echo 'PATH=\"/home/solana/.cargo/bin:$PATH\"' > /home/solana/.profile
|
2019-07-22 15:13:08 -07:00
|
|
|
mkdir -p /home/solana/.ssh/
|
|
|
|
cd /home/solana/.ssh/
|
2019-09-03 17:51:16 -07:00
|
|
|
cp /solana-scratch/id_ecdsa.pub authorized_keys
|
2019-07-22 15:13:08 -07:00
|
|
|
umask 377
|
2019-09-03 17:51:16 -07:00
|
|
|
cp /solana-scratch/id_ecdsa id_ecdsa
|
2019-07-22 15:13:08 -07:00
|
|
|
echo \"
|
|
|
|
Host *
|
|
|
|
BatchMode yes
|
|
|
|
IdentityFile ~/.ssh/id_ecdsa
|
|
|
|
StrictHostKeyChecking no
|
|
|
|
\" > config
|
|
|
|
"
|
|
|
|
fi
|