diff options
author | Shaun Taheri <shaun@advancedtelematic.com> | 2016-07-20 15:09:41 +0200 |
---|---|---|
committer | Shaun Taheri <shaun@advancedtelematic.com> | 2016-07-21 11:48:59 +0200 |
commit | f6fd75eb0a8d691fc1c4a8338621bfc3db1574db (patch) | |
tree | b66bc68e5a24308fb7b24048f37c2daed247c425 | |
parent | 488ec993f4fa66501ac0c5e28eb86e12bbfcce8e (diff) | |
download | rvi_sota_client-f6fd75eb0a8d691fc1c4a8338621bfc3db1574db.tar.gz |
Rename binary from ota_plus_client to rvi_sota_client
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 8 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | pkg/Dockerfile | 4 | ||||
-rw-r--r-- | pkg/ota-client.service | 15 | ||||
-rwxr-xr-x | pkg/pkg.sh | 14 | ||||
-rw-r--r-- | pkg/sota.toml.template (renamed from pkg/ota.toml.template) | 0 | ||||
-rw-r--r-- | pkg/sota_client.service (renamed from pkg/yocto/ota-plus-client.service) | 2 | ||||
-rwxr-xr-x | pkg/start-up.sh | 12 | ||||
-rwxr-xr-x | pkg/tailor.sh | 17 | ||||
-rw-r--r-- | sota.toml (renamed from ota.toml) | 0 | ||||
-rw-r--r-- | src/datatype/config.rs | 2 | ||||
-rw-r--r-- | src/interaction_library/http.rs | 2 | ||||
-rw-r--r-- | src/interaction_library/websocket.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 4 | ||||
-rw-r--r-- | tests/ota_plus_client_tests.rs | 4 |
18 files changed, 45 insertions, 58 deletions
@@ -1,4 +1,3 @@ target -pkg/ota_plus_client -src/.version +pkg/sota_client .tmp* @@ -1,5 +1,5 @@ [root] -name = "ota-plus-client" +name = "sota_client" version = "0.1.0" dependencies = [ "chan 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1,14 +1,16 @@ [package] -name = "ota-plus-client" +name = "sota_client" version = "0.1.0" -authors = ["Txus <txus@advancedtelematic.com>"] +authors = ["Jerry Trieu <jerry@advancedtelematic.com", + "Shaun Taheri <shaun@advancedtelematic.com>", + "Stevan Andjelkovic <steven@advancedtelematic.com"] [lib] name = "libotaplus" path = "src/lib.rs" [[bin]] -name = "ota_plus_client" +name = "sota_client" path = "src/main.rs" doc = false @@ -13,7 +13,7 @@ all: test deb rpm ## Run tests and make new DEB and RPM packages. run: image ## Run the client inside a Docker container. @docker run --rm -it --net=host \ --env OTA_NO_AUTH=true \ - advancedtelematic/rvi-sota-client:latest + advancedtelematic/sota-client:latest clean: ## Remove all compiled libraries, builds and temporary files. @cargo clean @@ -34,10 +34,10 @@ client-musl: src/ ## Make a statically linked release build of the client. --workdir /build \ advancedtelematic/rust:latest \ cargo build --release --target=$(MUSL_TARGET) - @cp target/$(MUSL_TARGET)/release/ota_plus_client pkg/ + @cp target/$(MUSL_TARGET)/release/sota_client pkg/ image: client-musl ## Build a Docker image from a statically linked binary. - @docker build -t advancedtelematic/rvi-sota-client pkg + @docker build -t advancedtelematic/sota-client pkg define make-pkg @docker run --rm \ @@ -48,7 +48,7 @@ define make-pkg --volume ~/.cargo:/cargo \ --volume $(CURDIR):/build \ --workdir /build \ - advancedtelematic/rvi-sota-client:latest \ + advancedtelematic/sota-client:latest \ pkg/pkg.sh $@ endef @@ -47,7 +47,7 @@ Variable | Default value ### Provisioning -Setting `PROVISION=true` will output a newly generated `ota.toml` to STDOUT then quit, rather than starting the client. +Setting `PROVISION=true` will output a newly generated `sota.toml` to STDOUT then quit, rather than starting the client. ### Example @@ -56,7 +56,7 @@ docker run --rm -it --net=host \ --env OTA_AUTH_URL="http://auth-plus-staging.gw.prod01.advancedtelematic.com" \ --env OTA_WEB_URL="http://ota-plus-web-staging.gw.prod01.advancedtelematic.com" \ --env OTA_CORE_URL="http://ota-plus-core-staging.gw.prod01.advancedtelematic.com" \ - advancedtelematic/ota-plus-client:latest + advancedtelematic/sota-client:latest ``` The `--net=host` flag is only required if the Docker container needs to communicate with other containers running on the same host. diff --git a/pkg/Dockerfile b/pkg/Dockerfile index 20606de..f8349ea 100644 --- a/pkg/Dockerfile +++ b/pkg/Dockerfile @@ -1,7 +1,7 @@ FROM advancedtelematic/fpm -COPY ota_plus_client /usr/bin/ -COPY ota.toml.template /etc/ +COPY sota_client /usr/bin/ +COPY sota.toml.template /etc/ COPY start-up.sh /usr/bin/ ENV LANG="en_US.UTF-8" diff --git a/pkg/ota-client.service b/pkg/ota-client.service deleted file mode 100644 index 2d8555d..0000000 --- a/pkg/ota-client.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=OTA+ Client -Wants=network-online.target -After=network.target network-online.target -Requires=network-online.target - -[Service] -RestartSec=5 -Restart=on-failure -Environment="RUST_LOG=info" -DefaultTimeoutStopSec=5 -ExecStart=/opt/ats/ota_plus_client --config /opt/ats/ota.toml - -[Install] -WantedBy=multi-user.target
\ No newline at end of file @@ -10,7 +10,7 @@ fi : "${PACKAGE_VERSION:?'Environment variable PACKAGE_VERSION must be set.'}" -PACKAGE_NAME="${PACKAGE_NAME-ota-plus-client}" +PACKAGE_NAME="${PACKAGE_NAME-sota_client}" PACKAGE_DIR="$(cd "$(dirname "$0")" && pwd)" PREFIX=/opt/ats @@ -24,11 +24,11 @@ export OTA_WEBSOCKET="${OTA_WEBSOCKET-true}" case $1 in "deb" ) export PACKAGE_MANAGER="deb" - PKG_BUILD_OPTS="--deb-systemd ${PACKAGE_DIR}/ota-client.service" + PKG_BUILD_OPTS="--deb-systemd ${PACKAGE_DIR}/sota_client.service" ;; "rpm" ) export PACKAGE_MANAGER="rpm" - PKG_BUILD_OPTS="--rpm-service ${PACKAGE_DIR}/ota-client.service" + PKG_BUILD_OPTS="--rpm-service ${PACKAGE_DIR}/sota_client.service" ;; *) echo "unknown package format $1" @@ -40,7 +40,7 @@ function make_pkg { destination=$1 template=$(mktemp) - envsubst < "${PACKAGE_DIR}/ota.toml.template" > "${template}" + envsubst < "${PACKAGE_DIR}/sota.toml.template" > "${template}" if [[ -n "${OTA_NO_AUTH}" ]]; then sed -i '1,/\[device\]/{/\[device\]/p;d}' "${template}" fi @@ -55,11 +55,11 @@ function make_pkg { --package NAME-VERSION.TYPE \ --prefix "${PREFIX}" \ ${PKG_BUILD_OPTS} \ - "${PACKAGE_DIR}/ota_plus_client=ota_plus_client" \ - "${template}=ota.toml" + "${PACKAGE_DIR}/sota_client=sota_client" \ + "${template}=sota.toml" if [ -n "$destination" ]; then - mv -f "ota-plus-client*.${PACKAGE_MANAGER}" "${destination}" + mv -f "sota_client*.${PACKAGE_MANAGER}" "${destination}" fi rm -f "${template}" } diff --git a/pkg/ota.toml.template b/pkg/sota.toml.template index c1a8eb4..c1a8eb4 100644 --- a/pkg/ota.toml.template +++ b/pkg/sota.toml.template diff --git a/pkg/yocto/ota-plus-client.service b/pkg/sota_client.service index 8283707..1578a70 100644 --- a/pkg/yocto/ota-plus-client.service +++ b/pkg/sota_client.service @@ -9,7 +9,7 @@ RestartSec=5 Restart=on-failure Environment="RUST_LOG=info" DefaultTimeoutStopSec=5 -ExecStart=/usr/bin/ota_plus_client --config /etc/ota.toml +ExecStart=/opt/ats/sota_client --config /opt/ats/sota.toml [Install] WantedBy=multi-user.target diff --git a/pkg/start-up.sh b/pkg/start-up.sh index b0062f9..c359ce5 100755 --- a/pkg/start-up.sh +++ b/pkg/start-up.sh @@ -51,18 +51,18 @@ else export OTA_CREDENTIALS_FILE=${OTA_CREDENTIALS_FILE-/opt/ats/credentials.toml} fi -TEMPLATE_PATH=${TEMPLATE_PATH-'/etc/ota.toml.template'} -OUTPUT_PATH=${OUTPUT_PATH-/etc/ota.toml} +TEMPLATE_PATH=${TEMPLATE_PATH-'/etc/sota.toml.template'} +OUTPUT_PATH=${OUTPUT_PATH-/etc/sota.toml} if [[ -n "${OTA_NO_AUTH}" ]]; then sed -i '1,/\[device\]/{/\[device\]/p;d}' "${TEMPLATE_PATH}" fi if [[ -n $PROVISION ]]; then - OTA_TOML=$(cat $TEMPLATE_PATH | envsubst ) - echo "$OTA_TOML" + SOTA_TOML=$(cat $TEMPLATE_PATH | envsubst ) + echo "$SOTA_TOML" else - OTA_TOML=$(cat $TEMPLATE_PATH | envsubst > $OUTPUT_PATH) + SOTA_TOML=$(cat $TEMPLATE_PATH | envsubst > $OUTPUT_PATH) cat $OUTPUT_PATH - RUST_LOG=${RUST_LOG-debug} ota_plus_client --config=/etc/ota.toml + RUST_LOG=${RUST_LOG-debug} sota_client --config=/etc/sota.toml fi diff --git a/pkg/tailor.sh b/pkg/tailor.sh index 09f7820..ab9d0de 100755 --- a/pkg/tailor.sh +++ b/pkg/tailor.sh @@ -2,8 +2,8 @@ set -eo pipefail -PKG_NAME="ota-plus-client_latest" -WORKING_DIR="/tmp/ota_plus_client_extract_$$" +PKG_NAME="sota_client_latest" +WORKING_DIR="/tmp/sota_client_extract_$$" cd $(dirname $0) PKG_SRC_DIR=$(pwd) @@ -11,7 +11,7 @@ PKG_SRC_DIR=$(pwd) function convert_to_rpm { mv $dest $dest.deb alien -c -k -r --fixperms $dest.deb - mv ota-plus*.rpm $dest + mv sota*.rpm $dest } function tailor_deb { @@ -27,11 +27,12 @@ function tailor_deb { pkgmanager="rpm" fi - sed -i "s/^client_id = .*$/client_id = \"$OTA_AUTH_CLIENT_ID\"/" $WORKING_DIR/opt/ats/ota.toml - sed -i "s/^secret = .*$/secret = \"$OTA_AUTH_SECRET\"/" $WORKING_DIR/opt/ats/ota.toml - sed -i "s/^uuid = .*$/uuid = \"$OTA_DEVICE_UUID\"/" $WORKING_DIR/opt/ats/ota.toml - sed -i "s/^vin = .*$/vin = \"$OTA_CLIENT_VIN\"/" $WORKING_DIR/opt/ats/ota.toml - sed -i "s/^package_manager = .*$/package_manager = \"$pkgmanager\"/" $WORKING_DIR/opt/ats/ota.toml + SOTA_TOML="$WORKING_DIR/opt/ats/sota.toml" + sed -i "s/^client_id = .*$/client_id = \"$OTA_AUTH_CLIENT_ID\"/" "$SOTA_TOML" + sed -i "s/^secret = .*$/secret = \"$OTA_AUTH_SECRET\"/" "$SOTA_TOML" + sed -i "s/^uuid = .*$/uuid = \"$OTA_DEVICE_UUID\"/" "$SOTA_TOML" + sed -i "s/^vin = .*$/vin = \"$OTA_CLIENT_VIN\"/" "$SOTA_TOML" + sed -i "s/^package_manager = .*$/package_manager = \"$pkgmanager\"/" "$SOTA_TOML" mkdir -p $(dirname $dest) echo "Re-packaging contents of $WORKING_DIR/ to $dest" diff --git a/src/datatype/config.rs b/src/datatype/config.rs index 9be0e01..a08156a 100644 --- a/src/datatype/config.rs +++ b/src/datatype/config.rs @@ -240,7 +240,7 @@ mod tests { #[test] fn parse_example_config() { let config = String::new() + AUTH_CONFIG + DEVICE_CONFIG + GATEWAY_CONFIG + OTA_CONFIG; - assert_eq!(load_config("ota.toml").unwrap(), parse_config(&config).unwrap()); + assert_eq!(load_config("sota.toml").unwrap(), parse_config(&config).unwrap()); } #[test] diff --git a/src/interaction_library/http.rs b/src/interaction_library/http.rs index 1eef062..fca033d 100644 --- a/src/interaction_library/http.rs +++ b/src/interaction_library/http.rs @@ -23,7 +23,7 @@ impl<C, E> Gateway<C, E> for Http { fn new(itx: Sender<Interpret<C, E>>) -> Result<Self, String> { let itx = Arc::new(Mutex::new(itx)); - let addr = env::var("OTA_PLUS_CLIENT_HTTP_ADDR").unwrap_or("127.0.0.1:8888".to_string()); + let addr = env::var("SOTA_HTTP_ADDR").unwrap_or("127.0.0.1:8888".to_string()); let server = match Server::http(&addr.parse().unwrap()) { Ok(server) => server, diff --git a/src/interaction_library/websocket.rs b/src/interaction_library/websocket.rs index b9477b3..4114c42 100644 --- a/src/interaction_library/websocket.rs +++ b/src/interaction_library/websocket.rs @@ -23,7 +23,7 @@ impl<C, E> Gateway<C, E> for Websocket { fn new(itx: Sender<Interpret<C, E>>) -> Result<Self, String> { let clients = Arc::new(Mutex::new(HashMap::new())); - let addr = env::var("OTA_PLUS_CLIENT_WEBSOCKET_ADDR").unwrap_or("127.0.0.1:3012".to_string()); + let addr = env::var("SOTA_WEBSOCKET_ADDR").unwrap_or("127.0.0.1:3012".to_string()); let handler_clients = clients.clone(); let (start_tx, start_rx) = chan::sync::<Result<(), ws::Error>>(0); diff --git a/src/main.rs b/src/main.rs index 8618756..f52cb66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -106,7 +106,7 @@ fn main() { } fn setup_logging() { - let name = option_env!("SERVICE_NAME").unwrap_or("ota-plus-client"); + let name = option_env!("SERVICE_NAME").unwrap_or("sota_client"); let version = option_env!("SERVICE_VERSION").unwrap_or("?"); let mut builder = LogBuilder::new(); @@ -148,7 +148,7 @@ fn build_config() -> Config { } let config_file = matches.opt_str("config").unwrap_or_else(|| { - env::var("OTA_PLUS_CLIENT_CFG").unwrap_or("/opt/ats/ota/etc/ota.toml".to_string()) + env::var("SOTA_CONFIG").unwrap_or("/opt/ats/ota/etc/sota.toml".to_string()) }); let mut config = config::load_config(&config_file).unwrap_or_else(|err| exit!("{}", err)); diff --git a/tests/ota_plus_client_tests.rs b/tests/ota_plus_client_tests.rs index 1e750f1..e9e6dd8 100644 --- a/tests/ota_plus_client_tests.rs +++ b/tests/ota_plus_client_tests.rs @@ -17,7 +17,7 @@ fn bin_dir() -> String { } fn client(args: &[&str]) -> String { - let output = Command::new(format!("{}/ota_plus_client", bin_dir())) + let output = Command::new(format!("{}/sota_client", bin_dir())) .args(args) .output() .unwrap_or_else(|e| panic!("failed to execute child: {}", e)); @@ -37,7 +37,7 @@ fn client_with_config(args: &[&str], cfg: &str) -> String { #[test] fn help() { assert_eq!(client(&["-h"]), - format!(r#"Usage: {}/ota_plus_client [options] + format!(r#"Usage: {}/sota_client [options] Options: -h, --help print this help menu |