summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2018-05-15 23:34:18 +0200
committerLinus Färnstrand <linus@mullvad.net>2018-05-15 23:34:18 +0200
commit539532d275ade3466c6040574c902e66c171d4e1 (patch)
treeab22dfbe1515d860d2000e42d9887bbe89bfe754
parent9d546c06d9913528166363c72035f87eca8c0d24 (diff)
parentfa92c7b11f9f2bf5632bc6b9b7b2ad6fb4220287 (diff)
downloadmullvadvpn-539532d275ade3466c6040574c902e66c171d4e1.tar.xz
mullvadvpn-539532d275ade3466c6040574c902e66c171d4e1.zip
Merge branch 'move-settings-on-unix'
-rw-r--r--CHANGELOG.md1
-rwxr-xr-xdist-assets/pkg-scripts/preinstall29
-rw-r--r--mullvad-daemon/src/settings.rs16
-rw-r--r--package.json2
4 files changed, 41 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aaa037bfb6..c3804f41f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,7 @@ Line wrap the file at 100 chars. Th
- Improve account token hint to be the same length as an expected token.
- The macOS installer is changed from dmg to pkg format.
- The backend daemon is installed as a launchd daemon and started on macOS on install.
+- Move logs to `/var/log/mullvad-daemon/` and settings to `/etc/mullvad-daemon/` on macOS.
### Fixed
- Fix a bug in account input field that advanced the cursor to the end regardless its prior
diff --git a/dist-assets/pkg-scripts/preinstall b/dist-assets/pkg-scripts/preinstall
index 08ada60d4d..db9c296fd6 100755
--- a/dist-assets/pkg-scripts/preinstall
+++ b/dist-assets/pkg-scripts/preinstall
@@ -9,12 +9,39 @@ exec 2>&1 > $LOG_DIR/preinstall.log
echo "Running preinstall at $(date)"
+# Uninstall <=2018.1 versions of the app
OLD_INSTALL_DIR="/Applications/MullvadVPN.app"
-
if [ -d "$OLD_INSTALL_DIR" ]; then
echo "Found old Mullvad VPN install at $OLD_INSTALL_DIR. Stopping and uninstalling"
pkill MullvadVPN || true
pkill mullvad-daemon || true
+ sleep 0.5
rm -rf "$OLD_INSTALL_DIR"
fi
+# Migrate settings from <=2018.1 paths
+OLD_SETTINGS_DIR="$HOME/Library/Application Support/mullvad-daemon"
+NEW_SETTINGS_DIR="/etc/mullvad-daemon"
+if [ -d "$OLD_SETTINGS_DIR" ]; then
+ echo "Found old setting dir $OLD_SETTINGS_DIR. Moving to $NEW_SETTINGS_DIR"
+ mkdir -p "$NEW_SETTINGS_DIR"
+ mv "$OLD_SETTINGS_DIR/settings.json" "$NEW_SETTINGS_DIR/settings.json" || true
+ rm -rf "$OLD_SETTINGS_DIR"
+fi
+
+# Delete logs from <=2018.1 paths
+OLD_LOG_DIR="$HOME/Library/Logs/MullvadVPN"
+if [ -d "$OLD_LOG_DIR" ]; then
+ echo "Found old log dir $OLD_LOG_DIR. Deleting"
+ rm -rf "$OLD_LOG_DIR"
+fi
+
+# Migrate cache files from <=2018.1 paths
+OLD_CACHE_DIR="$HOME/Library/Caches/mullvad-daemon"
+NEW_CACHE_DIR="/var/root/Library/Caches/mullvad-daemon"
+if [ -d "$OLD_CACHE_DIR" ]; then
+ echo "Found old cache dir at $OLD_CACHE_DIR, moving to $NEW_CACHE_DIR"
+ mkdir -p "$NEW_CACHE_DIR"
+ mv "$OLD_CACHE_DIR"/* "$NEW_CACHE_DIR/" || true
+ rm -rf "$OLD_CACHE_DIR"
+fi
diff --git a/mullvad-daemon/src/settings.rs b/mullvad-daemon/src/settings.rs
index 9050d289c7..61017dee67 100644
--- a/mullvad-daemon/src/settings.rs
+++ b/mullvad-daemon/src/settings.rs
@@ -1,7 +1,5 @@
extern crate serde_json;
-use app_dirs;
-
use mullvad_types::relay_constraints::{
Constraint, LocationConstraint, RelayConstraints, RelaySettings, RelaySettingsUpdate,
};
@@ -18,11 +16,11 @@ error_chain! {
}
ReadError(path: PathBuf) {
description("Unable to read settings file")
- display("Unable to read settings from {}", path.to_string_lossy())
+ display("Unable to read settings from {}", path.display())
}
WriteError(path: PathBuf) {
description("Unable to write settings file")
- display("Unable to write settings to {}", path.to_string_lossy())
+ display("Unable to write settings to {}", path.display())
}
ParseError {
description("Malformed settings")
@@ -88,8 +86,16 @@ impl Settings {
serde_json::to_writer_pretty(file, self).chain_err(|| ErrorKind::WriteError(path))
}
+ #[cfg(unix)]
+ fn get_settings_path() -> Result<PathBuf> {
+ let dir = PathBuf::from("/etc/mullvad-daemon");
+ ::std::fs::create_dir_all(&dir).chain_err(|| ErrorKind::DirectoryError)?;
+ Ok(dir.join(SETTINGS_FILE))
+ }
+
+ #[cfg(windows)]
fn get_settings_path() -> Result<PathBuf> {
- let dir = app_dirs::app_root(app_dirs::AppDataType::UserConfig, &::APP_INFO)
+ let dir = ::app_dirs::app_root(::app_dirs::AppDataType::UserConfig, &::APP_INFO)
.chain_err(|| ErrorKind::DirectoryError)?;
Ok(dir.join(SETTINGS_FILE))
}
diff --git a/package.json b/package.json
index bb794f5fe9..a4f8edce34 100644
--- a/package.json
+++ b/package.json
@@ -74,7 +74,7 @@
"lint": "eslint --no-ignore scripts app test *.js",
"flow": "flow",
"pack": "run-s pack:mac pack:win pack:linux",
- "pack:mac": "./pre-mac-sign.sh && cross-env BABEL_ENV=electron run-s private:clean private:compile private:build:mac",
+ "pack:mac": "./pre-mac-sign.sh && cross-env BABEL_ENV=electron run-s private:clean private:compile private:build:mac && rm -r ./dist/mac",
"pack:win": "cross-env BABEL_ENV=electron run-s private:clean private:compile private:build:win",
"pack:linux": "cross-env BABEL_ENV=electron run-s private:clean private:compile private:build:linux",
"private:build:mac": "npm run private:build -- --mac",