also looking at this
test(fleet): prove the database and hostname halves of a transfer on real machines
#184
4 files
+363
-3
| @@ -177,8 +177,15 @@ export function buildSetHostnameScript(next: string): string { | ||
| 177 | 177 | `hostnamectl set-hostname ${quoted} 2>/dev/null || { echo ${quoted} > /etc/hostname && hostname ${quoted}; }`, |
| 178 | 178 | // Replace the old name where it stands rather than appending: a second |
| 179 | 179 | // 127.0.1.1 line would leave the box resolving its own name two ways. |
| 180 | `if grep -q "127.0.1.1" /etc/hosts; then`, | |
| 181 | ` sed -i "s/^127\\.0\\.1\\.1.*/127.0.1.1\\t${next}/" /etc/hosts`, | |
| 180 | // | |
| 181 | // Rewritten through a variable and truncating redirect rather than `sed -i`, | |
| 182 | // which renames a temp file over the target and so fails outright when | |
| 183 | // /etc/hosts is a bind mount (every container), is hard-linked, or lives on | |
| 184 | // a filesystem the rename cannot cross. Writing in place keeps the inode and | |
| 185 | // works in all of those. | |
| 186 | `if grep -q "^127.0.1.1" /etc/hosts; then`, | |
| 187 | ` TS_CLOUD_HOSTS="$(sed -E "s/^127\\.0\\.1\\.1.*/127.0.1.1\\t${next}/" /etc/hosts)"`, | |
| 188 | ` printf '%s\\n' "$TS_CLOUD_HOSTS" > /etc/hosts`, | |
| 182 | 189 | 'else', |
| 183 | 190 | ` printf '127.0.1.1\\t%s\\n' ${quoted} >> /etc/hosts`, |
| 184 | 191 | 'fi', |