| |
@@ -0,0 +1,63 @@
|
| |
+ #!/usr/bin/env bash
|
| |
+
|
| |
+
|
| |
+ # check if init was done already
|
| |
+ if [ -f $HOME/.config/taskotron/init_done ]; then
|
| |
+ echo -n "Taskotron and testcloud already initialized, do you want to redo the init? "
|
| |
+ read -r -p "[y/N] " response
|
| |
+ response=${response,,} #to lower
|
| |
+ if [[ $response =~ ^(yes|y)$ ]]; then
|
| |
+ rm -f /var/lib/taskotron/init_done
|
| |
+ else
|
| |
+ exit 1
|
| |
+ fi
|
| |
+ fi
|
| |
+
|
| |
+ # get the path to pubkey
|
| |
+ PUBKEY_PATH=
|
| |
+ if [ -f ~/.ssh/id_rsa.pub ]; then
|
| |
+ echo -n "Enter path to ssh pubkey (leave empty to use ~/.ssh/id_rsa.pub):"
|
| |
+ read PUBKEY_PATH
|
| |
+ if [ -z "$PUBKEY_PATH" ]; then
|
| |
+ PUBKEY_PATH="$HOME/.ssh/id_rsa.pub"
|
| |
+ fi
|
| |
+ else
|
| |
+ echo -n "Enter path to ssh pubkey:"
|
| |
+ read PUBKEY_PATH
|
| |
+ if [ -z "$PUBKEY_PATH" ]; then
|
| |
+ echo "No pubkey specified, exiting."
|
| |
+ exit 1
|
| |
+ fi
|
| |
+ fi
|
| |
+
|
| |
+ # read the pubkey
|
| |
+ PUBKEY=
|
| |
+ if [ -f $PUBKEY_PATH ]; then
|
| |
+ PUBKEY=`cat $PUBKEY_PATH`
|
| |
+ else
|
| |
+ echo "File $PUBKEY_PATH does not exist."
|
| |
+ exit 1
|
| |
+ fi
|
| |
+
|
| |
+ # generate config for testcloud
|
| |
+ mkdir -p $HOME/.config/testcloud
|
| |
+ cat > $HOME/.config/testcloud/settings.py <<EOF
|
| |
+ USER_DATA = """#cloud-config
|
| |
+ users:
|
| |
+ - default
|
| |
+ - name: root
|
| |
+ password: %s
|
| |
+ chpasswd: { expire: False }
|
| |
+ ssh-authorized-keys:
|
| |
+ - $PUBKEY
|
| |
+ """
|
| |
+ EOF
|
| |
+
|
| |
+ # setup groups
|
| |
+ echo "Adding $USER to groups 'taskotron' and 'testcloud', will need superuser access..."
|
| |
+ sudo gpasswd -a $USER testcloud
|
| |
+ sudo gpasswd -a $USER taskotron
|
| |
+ echo "User $USER has beed added to groups 'taskotron' and 'testcloud', relogin may be required"
|
| |
+
|
| |
+ mkdir -p $HOME/.config/taskotron
|
| |
+ touch $HOME/.config/taskotron/init_done
|
| |
Summary: Script that inits taskotron and testcloud after installation. This is PoC to open a discussion what else we'd like to see in init script.
Test Plan: run the script
Reviewers: kparal, tflink, mkrizek, jskladan
Subscribers: tflink
Tags: #libtaskotron
Differential Revision: https://fedorapeople.org/groups/qa/phabarchive/differentials/phab.qa.fedoraproject.org/D966.html