forked from openshift/ocm-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
executable file
·59 lines (48 loc) · 1.46 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
cd $(dirname $0)
CONFIG_DIR=${HOME}/.config/ocm-container
function init_new_config() {
if [ ! -f ${CONFIG_DIR}/env.source ]
then
echo "Initializing Default Configuration"
cp env.source.sample ${CONFIG_DIR}/env.source
else
echo "ocm-container is already configured."
fi
}
mkdir -p ${CONFIG_DIR}
if [ -f env.source ]
then
echo "We see you already have a local configuration file. Would you like us to:"
echo " 1: Move the config file to the new config location"
echo " 2: Symlink the config file to the new config location"
echo " 3: Create a new config file at the new config location"
echo " 4: Do nothing and exit"
read -n 1 -p "Select 1-4: " prev_config_selection
echo
if [ $prev_config_selection == "1" ]
then
echo "Moving configuration file"
mv env.source ${CONFIG_DIR}
elif [ $prev_config_selection == "2" ]
then
echo "Symlinking configuration file"
ln -s env.source $CONFIG_DIR/env.source
elif [ $prev_config_selection == "3" ]
then
init_new_config
else
echo "Exiting."
exit 0
fi
else
init_new_config
fi
echo "Creating symlink for ocm-container binary (requires sudo permissions...)"
sudo ln -sfn "$(pwd)/ocm-container.sh" /usr/local/bin/ocm-container
echo
echo "Tip: Many developers like to add the following alias:"
echo "alias ocm-container-stg=\"OCM_URL=staging ocm-container\""
echo
echo
echo "ocm-container configuration can be customized by editing ${CONFIG_DIR}/env.source"