-
Notifications
You must be signed in to change notification settings - Fork 1
/
oc_credentials
70 lines (60 loc) · 2.06 KB
/
oc_credentials
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
#! /bin/bash
# TODO: Error Checks
oCT_VERSION=0.0.1
CRED=~/.oC_credentials
if [ -f $CRED ]; then
# shellcheck source=~/.oC_credentials
. "$CRED"
else
cat > $CRED << "EOF"
#! /bin/bash
# Credentials for oC-Tools
# oC-Tools configuration:
oC_CREDS_VERSION=0.0.1
# VERIFY=YES #<- Please uncomment this line and remove the next line when you verified your configuration
VERIFY=
# ownCloud configuration:
oC_PATH=/var/www/owncloud
oC_CONFIG_PATH=$oC_PATH/config
oC_DATA_PATH=/mnt/owncloud/data
oC_INSTALL_PATH=/var/www/install
oc_UPDATE_PATH=/var/www/update
oC_THEME=$(more $oC_CONFIG_PATH/config.php |grep theme | awk -F$'\'' '{print $4}')
oC_VERSION=$(more $oC_CONFIG_PATH/config.php |grep version | awk -F$'\'' '{print $4}')
# Apache configuration:
APACHE_USER=www-data
APACHE_PATH=/var/www/owncloud
APACHE_CONFIG_PATH=/etc/apache
APACHE_LOG_PATH=/var/log/apache2
# Database configuration:
DB_NAME=$(more $oC_CONFIG_PATH/config.php |grep dbname | awk -F$'\'' '{print $4}')
DB_HOST=$(more $oC_CONFIG_PATH/config.php |grep dbhost | awk -F$'\'' '{print $4}')
DB_PREFIX=$(more $oC_CONFIG_PATH/config.php |grep dbtableprefix | awk -F$'\'' '{print $4}')
DB_USER=$(more $oC_CONFIG_PATH/config.php |grep dbuser | awk -F$'\'' '{print $4}')
DB_PASSWORD=$(more $oC_CONFIG_PATH/config.php |grep dbpassword | awk -F$'\'' '{print $4}')
# PHP configuraion:
PHP_PATH=oC_PATH=/usr/bin
EOF
tput setaf 1
echo $CRED template created with a default configuration. Please edit the file to verify your information.
tput sgr0
exit 1
fi
if [ -z "$VERIFY" ]; then
tput setaf 1
echo "$CRED has empty VERIFY input. Please edit the file to verify your information"
tput sgr0
exit 1
fi
if [ "$oC_CREDS_VERSION" != "$oCT_VERSION" ]; then
tput setaf 1
mv "$CRED" "$CRED"_$(date +"%Y%m%d").bak
echo "$CRED" is an older version!
echo File moved to "$CRED"_$(date +"%Y%m%d").bak
echo Please verify the information and add a line: oC_CREDS_VERSION="$oCT_VERSION"
tput sgr0
exit 1
fi
if [ "$1" != "check" ]; then
echo Your oC-Tools credentials ist up to date in version "$oC_CREDS_VERSION"
fi