@@ -69,11 +69,19 @@ export GHE_SNAPSHOT_TIMESTAMP
6969# all backups should be written for the current invocation.
7070GHE_SNAPSHOT_DIR=" $GHE_DATA_DIR " /" $GHE_SNAPSHOT_TIMESTAMP "
7171
72- # The root location of all persistent data stores on the remote side. This is
73- # always "/data" for GitHub instances. Use of this variable allows
72+ # The root location of persistent data and applications on the remote side. This
73+ # is always "/data" for GitHub instances. Use of this variable allows
7474# the location to be overridden in tests.
7575: ${GHE_REMOTE_DATA_DIR:= " /data" }
7676
77+ # The root location of user data stores such as git repositories, pages sites,
78+ # elasticsearch indices, etc. This is "/data" under 1.x filesystem layouts and
79+ # "/data/user" under the 2.x filesystem layout. The location is adjusted
80+ # dynamically in ghe_remote_version_config() immediately after obtaining the
81+ # remote version. Utilities that transfer data in and out of the appliance
82+ # should use this variable to ensure proper behavior under different versions.
83+ : ${GHE_REMOTE_DATA_USER_DIR:= " $GHE_REMOTE_DATA_DIR " }
84+
7785# The location of the license file on the remote side. This is always
7886# "/data/enterprise/enterprise.ghl" for GitHub instances. Use of this variable
7987# allows the location to be overridden in tests.
@@ -96,6 +104,21 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP"
96104# Set "true" to get verbose logging of all ssh commands on stderr
97105: ${GHE_VERBOSE_SSH:= false}
98106
107+
108+ # ##############################################################################
109+ # ## Dynamic remote version config
110+
111+ # Adjusts remote paths based on the version of the remote appliance. This is
112+ # called immediately after the remote version is obtained by
113+ # ghe_remote_version_required(). Child processes inherit the values set here.
114+ ghe_remote_version_config () {
115+ if [ " $GHE_VERSION_MAJOR " -gt 1 ]; then
116+ GHE_REMOTE_DATA_USER_DIR=" $GHE_REMOTE_DATA_DIR /user"
117+ fi
118+ export GHE_REMOTE_DATA_DIR GHE_REMOTE_DATA_USER_DIR
119+ export GHE_REMOTE_LICENSE_FILE GHE_REMOTE_METADATA_FILE
120+ }
121+
99122# ##############################################################################
100123# ## Utility functions
101124
@@ -138,6 +161,7 @@ ghe_remote_version_required () {
138161 export GHE_REMOTE_VERSION
139162
140163 ghe_parse_remote_version " $GHE_REMOTE_VERSION "
164+ ghe_remote_version_config " $GHE_REMOTE_VERSION "
141165 fi
142166 true
143167}
0 commit comments