forked from OCSInventory-NG/OCSInventory-Docker-Image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
95 lines (73 loc) · 2.96 KB
/
setup.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
echo "Welcome to OCSInventory Docker image setup"
echo "Please specify container name"
read containerName
while ! [[ $containerName =~ ^[[:lower:]_]+$ ]]; do
echo "Please choose another name without uppercase and number, only letters."
read containerName
done
echo "Your container name: $containerName"
echo "Please specify your database parameters in next steps:"
echo "Database name"
read databaseName
while ! [[ $databaseName =~ ^[a-zA-Z_0-9]+$ ]]; do
echo "Please choose valid database name"
read databaseName
done
echo "Database server READ"
read databaseServerRead
while ! [[ $databaseServerRead =~ ^[a-zA-Z_0-9.]+$ ]]; do
echo "Please choose valid database server"
read databaseServerRead
done
echo "Database server WRITE"
read databaseServerWrite
while ! [[ $databaseServerWrite =~ ^[a-zA-Z_0-9.]+$ ]]; do
echo "Please choose valid database server"
read databaseServerWrite
done
echo "Database user"
read databaseUser
while ! [[ $databaseUser =~ ^[a-zA-Z_0-9]+$ ]]; do
echo "Please choose valid database user"
read databaseUser
done
echo "Database password"
read databasePassword
while [[ -z $databasePassword ]]; do
echo "Please choose valid database password"
read databasePassword
done
echo "Do you want to attach existing data volume ? (yes / no)"
read dataVolume
VOLUME_ARGS=""
if [ $dataVolume = "yes" ]
then
echo "Name of data volume:"
read dataVolumeName
VOLUME_ARGS="-v ${dataVolumeName}:/usr/share/ocsinventory-reports/ocsreports/ -v ${dataVolumeName}:/etc/ocsinventory-reports/ -v ${dataVolumeName}:/var/lib/ocsinventory-reports/"
fi
BASEPATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
#MODIFY APACHE CONFIGURATION
#sed -i -e "s/PerlSetEnv OCS_DB_HOST localhost/PerlSetEnv OCS_DB_HOST ${databaseServerWrite}/g" $BASEPATH/conf/z-ocsinventory-server.conf
#sed -i -e "s/PerlSetEnv OCS_DB_NAME ocsweb/PerlSetEnv OCS_DB_NAME ${databaseName}/g" $BASEPATH/conf/z-ocsinventory-server.conf
#sed -i -e "s/PerlSetEnv OCS_DB_LOCAL ocsweb/PerlSetEnv OCS_DB_LOCAL ${databaseName}/g" $BASEPATH/conf/z-ocsinventory-server.conf
#sed -i -e "s/PerlSetEnv OCS_DB_USER ocs/PerlSetEnv OCS_DB_USER ${databaseUser}/g" $BASEPATH/conf/z-ocsinventory-server.conf
#sed -i -e "s/PerlSetVar OCS_DB_PWD ocs/PerlSetVar OCS_DB_PWD ${databasePassword}/g" $BASEPATH/conf/z-ocsinventory-server.conf
COMMAND="docker run -p 80:80 --name ${containerName} -e OCS_DBNAME=${databaseName} \
-e OCS_DBSERVER_READ=${databaseServerRead} -e OCS_DBSERVER_WRITE=${databaseServerWrite} \
-e OCS_DBUSER=${databaseUser} -e OCS_DBPASS=${databasePassword} ${VOLUME_ARGS} -itd ocsinventory/ocsinventory-docker-image:latest"
echo "========================================="
echo ""
echo "The command to launch your container is:"
echo ""
echo ${COMMAND}
echo ""
echo "=========================================="
echo ""
echo "Do you want to run container now ? (yes / no)"
read launchNow
if [ $launchNow = "yes" ]
then
${COMMAND}
fi