diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..47d0eb4 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,4 @@ +2017-10-21 Kunihiro Ishiguro + + * README.md: Initial commit. Vesrion 0.8.0. + diff --git a/package/Makefile b/package/Makefile new file mode 100644 index 0000000..7ebe1d8 --- /dev/null +++ b/package/Makefile @@ -0,0 +1,76 @@ +## +## Makefile for openconfigd package. +## +PACKAGE_NAME:=openconfigd + +OPENCONFIGD_VERSION:=0.8.0 + +PACKAGE_VERSION:=$(OPENCONFIGD_VERSION) +PACKAGE_LICENSE:=Apache License version 2.0 +PACKAGE_DESCRIPTION:=OpenConfigd +PACKAGE_MAINTAINER:=ishi@coreswitch.io +PACKAGE_URL:=http://coreswitch.io/ +PACKAGE_VENDOR:=coreswitch + +OUT_DIR:=out +STAGING_DIR:=$(OUT_DIR)/stage +BUILD_DIR:=$(OUT_DIR)/build + +.PHONY: package stage clean files + +package: $(OUT_DIR)/package.timestamp + +$(OUT_DIR)/package.timestamp: stage + @echo "Creating package" + @rm -f $(OUT_DIR)/$(PACKAGE_NAME)_$(PACKAGE_VERSION)*.deb + @cd $(OUT_DIR) && \ + fpm -s dir -C $(realpath $(STAGING_DIR)) \ + --name $(PACKAGE_NAME) \ + --version $(PACKAGE_VERSION) \ + --license "$(PACKAGE_LICENSE)" \ + --maintainer "$(PACKAGE_MAINTAINER)" \ + --description "$(PACKAGE_DESCRIPTION)" \ + --url "$(PACKAGE_URL)" \ + --vendor "$(PACKAGE_VENDOR)" \ + --before-install ../scripts/before_install.sh \ + --after-install ../scripts/after_install.sh \ + --before-remove ../scripts/before_remove.sh \ + --after-remove ../scripts/after_remove.sh \ + --deb-changelog ../../ChangeLog \ + --deb-no-default-config-files \ + -t deb . + touch $(OUT_DIR)/package.timestamp + +stage: files openconfigd cli + +files: $(STAGING_DIR) $(STAGING_DIR)/etc $(STAGING_DIR)/etc/openconfigd + rsync -avz ./files/ubuntu/ $(STAGING_DIR)/ + rsync -avz ../bash_completion.d $(STAGING_DIR)/etc + rsync -avz ../yang $(STAGING_DIR)/etc/openconfigd + +openconfigd: $(STAGING_DIR)/usr/bin + go get github.com/hash-set/openconfigd/openconfigd + go get github.com/hash-set/openconfigd/cli_command + cp $(GOPATH)/bin/openconfigd $(STAGING_DIR)/usr/bin + cp $(GOPATH)/bin/cli_command $(STAGING_DIR)/usr/bin + +cli: $(BUILD_DIR) $(STAGING_DIR)/usr/bin + (cd $(BUILD_DIR); ../../../cli/configure; make; cp cli ../../$(STAGING_DIR)/usr/bin) + +$(STAGING_DIR): + mkdir -p $(STAGING_DIR) + +$(STAGING_DIR)/usr/bin: + mkdir -p $(STAGING_DIR)/usr/bin + +$(STAGING_DIR)/etc: + mkdir -p $(STAGING_DIR)/etc + +$(STAGING_DIR)/etc/openconfigd: + mkdir -p $(STAGING_DIR)/etc/openconfigd + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +clean: + rm -rf $(OUT_DIR) diff --git a/package/files/ubuntu/lib/systemd/system/openconfigd.service b/package/files/ubuntu/lib/systemd/system/openconfigd.service new file mode 100644 index 0000000..e21073d --- /dev/null +++ b/package/files/ubuntu/lib/systemd/system/openconfigd.service @@ -0,0 +1,14 @@ +[Unit] +Description=openconfigd + +[Service] +Type=simple +User=root +Group=root +StandardOutput=syslog +StandardError=syslog +Restart=always +ExecStart=/usr/bin/openconfigd -y /etc/openconfigd/yang + +[Install] +WantedBy=multi-user.target diff --git a/package/files/ubuntu/usr/local/etc/openconfigd.conf b/package/files/ubuntu/usr/local/etc/openconfigd.conf new file mode 100644 index 0000000..e69de29 diff --git a/package/scripts/after_install.sh b/package/scripts/after_install.sh new file mode 100755 index 0000000..4f04ac1 --- /dev/null +++ b/package/scripts/after_install.sh @@ -0,0 +1,38 @@ +#! /bin/bash + +_ubuntu_version () +{ + if /bin/grep 16.04 /etc/lsb-release>/dev/null;then + U1604=1 + else + U1604=0 + fi +} + +_process_1404 () +{ + echo "Post install script for Ubuntu 14.04" + /usr/bin/supervisorctl reload + return 0 +} + +_process_1604 () +{ + echo "Post install script for Ubuntu 16.04" + /bin/systemctl daemon-reload + /bin/systemctl restart openconfigd.service + return 0 +} + +_main () +{ + _ubuntu_version + + if [ ${U1604} == 1 ]; then + _process_1604 + else + _process_1404 + fi +} + +_main diff --git a/package/scripts/after_remove.sh b/package/scripts/after_remove.sh new file mode 100755 index 0000000..39903ce --- /dev/null +++ b/package/scripts/after_remove.sh @@ -0,0 +1,37 @@ +#! /bin/bash + +_ubuntu_version () +{ + if /bin/grep 16.04 /etc/lsb-release>/dev/null;then + U1604=1 + else + U1604=0 + fi +} + +_process_1404 () +{ + echo "Post uninstall script for Ubuntu 14.04" + /usr/bin/supervisorctl reload + return 0 +} + +_process_1604 () +{ + echo "Post uninstall script for Ubuntu 16.04" + /bin/systemctl daemon-reload + return 0 +} + +_main () +{ + _ubuntu_version + + if [ ${U1604} == 1 ]; then + _process_1604 + else + _process_1404 + fi +} + +_main diff --git a/package/scripts/before_install.sh b/package/scripts/before_install.sh new file mode 100755 index 0000000..509a7c2 --- /dev/null +++ b/package/scripts/before_install.sh @@ -0,0 +1,38 @@ +#! /bin/bash + +_ubuntu_version () +{ + if /bin/grep 16.04 /etc/lsb-release>/dev/null;then + U1604=1 + else + U1604=0 + fi +} + +_process_1404 () +{ + echo "Pre install script for Ubuntu 14.04" + /bin/mkdir -p /var/log/openconfigd + /usr/bin/supervisorctl stop openconfigd + return 0 +} + +_process_1604 () +{ + echo "Pre install script for Ubuntu 16.04" + /usr/bin/supervisorctl stop openconfigd + return 0 +} + +_main () +{ + _ubuntu_version + + if [ ${U1604} == 1 ]; then + _process_1604 + else + _process_1404 + fi +} + +_main diff --git a/package/scripts/before_remove.sh b/package/scripts/before_remove.sh new file mode 100755 index 0000000..5803b70 --- /dev/null +++ b/package/scripts/before_remove.sh @@ -0,0 +1,37 @@ +#! /bin/bash + +_ubuntu_version () +{ + if /bin/grep 16.04 /etc/lsb-release>/dev/null;then + U1604=1 + else + U1604=0 + fi +} + +_process_1404 () +{ + echo "Pre uninstall script for Ubuntu 14.04" + /usr/bin/supervisorctl stop openconfigd + return 0 +} + +_process_1604 () +{ + echo "Pre uninstall script for Ubuntu 16.04" + /bin/systemctl stop openconfigd.service + return 0 +} + +_main () +{ + _ubuntu_version + + if [ ${U1604} == 1 ]; then + _process_1604 + else + _process_1404 + fi +} + +_main