From 8ff39764840a134cbbe387edde247876a8cc77a9 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Tue, 28 May 2024 15:24:51 +0530 Subject: [PATCH 01/10] Added kernel-config-server and migrated it Signed-off-by: Loganathan Sekar --- .github/workflows/push-trigger.yml | 3 + kernel/kernel-config-server/.gitignore | 20 ++ kernel/kernel-config-server/Dockerfile | 41 ++++ .../Dockerfile-no-updates | 41 ++++ kernel/kernel-config-server/README.md | 159 +++++++++++++ kernel/kernel-config-server/execute-jar.sh | 17 ++ kernel/kernel-config-server/pom.xml | 222 ++++++++++++++++++ .../src/main/java/META-INF/MANIFEST.MF | 3 + .../server/ConfigServerBootApplication.java | 26 ++ .../server/controller/RefreshController.java | 87 +++++++ .../src/main/resources/bootstrap.properties | 59 +++++ .../src/main/resources/logback.xml | 21 ++ .../config/HibernateDaoConfig.java | 4 +- .../test/service/UinGeneratorServiceTest.java | 4 - kernel/pom.xml | 1 + 15 files changed, 703 insertions(+), 5 deletions(-) create mode 100644 kernel/kernel-config-server/.gitignore create mode 100644 kernel/kernel-config-server/Dockerfile create mode 100644 kernel/kernel-config-server/Dockerfile-no-updates create mode 100644 kernel/kernel-config-server/README.md create mode 100644 kernel/kernel-config-server/execute-jar.sh create mode 100644 kernel/kernel-config-server/pom.xml create mode 100644 kernel/kernel-config-server/src/main/java/META-INF/MANIFEST.MF create mode 100644 kernel/kernel-config-server/src/main/java/io/mosip/kernel/config/server/ConfigServerBootApplication.java create mode 100644 kernel/kernel-config-server/src/main/java/io/mosip/kernel/config/server/controller/RefreshController.java create mode 100644 kernel/kernel-config-server/src/main/resources/bootstrap.properties create mode 100644 kernel/kernel-config-server/src/main/resources/logback.xml diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml index 6c6ce1167b2..f3bcba12917 100644 --- a/.github/workflows/push-trigger.yml +++ b/.github/workflows/push-trigger.yml @@ -83,6 +83,9 @@ jobs: - SERVICE_LOCATION: 'kernel/kernel-salt-generator' SERVICE_NAME: 'kernel-salt-generator' BUILD_ARTIFACT: 'commons' + - SERVICE_LOCATION: 'kernel/kernel-config-server' + SERVICE_NAME: 'kernel-config-server' + BUILD_ARTIFACT: 'commons' fail-fast: false uses: mosip/kattu/.github/workflows/docker-build.yml@master-java21 name: ${{ matrix.SERVICE_NAME }} diff --git a/kernel/kernel-config-server/.gitignore b/kernel/kernel-config-server/.gitignore new file mode 100644 index 00000000000..6b70919dee9 --- /dev/null +++ b/kernel/kernel-config-server/.gitignore @@ -0,0 +1,20 @@ +*.class +.mtj.tmp/ +*.jar +*.war +*.ear +hs_err_pid* +target/ +.metadata +.classpath +.project +.settings/ +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.loadpath +.DS_Store \ No newline at end of file diff --git a/kernel/kernel-config-server/Dockerfile b/kernel/kernel-config-server/Dockerfile new file mode 100644 index 00000000000..cb1ce86ad71 --- /dev/null +++ b/kernel/kernel-config-server/Dockerfile @@ -0,0 +1,41 @@ +FROM eclipse-temurin:21-jre-alpine + +# can be passed during Docker build as build time environment for keystore location for encryption +ARG encrypt_keyStore_location + +# can be passed during Docker build as build time environment for keystore password for encryption +ARG encrypt_keyStore_password + +# can be passed during Docker build as build time environment for keystore alias for encryption +ARG encrypt_keyStore_alias + +# can be passed during Docker build as build time environment for keystore secret for encryption +ARG encrypt_keyStore_secret + +# environment variable to pass GIT URL at docker runtime +ENV git_url_env=${git_url} + +# environment variable to pass github configuration folder to pickup configuration from, at docker runtime +ENV git_config_folder_env=${git_config_folder} + +# environment variable to pass encryption keystore location at docker runtime +ENV encrypt_keyStore_location_env=${encrypt_keyStore_location} + +# environment variable to pass encryption keystore password at docker runtime +ENV encrypt_keyStore_password_env=${encrypt_keyStore_password} + +# environment variable to pass encryption keystore alias at docker runtime +ENV encrypt_keyStore_alias_env=${encrypt_keyStore_alias} + +# environment variable to pass encryption keystore secret at docker runtime +ENV encrypt_keyStore_secret_env=${encrypt_keyStore_secret} + +ADD execute-jar.sh execute-jar.sh + +RUN chmod 777 execute-jar.sh + +COPY ./target/kernel-config-server-*.jar kernel-config-server.jar + +EXPOSE 51000 + +CMD ./execute-jar.sh diff --git a/kernel/kernel-config-server/Dockerfile-no-updates b/kernel/kernel-config-server/Dockerfile-no-updates new file mode 100644 index 00000000000..2f2b8cb3adb --- /dev/null +++ b/kernel/kernel-config-server/Dockerfile-no-updates @@ -0,0 +1,41 @@ +FROM openjdk:11 + +# can be passed during Docker build as build time environment for keystore location for encryption +ARG encrypt_keyStore_location + +# can be passed during Docker build as build time environment for keystore password for encryption +ARG encrypt_keyStore_password + +# can be passed during Docker build as build time environment for keystore alias for encryption +ARG encrypt_keyStore_alias + +# can be passed during Docker build as build time environment for keystore secret for encryption +ARG encrypt_keyStore_secret + +# environment variable to pass GIT URL at docker runtime +ENV git_url_env=${git_url} + +# environment variable to pass github configuration folder to pickup configuration from, at docker runtime +ENV git_config_folder_env=${git_config_folder} + +# environment variable to pass encryption keystore location at docker runtime +ENV encrypt_keyStore_location_env=${encrypt_keyStore_location} + +# environment variable to pass encryption keystore password at docker runtime +ENV encrypt_keyStore_password_env=${encrypt_keyStore_password} + +# environment variable to pass encryption keystore alias at docker runtime +ENV encrypt_keyStore_alias_env=${encrypt_keyStore_alias} + +# environment variable to pass encryption keystore secret at docker runtime +ENV encrypt_keyStore_secret_env=${encrypt_keyStore_secret} + +ADD execute-jar.sh execute-jar.sh + +RUN chmod 777 execute-jar.sh + +COPY ./target/kernel-config-server-*.jar kernel-config-server.jar + +EXPOSE 51000 + +CMD ./execute-jar.sh diff --git a/kernel/kernel-config-server/README.md b/kernel/kernel-config-server/README.md new file mode 100644 index 00000000000..f2ff0838f0a --- /dev/null +++ b/kernel/kernel-config-server/README.md @@ -0,0 +1,159 @@ +## kernel-config-server + +[Background & Design]( https://github.com/mosip/mosip/wiki/MOSIP-Configuration-Server ) + +Default Port and Context Path + +``` +server.port=51000 +server.servlet.path=/config + +``` + +**For Encryption Decryption of properties**
+
+Create keystore with following command:
+`keytool -genkeypair -alias -keyalg RSA -keystore server.keystore -storepass --dname "CN=,OU=,O=,L=,S=,C="` + +When you run the above command it will ask you for password for < your-alias > , choose your password or press enter for same password as < store-password > + +The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format, migrate it using following command: +`keytool -importkeystore -srckeystore server.keystore -destkeystore server.keystore -deststoretype pkcs12`
+For more information look [here]( https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html#_creating_a_key_store_for_testing ) + +**How To Run** +
+To run the application:
+Make sure you have configured ssh keys to connect to git, because it will take ssh keys from default location (${user.home}/.ssh) . +Now run the jar using the following command:
+
+`java -jar -Dspring.cloud.config.server.git.uri=< git-repo-ssh-url > -Dspring.cloud.config.server.git.search-paths=< config-folder-location-in-git-repo > -Dencrypt.keyStore.location=file:///< file-location-of-keystore > -Dencrypt.keyStore.password=< keystore-passowrd > -Dencrypt.keyStore.alias=< keystore-alias > -Dencrypt.keyStore.secret=< keystore-secret > < jar-name >` +
+
+To run it inside Docker container provide the follwing run time arguments: +1. git_url_env +The URL of your Git repo + +2. git_config_folder_env +The folder inside your git repo which contains the configuration + +3. encrypt_keyStore_location_env +The encrypt keystore location + +4. encrypt_keyStore_password_env +The encryption keystore password + +5. encrypt_keyStore_alias_env +The encryption keystore alias + +6. encrypt_keyStore_secret_env +The encryption keyStore secret + +The final docker run command should look like: + +`docker run --name= -d -v /server.keystore:/server.keystore:z -v /home/madmin/:/.ssh:z -e git_url_env= -e git_config_folder_env= -e encrypt_keyStore_location_env=file:////server.keystore -e encrypt_keyStore_password_env= -e encrypt_keyStore_alias_env= -e encrypt_keyStore_secret_env= -p 51000:51000 ` +
+
+**To Encrypt any property:**
+Run the following command :
+`curl http:////encrypt -d ` + +And place the encrypted value in client application properties file with the format:
+`password={cipher}` + +**To Decrypt any property manually:**
+ +`curl http:////decrypt -d ` + +**NOTE** There is no need to write decryption mechanism in client applications for encrypted values. They will be automatically decrypted by config server. + + + +**Application Properties** + +``` +#Port where mosip spring cloud config server needs to run +server.port = 51000 + +#adding context path +server.servlet.path=/config + +# Uncomment spring.cloud.config.server.git.uri and spring.cloud.config.server.git.search-paths for # connecting to git Repo for configuration. +################################################################# +#Git repository location where configuration files are stored +#spring.cloud.config.server.git.uri= + +#Path inside the GIT repo where config files are stored, in our case they are inside config directory +#spring.cloud.config.server.git.search-paths= + +# Uncomment spring.profiles.active and spring.cloud.config.server.native.search-locations for # connecting to local file system for configuration. +################################################################# +# spring.profiles.active=native + +# spring.cloud.config.server.native.search-locations=file:/// + +#Server would return a HTTP 404 status, if the application is not found.By default, this flag is set to true. +spring.cloud.config.server.accept-empty=false + +#Spring Cloud Config Server makes a clone of the remote git repository and if somehow the local copy gets +#dirty (e.g. folder content changes by OS process) so Spring Cloud Config Server cannot update the local copy +#from remote repository. For Force-pull in such case, we are setting the flag to true. +spring.cloud.config.server.git.force-pull=true + +# Disabling health endpoints to improve performance of config server while in development, can be commented out in production. +health.config.enabled=false + +# Setting up refresh rate to 1 minute so that config server will check for updates in Git repo after every one minute, +#can be lowered down for production. +spring.cloud.config.server.git.refreshRate=60 + + +# adding provision to clone on start of server instead of first request +spring.cloud.config.server.git.cloneOnStart=true + +#For encryption of properties +########################################### +#pass at runtime +#encrypt.keyStore.location=file:/// +#encrypt.keyStore.password= +#encrypt.keyStore.alias= +#encrypt.keyStore.secret= + + + +``` + +**Config hierarchy** + +![Config Properties](../../docs/design/kernel/_images/GlobalProperties_1.jpg) + + + +**Maven dependency for Config client** + +``` + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + +``` + + +**Config client bootstrap.properties** + +``` +spring.cloud.config.uri=http://: +spring.cloud.config.label= +spring.application.name= +spring.cloud.config.name= +spring.profiles.active= +management.endpoints.web.exposure.include=refresh +#management.security.enabled=false + +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +spring.cloud.config.server.health.enabled=false + +``` diff --git a/kernel/kernel-config-server/execute-jar.sh b/kernel/kernel-config-server/execute-jar.sh new file mode 100644 index 00000000000..11487b5e795 --- /dev/null +++ b/kernel/kernel-config-server/execute-jar.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# This scipt will run kernel-config-server.jar inside Docker container according to the run time arguments provided +# while giving Docker run command + +# if all encryption arguments +if [ "x$encrypt_keyStore_location_env" != "x" ] && [ "x$encrypt_keyStore_password_env" != "x" ] && [ "x$encrypt_keyStore_alias_env" != "x" ] && [ "x$encrypt_keyStore_secret_env" != "x" ]; + then echo "Encryption has to be done"; + java -jar -Dspring.cloud.config.server.git.uri=${git_url_env} -Dspring.cloud.config.server.git.search-paths=${git_config_folder_env} -Dencrypt.keyStore.location=${encrypt_keyStore_location_env} -Dencrypt.keyStore.password=${encrypt_keyStore_password_env} -Dencrypt.keyStore.alias=${encrypt_keyStore_alias_env} -Dencrypt.keyStore.secret=${encrypt_keyStore_secret_env} kernel-config-server.jar; + + +# running without encryption +else + echo "Encryption configurations not Passed, Encryption is disabled"; + java -jar -Dspring.cloud.config.server.git.uri=${git_url_env} -Dspring.cloud.config.server.git.search-paths=${git_config_folder_env} kernel-config-server.jar; + + fi diff --git a/kernel/kernel-config-server/pom.xml b/kernel/kernel-config-server/pom.xml new file mode 100644 index 00000000000..07d2a70ff00 --- /dev/null +++ b/kernel/kernel-config-server/pom.xml @@ -0,0 +1,222 @@ + + + 4.0.0 + + io.mosip.kernel + 1.2.1-java21-SNAPSHOT + kernel-config-server + Kernel Config Server + https://github.com/mosip/commons + Config Server for Mosip + + + UTF-8 + + + 21 + 21 + 3.8.0 + 2.22.0 + + 3.0.2 + 3.1.0 + 0.8.1 + 3.7.0.1746 + 3.2.0 + 2.3 + + 3.2.3 + + + + + + io.mosip.kernel + kernel-bom + 1.2.1-java21-SNAPSHOT + pom + import + + + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.cloud + spring-cloud-config-server + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot-maven-plugin.version} + + true + + + + + repackage + + + + + + maven-deploy-plugin + 2.8.1 + + + default-deploy + deploy + + deploy + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + + default-deploy + deploy + + deploy + + + + + ossrh + https://oss.sonatype.org/ + false + + + + + org.apache.maven.plugins + maven-source-plugin + true + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + + attach-javadocs + + jar + + + + + none + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + pl.project13.maven + git-commit-id-plugin + 3.0.1 + + + get-the-git-infos + + revision + + validate + + + + true + ${project.build.outputDirectory}/git.properties + + ^git.build.(time|version)$ + ^git.commit.id.(abbrev|full)$ + + full + ${project.basedir}/.git + + + + + + + scm:git:git://github.com/mosip/commons.git + scm:git:ssh://github.com:mosip/commons.git + https://github.com/mosip/commons + HEAD + + + + MPL 2.0 + https://www.mozilla.org/en-US/MPL/2.0/ + + + + + Mosip + mosip.emailnotifier@gmail.com + io.mosip + https://github.com/mosip/commons + + + + diff --git a/kernel/kernel-config-server/src/main/java/META-INF/MANIFEST.MF b/kernel/kernel-config-server/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..254272e1c07 --- /dev/null +++ b/kernel/kernel-config-server/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/kernel/kernel-config-server/src/main/java/io/mosip/kernel/config/server/ConfigServerBootApplication.java b/kernel/kernel-config-server/src/main/java/io/mosip/kernel/config/server/ConfigServerBootApplication.java new file mode 100644 index 00000000000..079198526bc --- /dev/null +++ b/kernel/kernel-config-server/src/main/java/io/mosip/kernel/config/server/ConfigServerBootApplication.java @@ -0,0 +1,26 @@ +package io.mosip.kernel.config.server; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.config.server.EnableConfigServer; + +/** + * Config Server application + * + * @author Swati Raj + * @since 1.0.0 + * + */ +@SpringBootApplication +@EnableConfigServer +public class ConfigServerBootApplication { + + /** + * Main method to run spring boot application + * + * @param args args + */ + public static void main(String[] args) { + SpringApplication.run(ConfigServerBootApplication.class, args); + } +} diff --git a/kernel/kernel-config-server/src/main/java/io/mosip/kernel/config/server/controller/RefreshController.java b/kernel/kernel-config-server/src/main/java/io/mosip/kernel/config/server/controller/RefreshController.java new file mode 100644 index 00000000000..4f5abcca30d --- /dev/null +++ b/kernel/kernel-config-server/src/main/java/io/mosip/kernel/config/server/controller/RefreshController.java @@ -0,0 +1,87 @@ +package io.mosip.kernel.config.server.controller; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.client.ServiceInstance; +import org.springframework.cloud.client.discovery.DiscoveryClient; +import org.springframework.http.*; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +import java.util.*; +import java.util.stream.Collectors; + +@RestController +public class RefreshController { + + private static final Logger logger = LoggerFactory.getLogger(RefreshController.class); + + @Autowired + private DiscoveryClient discoveryClient; + + @Value("${spring.application.name}") + private String applicationName; + + @Value("#{${mosip.config.dnd.services}}") + private List dndServices; + + private String URL_TEMPLATE = "%s/actuator/refresh"; + private RestTemplate restTemplate; + + @GetMapping("/refresh") + public Map refreshContext(@RequestParam("servicename") String serviceName) { + logger.info("refreshContext invoked with serviceName : {}", serviceName); + Map result = new HashMap<>(); + + if(Objects.nonNull(discoveryClient)) { + try { + List serviceIds = serviceName.isBlank() ? discoveryClient.getServices() : + discoveryClient.getServices().stream() + .filter(s -> s.contains(serviceName) || s.equals(serviceName)).collect(Collectors.toList()); + + logger.info("shortlisted serviceIds : {}", serviceIds); + + serviceIds.stream() + .dropWhile(s -> isDNDService(s) ) + .forEach(s -> this.invokeRefreshActuatorEndpoint(s,discoveryClient.getInstances(s),result)); + + } catch (Throwable t) { + logger.error("Failed to refresh contexts", t); + } + } + logger.info("refreshContext completed"); + return result; + } + + private boolean isDNDService(String serviceId) { + if(serviceId.equals(applicationName) || (dndServices!=null && dndServices.contains(serviceId))) { + logger.info("DND service found, ignoring refresh attempt! serviceId : {} ", serviceId); + return true; + } + return false; + } + + private void invokeRefreshActuatorEndpoint(String serviceId, List instances, Map result) { + if(Objects.nonNull(instances)) { + restTemplate = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity httpEntity = new HttpEntity(null, headers); + + for (ServiceInstance instance : instances) { + logger.info("Refresh actuator invoked on serviceId: {} and instance : {} ", serviceId, instance.getUri()); + String url = String.format(URL_TEMPLATE, instance.getUri().toString()); + ResponseEntity resp = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class); + result.put(url, resp.getStatusCode().toString()); + logger.info("{} response : {}", url, resp); + } + } + } +} diff --git a/kernel/kernel-config-server/src/main/resources/bootstrap.properties b/kernel/kernel-config-server/src/main/resources/bootstrap.properties new file mode 100644 index 00000000000..088020c6c6f --- /dev/null +++ b/kernel/kernel-config-server/src/main/resources/bootstrap.properties @@ -0,0 +1,59 @@ +spring.application.name=kernel-config-service + +#management.security.enabled=false +#management.endpoint.health.show-details=when-authorized +#management.endpoints.web.exposure.include=* +management.endpoint.health.show-details=always +management.endpoints.web.exposure.include=info,health + +#Port where mosip spring cloud config server needs to run +server.port = 51000 + +#adding context path +server.servlet.path=/config +server.servlet.context-path=${server.servlet.path} + + +# Uncomment spring.cloud.config.server.git.uri and spring.cloud.config.server.git.search-paths for # connecting to git Repo for configuration. +################################################################# +#Git repository location where configuration files are stored +#spring.cloud.config.server.git.uri= + +#Path inside the GIT repo where config files are stored, in our case they are inside config directory +#spring.cloud.config.server.git.search-paths= + +# Uncomment spring.profiles.active and spring.cloud.config.server.native.search-locations for # connecting to local file system for configuration. +################################################################# +#spring.profiles.active=native + +#spring.cloud.config.server.native.search-locations=file:/// + +#Server would return a HTTP 404 status, if the application is not found.By default, this flag is set to true. +spring.cloud.config.server.accept-empty=false + +#Spring Cloud Config Server makes a clone of the remote git repository and if somehow the local copy gets +#dirty (e.g. folder content changes by OS process) so Spring Cloud Config Server cannot update the local copy +#from remote repository. For Force-pull in such case, we are setting the flag to true. +spring.cloud.config.server.git.force-pull=true + +# Disabling health endpoints to improve performance of config server while in development, can be commented out in production. +health.config.enabled=false + +# Setting up refresh rate to 5 seconds so that config server will check for updates in Git repo after every one minute, +#can be lowered down for production. +spring.cloud.config.server.git.refreshRate=5 + + +# adding provision to clone on start of server instead of first request +spring.cloud.config.server.git.cloneOnStart=true + +#For encryption of properties +########################################### +#pass at runtime +#encrypt.keyStore.location=file:/// +#encrypt.keyStore.password= +#encrypt.keyStore.alias= +#encrypt.keyStore.secret= + +mosip.config.dnd.services={'consul','kernel-config-service'} + diff --git a/kernel/kernel-config-server/src/main/resources/logback.xml b/kernel/kernel-config-server/src/main/resources/logback.xml new file mode 100644 index 00000000000..9f80a827ab0 --- /dev/null +++ b/kernel/kernel-config-server/src/main/resources/logback.xml @@ -0,0 +1,21 @@ + + + + %d [%t] %p [%C{1}].%M.%L : %m%n + + + + logs/kernel-config-server.log + true + true + + %d [%t] %p [%C{1}].%M.%L : %m%n + + + + + + + + diff --git a/kernel/kernel-idgenerator-service/src/main/java/io/mosip/kernel/idgenerator/config/HibernateDaoConfig.java b/kernel/kernel-idgenerator-service/src/main/java/io/mosip/kernel/idgenerator/config/HibernateDaoConfig.java index 207dde15fc8..428f352c389 100644 --- a/kernel/kernel-idgenerator-service/src/main/java/io/mosip/kernel/idgenerator/config/HibernateDaoConfig.java +++ b/kernel/kernel-idgenerator-service/src/main/java/io/mosip/kernel/idgenerator/config/HibernateDaoConfig.java @@ -18,6 +18,7 @@ import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @@ -25,6 +26,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; @@ -52,7 +54,7 @@ "io.mosip.kernel.crypto.*", "${mosip.auth.adapter.impl.basepackage}.*","io.mosip.kernel.cryptosignature.*","io.mosip.kernel.idgenerator.*","io.mosip.kernel.keygenerator.bouncycastle"}, excludeFilters = @Filter(type=FilterType.REGEX,pattern="io\\.mosip\\.kernel\\.idgenerator\\.test\\..*")) @EnableTransactionManagement -@EnableWebSecurity +@Import({WebSecurityConfiguration.class}) public class HibernateDaoConfig implements EnvironmentAware { private static final Logger LOGGER = LoggerFactory.getLogger(HibernateDaoConfig.class); diff --git a/kernel/kernel-idgenerator-service/src/test/java/io/mosip/kernel/uingenerator/test/service/UinGeneratorServiceTest.java b/kernel/kernel-idgenerator-service/src/test/java/io/mosip/kernel/uingenerator/test/service/UinGeneratorServiceTest.java index f584e391e2f..6a39547ac59 100644 --- a/kernel/kernel-idgenerator-service/src/test/java/io/mosip/kernel/uingenerator/test/service/UinGeneratorServiceTest.java +++ b/kernel/kernel-idgenerator-service/src/test/java/io/mosip/kernel/uingenerator/test/service/UinGeneratorServiceTest.java @@ -12,7 +12,6 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.web.client.RestTemplate; import io.mosip.kernel.core.authmanager.authadapter.spi.VertxAuthenticationProvider; import io.mosip.kernel.idgenerator.config.HibernateDaoConfig; @@ -51,9 +50,6 @@ public class UinGeneratorServiceTest { @MockBean private VertxAuthenticationProvider authHandler; - @MockBean - private RestTemplate restTemplate; - @Test(expected = UinNotFoundException.class) public void getUinNotFoundTest() { diff --git a/kernel/pom.xml b/kernel/pom.xml index 9ba3eae459a..2800dcda4b6 100644 --- a/kernel/pom.xml +++ b/kernel/pom.xml @@ -68,6 +68,7 @@ kernel-pridgenerator-service kernel-salt-generator kernel-demographics-api + kernel-config-server From 20d39bf61be2ea5ed6250bac82b15af716b82c7f Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Tue, 28 May 2024 15:38:04 +0530 Subject: [PATCH 02/10] Test case fix Signed-off-by: Loganathan Sekar --- .../io/mosip/kernel/idgenerator/config/HibernateDaoConfig.java | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/kernel-idgenerator-service/src/main/java/io/mosip/kernel/idgenerator/config/HibernateDaoConfig.java b/kernel/kernel-idgenerator-service/src/main/java/io/mosip/kernel/idgenerator/config/HibernateDaoConfig.java index 428f352c389..4526a8f0f8f 100644 --- a/kernel/kernel-idgenerator-service/src/main/java/io/mosip/kernel/idgenerator/config/HibernateDaoConfig.java +++ b/kernel/kernel-idgenerator-service/src/main/java/io/mosip/kernel/idgenerator/config/HibernateDaoConfig.java @@ -54,7 +54,6 @@ "io.mosip.kernel.crypto.*", "${mosip.auth.adapter.impl.basepackage}.*","io.mosip.kernel.cryptosignature.*","io.mosip.kernel.idgenerator.*","io.mosip.kernel.keygenerator.bouncycastle"}, excludeFilters = @Filter(type=FilterType.REGEX,pattern="io\\.mosip\\.kernel\\.idgenerator\\.test\\..*")) @EnableTransactionManagement -@Import({WebSecurityConfiguration.class}) public class HibernateDaoConfig implements EnvironmentAware { private static final Logger LOGGER = LoggerFactory.getLogger(HibernateDaoConfig.class); From a55e7e67efbe3095ef257985d78f017c6c06cd43 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Tue, 28 May 2024 16:58:48 +0530 Subject: [PATCH 03/10] Test case fix Signed-off-by: Loganathan Sekar --- .../uingenerator/test/service/UinGeneratorServiceTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/kernel-idgenerator-service/src/test/java/io/mosip/kernel/uingenerator/test/service/UinGeneratorServiceTest.java b/kernel/kernel-idgenerator-service/src/test/java/io/mosip/kernel/uingenerator/test/service/UinGeneratorServiceTest.java index 6a39547ac59..c2f77e42d0e 100644 --- a/kernel/kernel-idgenerator-service/src/test/java/io/mosip/kernel/uingenerator/test/service/UinGeneratorServiceTest.java +++ b/kernel/kernel-idgenerator-service/src/test/java/io/mosip/kernel/uingenerator/test/service/UinGeneratorServiceTest.java @@ -14,6 +14,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; import io.mosip.kernel.core.authmanager.authadapter.spi.VertxAuthenticationProvider; +import io.mosip.kernel.core.signatureutil.spi.SignatureUtil; import io.mosip.kernel.idgenerator.config.HibernateDaoConfig; import io.mosip.kernel.uingenerator.entity.UinEntity; import io.mosip.kernel.uingenerator.exception.UinNotFoundException; @@ -46,6 +47,9 @@ public class UinGeneratorServiceTest { @MockBean private RoutingContext routingContext; + + @MockBean + private SignatureUtil signatureutil; @MockBean private VertxAuthenticationProvider authHandler; From fd24a403302dd2b1b0f6b6a1464e7026edfbe9e1 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 29 May 2024 11:17:41 +0530 Subject: [PATCH 04/10] Added args for the dockerfile Signed-off-by: Loganathan Sekar --- kernel/kernel-config-server/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/kernel-config-server/Dockerfile b/kernel/kernel-config-server/Dockerfile index cb1ce86ad71..d39a546efc0 100644 --- a/kernel/kernel-config-server/Dockerfile +++ b/kernel/kernel-config-server/Dockerfile @@ -1,5 +1,14 @@ FROM eclipse-temurin:21-jre-alpine +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + # can be passed during Docker build as build time environment for keystore location for encryption ARG encrypt_keyStore_location From 8b968e7546dda17aff50ca9d6cdc143f4952f0bf Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 29 May 2024 16:34:57 +0530 Subject: [PATCH 05/10] Dockerfile correction Signed-off-by: Loganathan Sekar --- kernel/kernel-config-server/Dockerfile | 32 ++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/kernel/kernel-config-server/Dockerfile b/kernel/kernel-config-server/Dockerfile index d39a546efc0..b573df764fb 100644 --- a/kernel/kernel-config-server/Dockerfile +++ b/kernel/kernel-config-server/Dockerfile @@ -9,6 +9,32 @@ LABEL commit_hash=${COMMIT_HASH} LABEL commit_id=${COMMIT_ID} LABEL build_time=${BUILD_TIME} + + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +# install packages and create user +RUN apk -q update \ +&& apk add -q unzip wget \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + + # can be passed during Docker build as build time environment for keystore location for encryption ARG encrypt_keyStore_location @@ -39,7 +65,7 @@ ENV encrypt_keyStore_alias_env=${encrypt_keyStore_alias} # environment variable to pass encryption keystore secret at docker runtime ENV encrypt_keyStore_secret_env=${encrypt_keyStore_secret} -ADD execute-jar.sh execute-jar.sh +#ADD execute-jar.sh execute-jar.sh RUN chmod 777 execute-jar.sh @@ -47,4 +73,6 @@ COPY ./target/kernel-config-server-*.jar kernel-config-server.jar EXPOSE 51000 -CMD ./execute-jar.sh +#CMD ./execute-jar.sh +CMD ["/bin/sh" "-c" "java -jar kernel-config-server.jar"] + From 6e7a18d18fe06f2aae324e73b3dce8371ae92c76 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 29 May 2024 16:41:53 +0530 Subject: [PATCH 06/10] Docker fix Signed-off-by: Loganathan Sekar --- kernel/kernel-config-server/Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/kernel-config-server/Dockerfile b/kernel/kernel-config-server/Dockerfile index b573df764fb..f4e916839cf 100644 --- a/kernel/kernel-config-server/Dockerfile +++ b/kernel/kernel-config-server/Dockerfile @@ -67,7 +67,14 @@ ENV encrypt_keyStore_secret_env=${encrypt_keyStore_secret} #ADD execute-jar.sh execute-jar.sh -RUN chmod 777 execute-jar.sh +#RUN chmod 777 execute-jar.sh + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + COPY ./target/kernel-config-server-*.jar kernel-config-server.jar From 6ed3b7a27d5315eed3998ce3f0e88220b6006441 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 29 May 2024 18:14:53 +0530 Subject: [PATCH 07/10] Fix to dockerfile command Signed-off-by: Loganathan Sekar --- kernel/kernel-config-server/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kernel-config-server/Dockerfile b/kernel/kernel-config-server/Dockerfile index f4e916839cf..650c02a74ec 100644 --- a/kernel/kernel-config-server/Dockerfile +++ b/kernel/kernel-config-server/Dockerfile @@ -81,5 +81,5 @@ COPY ./target/kernel-config-server-*.jar kernel-config-server.jar EXPOSE 51000 #CMD ./execute-jar.sh -CMD ["/bin/sh" "-c" "java -jar kernel-config-server.jar"] +CMD java -jar kernel-config-server.jar From f821ffac22e946e45295c053b489057900ef3a4b Mon Sep 17 00:00:00 2001 From: Himaja Dhanyamraju <43470317+HimajaDhanyamraju2@users.noreply.github.com> Date: Wed, 29 May 2024 22:32:59 +0530 Subject: [PATCH 08/10] MOSIP-31977: Merged release-1.2.0.1 to develop (#1498) [MOSIP-31977] Mainly changes around the db upgrade scripts and Nosonar fix found and same merged from 1.2.0.1 to develop branch --------- Signed-off-by: Keshav Mishra Signed-off-by: Loganathan Sekar Signed-off-by: Rakshithb1 Signed-off-by: Loganathan Sekar <42532387+LoganathanSekar7627@users.noreply.github.com> Signed-off-by: Rakshith B <79500257+Rakshithb1@users.noreply.github.com> Signed-off-by: ckm007 Signed-off-by: techno-467 Signed-off-by: GitHub Signed-off-by: PRAFUL RAKHADE <99539100+Prafulrakhade@users.noreply.github.com> Signed-off-by: kameshsr Signed-off-by: Loganathan Sekar Signed-off-by: HimajaDhanyamraju2 Signed-off-by: Praful Rakhade <99539100+Prafulrakhade@users.noreply.github.com> Co-authored-by: Keshav Mishra Co-authored-by: Urvil Joshi <42868205+urviljoshi@users.noreply.github.com> Co-authored-by: Monobikash Das <43202165+MonobikashDas@users.noreply.github.com> Co-authored-by: urviljoshi Co-authored-by: Sasikumar Ganesan Co-authored-by: ckm007 Co-authored-by: Fossgen_AvinashW Co-authored-by: Vishwa Co-authored-by: Sowmya Ujjappa Banakar Co-authored-by: M1044292 Co-authored-by: PRAFUL RAKHADE <99539100+Prafulrakhade@users.noreply.github.com> Co-authored-by: Akila Lakshmanan <77330852+akilalakshmanan@users.noreply.github.com> Co-authored-by: akilalakshmanan Co-authored-by: Himaja Dhanyamraju Co-authored-by: syed salman <72004356+syedsalman3753@users.noreply.github.com> Co-authored-by: syed-salman-technoforte Co-authored-by: Loganathan Sekar Co-authored-by: Rakshithb1 <79500257+Rakshithb1@users.noreply.github.com> Co-authored-by: Loganathan Sekar <42532387+LoganathanSekar7627@users.noreply.github.com> Co-authored-by: techno-467 Co-authored-by: kameshsr Co-authored-by: Loganathan Sekar Co-authored-by: Prafulrakhade --- README.md | 4 +- .../authdevice_release_db_deploy.sh | 92 ------------------- .../authdevice_release_deploy.properties | 12 --- .../authdevice_revoke_db_deploy.sh | 92 ------------------- .../sql/1.1.5_authdevice-scripts_release.sql | 18 ---- .../sql/1.1.5_authdevice-scripts_revoke.sql | 13 --- .../sql/1.2_authdevice-scripts_release.sql | 30 ------ .../mosip_kernel/ddl/kernel-uin_assigned.sql | 47 ---------- .../mosip_kernel/ddl/kernel-vid_assigned.sql | 49 ---------- .../regdevice_release_db_deploy.sh | 92 ------------------- .../regdevice_release_deploy.properties | 12 --- .../regdevice_revoke_db_deploy.sh | 92 ------------------- .../sql/1.1.5_regdevice-scripts_release.sql | 14 --- .../sql/1.1.5_regdevice-scripts_revoke.sql | 13 --- .../sql/1.2_regdevice-scripts_release.sql | 14 --- db_scripts/mosip_authdevice/deploy.sh | 4 +- db_scripts/mosip_kernel/deploy.sh | 4 +- db_scripts/mosip_regdevice/deploy.sh | 8 +- .../README.MD | 0 .../sql/1.1.5.5_to_1.2.0.1-B1_rollback.sql | 5 + .../sql/1.1.5.5_to_1.2.0.1-B1_upgrade.sql | 17 ++++ .../sql/1.2.0.1-B1_to_1.2.0.1-B2_rollback.sql | 1 + .../sql/1.2.0.1-B1_to_1.2.0.1-B2_upgrade.sql | 1 + .../sql/1.2.0.1-B2_to_1.2.0.1_rollback.sql | 1 + .../sql/1.2.0.1-B2_to_1.2.0.1_upgrade.sql | 1 + .../mosip_kernel/upgrade.properties | 12 +++ db_upgrade_scripts/mosip_kernel/upgrade.sh | 51 ++++++++++ .../api/service/LoginService.java | 1 - .../controller/AuthProxyControllerTests.java | 2 +- kernel/kernel-biometrics-api/README.md | 8 ++ .../io/mosip/kernel/core/util/ZipUtils.java | 4 +- .../logger/logback/impl/LoggerImpl.java | 18 ++-- 32 files changed, 119 insertions(+), 613 deletions(-) delete mode 100644 db_release_scripts/mosip_authdevice/authdevice_release_db_deploy.sh delete mode 100644 db_release_scripts/mosip_authdevice/authdevice_release_deploy.properties delete mode 100644 db_release_scripts/mosip_authdevice/authdevice_revoke_db_deploy.sh delete mode 100644 db_release_scripts/mosip_authdevice/sql/1.1.5_authdevice-scripts_release.sql delete mode 100644 db_release_scripts/mosip_authdevice/sql/1.1.5_authdevice-scripts_revoke.sql delete mode 100644 db_release_scripts/mosip_authdevice/sql/1.2_authdevice-scripts_release.sql delete mode 100644 db_release_scripts/mosip_kernel/ddl/kernel-uin_assigned.sql delete mode 100644 db_release_scripts/mosip_kernel/ddl/kernel-vid_assigned.sql delete mode 100644 db_release_scripts/mosip_regdevice/regdevice_release_db_deploy.sh delete mode 100644 db_release_scripts/mosip_regdevice/regdevice_release_deploy.properties delete mode 100644 db_release_scripts/mosip_regdevice/regdevice_revoke_db_deploy.sh delete mode 100644 db_release_scripts/mosip_regdevice/sql/1.1.5_regdevice-scripts_release.sql delete mode 100644 db_release_scripts/mosip_regdevice/sql/1.1.5_regdevice-scripts_revoke.sql delete mode 100644 db_release_scripts/mosip_regdevice/sql/1.2_regdevice-scripts_release.sql rename {db_release_scripts => db_upgrade_scripts}/README.MD (100%) create mode 100644 db_upgrade_scripts/mosip_kernel/sql/1.1.5.5_to_1.2.0.1-B1_rollback.sql create mode 100644 db_upgrade_scripts/mosip_kernel/sql/1.1.5.5_to_1.2.0.1-B1_upgrade.sql create mode 100644 db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B1_to_1.2.0.1-B2_rollback.sql create mode 100644 db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B1_to_1.2.0.1-B2_upgrade.sql create mode 100644 db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B2_to_1.2.0.1_rollback.sql create mode 100644 db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B2_to_1.2.0.1_upgrade.sql create mode 100644 db_upgrade_scripts/mosip_kernel/upgrade.properties create mode 100644 db_upgrade_scripts/mosip_kernel/upgrade.sh diff --git a/README.md b/README.md index 5637302c8c9..73782164ee5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![Maven Package upon a push](https://github.com/mosip/commons/actions/workflows/push_trigger.yml/badge.svg?branch=release-1.2.0)](https://github.com/mosip/commons/actions/workflows/push_trigger.yml) -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=mosip_commons&metric=alert_status)](https://sonarcloud.io/dashboard?branch=release-1.2.0&id=mosip_commons) +[![Maven Package upon a push](https://github.com/mosip/commons/actions/workflows/push_trigger.yml/badge.svg?branch=release-1.2.0.1)](https://github.com/mosip/commons/actions/workflows/push_trigger.yml) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=mosip_commons&metric=alert_status)](https://sonarcloud.io/dashboard?branch=release-1.2.0.1&id=mosip_commons) # Commons diff --git a/db_release_scripts/mosip_authdevice/authdevice_release_db_deploy.sh b/db_release_scripts/mosip_authdevice/authdevice_release_db_deploy.sh deleted file mode 100644 index 397c9c1817b..00000000000 --- a/db_release_scripts/mosip_authdevice/authdevice_release_db_deploy.sh +++ /dev/null @@ -1,92 +0,0 @@ -### -- --------------------------------------------------------------------------------------------------------- -### -- Script Name : Authdevice Release DB deploy -### -- Deploy Module : MOSIP Kernel -### -- Purpose : To deploy AuthDevice Database alter scripts for the release. -### -- Created By : Ram Bhatt -### -- Created Date : Jan-2021 -### -- -### -- Modified Date Modified By Comments / Remarks -### -- ----------------------------------------------------------------------------------------------------------- - -### -- ----------------------------------------------------------------------------------------------------------- - -#########Properties file ############# -set -e -properties_file="$1" -release_version="$2" - echo `date "+%m/%d/%Y %H:%M:%S"` ": Properties File Name - $properties_file" - echo `date "+%m/%d/%Y %H:%M:%S"` ": DB Deploymnet Version - $release_version" -#properties_file="./app.properties" -if [ -f "$properties_file" ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file \"$properties_file\" found." - while IFS='=' read -r key value - do - key=$(echo $key | tr '.' '_') - eval ${key}=\${value} - done < "$properties_file" -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file not found, Pass property file name as argument." -fi -echo `date "+%m/%d/%Y %H:%M:%S"` ": ------------------ Database server and service status check for ${MOSIP_DB_NAME}------------------------" - -today=`date '+%d%m%Y_%H%M%S'`; -LOG="${LOG_PATH}${MOSIP_DB_NAME}-release-${release_version}-${today}.log" -touch $LOG - -SERVICE=$(PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "select count(1) from pg_roles where rolname IN('sysadmin')";exit; > /dev/null) - -if [ "$SERVICE" -eq 0 ] || [ "$SERVICE" -eq 1 ] -then -echo `date "+%m/%d/%Y %H:%M:%S"` ": Postgres database server and service is up and running" | tee -a $LOG 2>&1 -else -echo `date "+%m/%d/%Y %H:%M:%S"` ": Postgres database server or service is not running" | tee -a $LOG 2>&1 -fi - -echo `date "+%m/%d/%Y %H:%M:%S"` ": ----------------------------------------------------------------------------------------" - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Started sourcing the $MOSIP_DB_NAME Database Alter scripts" | tee -a $LOG 2>&1 - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Database Alter scripts are sourcing from :$BASEPATH/$MOSIP_DB_NAME/" | tee -a $LOG 2>&1 - -#========================================DB Alter Scripts deployment process begins on IDMAP DB SERVER================================== - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Alter scripts deployment on $MOSIP_DB_NAME database is started....Deployment Version...$release_version" | tee -a $LOG 2>&1 - -ALTER_SCRIPT_FILENAME_VERSION="sql/${release_version}_${ALTER_SCRIPT_FILENAME}" - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Alter scripts file which is considered for release deployment - $ALTER_SCRIPT_FILENAME_VERSION" | tee -a $LOG 2>&1 - -cd /$BASEPATH/$MOSIP_DB_NAME/ - -pwd | tee -a $LOG 2>&1 - -CONN=$(PGPASSWORD=$SYSADMIN_PWD psql --username=$SYSADMIN_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "SELECT count(pg_terminate_backend(pg_stat_activity.pid)) FROM pg_stat_activity WHERE datname = '$MOSIP_DB_NAME' AND pid <> pg_backend_pid()";exit; >> $LOG 2>&1) - -if [ ${CONN} == 0 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": No active database connections exist on ${MOSIP_DB_NAME}" | tee -a $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Active connections exist on the database server and active connection will be terminated for DB deployment." | tee -a $LOG 2>&1 -fi - -if [ ${ALTER_SCRIPT_FLAG} == 1 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Deploying Alter scripts for ${MOSIP_DB_NAME} database" | tee -a $LOG 2>&1 - PGPASSWORD=$SYSADMIN_PWD psql --username=$SYSADMIN_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $ALTER_SCRIPT_FILENAME_VERSION >> $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": There are no alter scripts available for this deployment at ${MOSIP_DB_NAME}" | tee -a $LOG 2>&1 -fi - -if [ $(grep -c ERROR $LOG) -ne 0 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Database Alter scripts deployment version $release_version is completed with ERRORS, Please check the logs for more information" | tee -a $LOG 2>&1 - echo `date "+%m/%d/%Y %H:%M:%S"` ": END of Alter scripts MOSIP database deployment" | tee -a $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Database Alter scripts deployment version $release_version completed successfully, Please check the logs for more information" | tee -a $LOG 2>&1 - echo `date "+%m/%d/%Y %H:%M:%S"` ": END of MOSIP \"${MOSIP_DB_NAME}\" database alter scripts deployment" | tee -a $LOG 2>&1 -fi - -echo "******************************************"`date "+%m/%d/%Y %H:%M:%S"` "*****************************************************" >> $LOG 2>&1 - - diff --git a/db_release_scripts/mosip_authdevice/authdevice_release_deploy.properties b/db_release_scripts/mosip_authdevice/authdevice_release_deploy.properties deleted file mode 100644 index e0c9ff9c2d7..00000000000 --- a/db_release_scripts/mosip_authdevice/authdevice_release_deploy.properties +++ /dev/null @@ -1,12 +0,0 @@ -DB_SERVERIP= -DB_PORT=30090 -SU_USER=postgres -DEFAULT_DB_NAME=postgres -MOSIP_DB_NAME=mosip_authdevice -SYSADMIN_USER=sysadmin -BASEPATH=/home/madmin/database_release -LOG_PATH=/home/madmin/logs/ -ALTER_SCRIPT_FLAG=1 -ALTER_SCRIPT_FILENAME=authdevice-scripts_release.sql -REVOKE_SCRIPT_FLAG=1 -REVOKE_SCRIPT_FILENAME=authdevice-scripts_revoke.sql diff --git a/db_release_scripts/mosip_authdevice/authdevice_revoke_db_deploy.sh b/db_release_scripts/mosip_authdevice/authdevice_revoke_db_deploy.sh deleted file mode 100644 index d79b96cfb72..00000000000 --- a/db_release_scripts/mosip_authdevice/authdevice_revoke_db_deploy.sh +++ /dev/null @@ -1,92 +0,0 @@ -### -- --------------------------------------------------------------------------------------------------------- -### -- Script Name : Authdevice Revoke DB deploy -### -- Deploy Module : MOSIP Authdevice -### -- Purpose : To revoke Authdevice Database alter scripts for the release. -### -- Create By : Ram Bhatt -### -- Created Date : Jan-2021 -### -- -### -- Modified Date Modified By Comments / Remarks -### -- ----------------------------------------------------------------------------------------------------------- - -### -- ----------------------------------------------------------------------------------------------------------- - -#########Properties file ############# -set -e -properties_file="$1" -revoke_version="$2" - echo `date "+%m/%d/%Y %H:%M:%S"` ": $properties_file" - echo `date "+%m/%d/%Y %H:%M:%S"` ": DB Revoke Version - $revoke_version" -#properties_file="./app.properties" -if [ -f "$properties_file" ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file \"$properties_file\" found." - while IFS='=' read -r key value - do - key=$(echo $key | tr '.' '_') - eval ${key}=\${value} - done < "$properties_file" -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file not found, Pass property file name as argument." -fi -echo `date "+%m/%d/%Y %H:%M:%S"` ": ------------------ Database server and service status check for ${MOSIP_DB_NAME}------------------------" - -today=`date '+%d%m%Y_%H%M%S'`; -LOG="${LOG_PATH}${MOSIP_DB_NAME}-revoke-${today}.log" -touch $LOG - -SERVICE=$(PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "select count(1) from pg_roles where rolname IN('sysadmin')";exit; > /dev/null) - -if [ "$SERVICE" -eq 0 ] || [ "$SERVICE" -eq 1 ] -then -echo `date "+%m/%d/%Y %H:%M:%S"` ": Postgres database server and service is up and running" | tee -a $LOG 2>&1 -else -echo `date "+%m/%d/%Y %H:%M:%S"` ": Postgres database server or service is not running" | tee -a $LOG 2>&1 -fi - -echo `date "+%m/%d/%Y %H:%M:%S"` ": ----------------------------------------------------------------------------------------" - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Started sourcing the $MOSIP_DB_NAME Database Deployment Revoke scripts" | tee -a $LOG 2>&1 - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Database revoke scripts are sourcing from :$BASEPATH/$MOSIP_DB_NAME/alter-scripts" | tee -a $LOG 2>&1 - -#========================================DB Alter Scripts deployment process begins on IDMAP DB SERVER================================== - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Revoke scripts for DB deployment on $MOSIP_DB_NAME database is started....Revoke Version...$revoke_version" | tee -a $LOG 2>&1 - -REVOKE_SCRIPT_FILENAME_VERSION="sql/${revoke_version}_${REVOKE_SCRIPT_FILENAME}" - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Alter scripts file which is considered for deployment revoke - $REVOKE_SCRIPT_FILENAME_VERSION" | tee -a $LOG 2>&1 - -cd /$BASEPATH/$MOSIP_DB_NAME/ - -pwd | tee -a $LOG 2>&1 - -CONN=$(PGPASSWORD=$SYSADMIN_PWD psql --username=$SYSADMIN_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "SELECT count(pg_terminate_backend(pg_stat_activity.pid)) FROM pg_stat_activity WHERE datname = '$MOSIP_DB_NAME' AND pid <> pg_backend_pid()";exit; >> $LOG 2>&1) - -if [ ${CONN} == 0 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": No active database connections exist on ${MOSIP_DB_NAME}" | tee -a $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Active connections exist on the database server and active connection will be terminated for DB deployment." | tee -a $LOG 2>&1 -fi - -if [ ${REVOKE_SCRIPT_FLAG} == 1 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Executing revoke scripts for ${MOSIP_DB_NAME} database" | tee -a $LOG 2>&1 - PGPASSWORD=$SYSADMIN_PWD psql --username=$SYSADMIN_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $REVOKE_SCRIPT_FILENAME_VERSION >> $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": There are no revoke scripts available for this deployment at ${MOSIP_DB_NAME}" | tee -a $LOG 2>&1 -fi - -if [ $(grep -c ERROR $LOG) -ne 0 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Database deployment revoke version $revoke_version is completed with ERRORS, Please check the logs for more information" | tee -a $LOG 2>&1 - echo `date "+%m/%d/%Y %H:%M:%S"` ": END of Alter scripts MOSIP database deployment" | tee -a $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Database deployment revoke version $revoke_version completed successfully, Please check the logs for more information" | tee -a $LOG 2>&1 - echo `date "+%m/%d/%Y %H:%M:%S"` ": END of MOSIP \"${MOSIP_DB_NAME}\" database deployment revoke" | tee -a $LOG 2>&1 -fi - -echo "******************************************"`date "+%m/%d/%Y %H:%M:%S"` "*****************************************************" >> $LOG 2>&1 - - diff --git a/db_release_scripts/mosip_authdevice/sql/1.1.5_authdevice-scripts_release.sql b/db_release_scripts/mosip_authdevice/sql/1.1.5_authdevice-scripts_release.sql deleted file mode 100644 index bffaa08e4f2..00000000000 --- a/db_release_scripts/mosip_authdevice/sql/1.1.5_authdevice-scripts_release.sql +++ /dev/null @@ -1,18 +0,0 @@ --- ------------------------------------------------------------------------------------------------- --- Database Name : mosip_authdevice --- Release Version : 1.2.0-SNAPSHOT --- Purpose : Database Alter scripts for the release for Authdevice DB. --- Create By : Ram Bhatt --- Created Date : Jan-2021 --- --- Modified Date Modified By Comments / Remarks --- --- ------------------------------------------------------------------------------------------------- - -\c mosip_authdevice sysadmin - --- ------------------------------------------------------------------------------------------------- - - - ----------------------------------------------------------------------------------------------------- diff --git a/db_release_scripts/mosip_authdevice/sql/1.1.5_authdevice-scripts_revoke.sql b/db_release_scripts/mosip_authdevice/sql/1.1.5_authdevice-scripts_revoke.sql deleted file mode 100644 index 9f34722c053..00000000000 --- a/db_release_scripts/mosip_authdevice/sql/1.1.5_authdevice-scripts_revoke.sql +++ /dev/null @@ -1,13 +0,0 @@ --- ------------------------------------------------------------------------------------------------- --- Database Name : mosip_authdevice --- Release Version : 1.2.0-SNAPSHOT --- Purpose : Revoking Database Alter deployement done for release in Authdevice DB. --- Create By : Ram Bhatt --- Created Date : Jan-2021 --- --- Modified Date Modified By Comments / Remarks --- ------------------------------------------------------------------------------------------------- - -\c mosip_authdevice sysadmin - ------------------------------------------------------------------------------------------------------ diff --git a/db_release_scripts/mosip_authdevice/sql/1.2_authdevice-scripts_release.sql b/db_release_scripts/mosip_authdevice/sql/1.2_authdevice-scripts_release.sql deleted file mode 100644 index 5b52b968139..00000000000 --- a/db_release_scripts/mosip_authdevice/sql/1.2_authdevice-scripts_release.sql +++ /dev/null @@ -1,30 +0,0 @@ --- ------------------------------------------------------------------------------------------------- --- Database Name : mosip_authdevice --- Release Version : 1.2.0-SNAPSHOT --- Purpose : Database Alter scripts for the release for Authdevice DB. --- Create By : Ram Bhatt --- Created Date : Nov-2021 --- --- Modified Date Modified By Comments / Remarks --- --- ------------------------------------------------------------------------------------------------- - -\c mosip_authdevice sysadmin - --- ------------------------------------------------------------------------------------------------- - -ALTER TABLE authdevice.secure_biometric_interface DROP CONSTRAINT IF EXISTS fk_sbi_id CASCADE; - - -ALTER TABLE authdevice.secure_biometric_interface ADD partner_org_name varchar(128); - -ALTER TABLE authdevice.secure_biometric_interface ADD provider_id varchar(36); - -ALTER TABLE authdevice.secure_biometric_interface_h ADD partner_org_name varchar(128); - -ALTER TABLE authdevice.secure_biometric_interface_h ADD provider_id varchar(36); - -ALTER TABLE authdevice.secure_biometric_interface DROP COLUMN IF EXISTS device_detail_id; -ALTER TABLE authdevice.secure_biometric_interface_h DROP COLUMN IF EXISTS device_detail_id; - ----------------------------------------------------------------------------------------------------- diff --git a/db_release_scripts/mosip_kernel/ddl/kernel-uin_assigned.sql b/db_release_scripts/mosip_kernel/ddl/kernel-uin_assigned.sql deleted file mode 100644 index 640a2d6d363..00000000000 --- a/db_release_scripts/mosip_kernel/ddl/kernel-uin_assigned.sql +++ /dev/null @@ -1,47 +0,0 @@ --- ------------------------------------------------------------------------------------------------- --- Database Name: mosip_kernel --- Table Name : kernel.uin_assigned --- Purpose : UIN ASSIGNED: Stores pre-generated UINs that are assigned to an individual as part of registration process.. --- --- Create By : Sadanandegowda DM --- Created Date : 20-May-2020 --- --- Modified Date Modified By Comments / Remarks --- ------------------------------------------------------------------------------------------ --- --- ------------------------------------------------------------------------------------------ - --- object: kernel.uin_assigned | type: TABLE -- --- DROP TABLE IF EXISTS kernel.uin_assigned CASCADE; -CREATE TABLE kernel.uin_assigned( - uin character varying(28) NOT NULL, - uin_status character varying(16), - cr_by character varying(256) NOT NULL, - cr_dtimes timestamp NOT NULL, - upd_by character varying(256), - upd_dtimes timestamp, - is_deleted boolean, - del_dtimes timestamp, - CONSTRAINT pk_uinass_id PRIMARY KEY (uin) - -); --- ddl-end -- -COMMENT ON TABLE kernel.uin_assigned IS 'UIN: Stores pre-generated UINs that are assigned to an individual as part of registration process.'; --- ddl-end -- -COMMENT ON COLUMN kernel.uin_assigned.uin IS 'UIN: Pre-generated UINs (Unique Identification Number), which will be used to assign to an individual'; --- ddl-end -- -COMMENT ON COLUMN kernel.uin_assigned.uin_status IS 'Is Used: Status of the pre-generated UIN, whether it is assigned, unassigned or issued.'; --- ddl-end -- -COMMENT ON COLUMN kernel.uin_assigned.cr_by IS 'Created By : ID or name of the user who create / insert record'; --- ddl-end -- -COMMENT ON COLUMN kernel.uin_assigned.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; --- ddl-end -- -COMMENT ON COLUMN kernel.uin_assigned.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; --- ddl-end -- -COMMENT ON COLUMN kernel.uin_assigned.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; --- ddl-end -- -COMMENT ON COLUMN kernel.uin_assigned.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; --- ddl-end -- -COMMENT ON COLUMN kernel.uin_assigned.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; --- ddl-end -- - diff --git a/db_release_scripts/mosip_kernel/ddl/kernel-vid_assigned.sql b/db_release_scripts/mosip_kernel/ddl/kernel-vid_assigned.sql deleted file mode 100644 index e528e5ac4c6..00000000000 --- a/db_release_scripts/mosip_kernel/ddl/kernel-vid_assigned.sql +++ /dev/null @@ -1,49 +0,0 @@ --- ------------------------------------------------------------------------------------------------- --- Database Name: mosip_kernel --- Table Name : kernel.vid_assigned --- Purpose : VID Assigned: Stores pre-generated VIDs that are assigned /expired to an individual as part of mosip process. --- --- Create By : Sadanandegowda DM --- Created Date : Dec-2020 --- --- Modified Date Modified By Comments / Remarks --- ------------------------------------------------------------------------------------------ --- --- ------------------------------------------------------------------------------------------ - --- object: kernel.vid_assigned | type: TABLE -- --- DROP TABLE IF EXISTS kernel.vid_assigned CASCADE; -CREATE TABLE kernel.vid_assigned( - vid character varying(36) NOT NULL, - expiry_dtimes timestamp, - vid_status character varying(16) NOT NULL, - cr_by character varying(256) NOT NULL, - cr_dtimes timestamp NOT NULL, - upd_by character varying(256), - upd_dtimes timestamp, - is_deleted boolean, - del_dtimes timestamp, - CONSTRAINT pk_vida_id PRIMARY KEY (vid) - -); --- ddl-end -- -COMMENT ON TABLE kernel.vid_assigned IS 'VID Assigned: Stores pre-generated VIDs that are assigned /expired to an individual as part of mosip process.'; --- ddl-end -- -COMMENT ON COLUMN kernel.vid_assigned.vid IS 'VID: Pre-generated VIDs (Vertual Identification Number), which will be used to assign to an individual'; --- ddl-end -- -COMMENT ON COLUMN kernel.vid_assigned.expiry_dtimes IS 'Expiry Date and Time: Expiry Date and Time of the Vertual ID'; --- ddl-end -- -COMMENT ON COLUMN kernel.vid_assigned.vid_status IS 'VID: Status of the pre-generated VID, whether it is available, expired or assigned.'; --- ddl-end -- -COMMENT ON COLUMN kernel.vid_assigned.cr_by IS 'Created By : ID or name of the user who create / insert record'; --- ddl-end -- -COMMENT ON COLUMN kernel.vid_assigned.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted'; --- ddl-end -- -COMMENT ON COLUMN kernel.vid_assigned.upd_by IS 'Updated By : ID or name of the user who update the record with new values'; --- ddl-end -- -COMMENT ON COLUMN kernel.vid_assigned.upd_dtimes IS 'Updated DateTimestamp : Date and Timestamp when any of the fields in the record is updated with new values.'; --- ddl-end -- -COMMENT ON COLUMN kernel.vid_assigned.is_deleted IS 'IS_Deleted : Flag to mark whether the record is Soft deleted.'; --- ddl-end -- -COMMENT ON COLUMN kernel.vid_assigned.del_dtimes IS 'Deleted DateTimestamp : Date and Timestamp when the record is soft deleted with is_deleted=TRUE'; --- ddl-end -- \ No newline at end of file diff --git a/db_release_scripts/mosip_regdevice/regdevice_release_db_deploy.sh b/db_release_scripts/mosip_regdevice/regdevice_release_db_deploy.sh deleted file mode 100644 index d0d399d7764..00000000000 --- a/db_release_scripts/mosip_regdevice/regdevice_release_db_deploy.sh +++ /dev/null @@ -1,92 +0,0 @@ -### -- --------------------------------------------------------------------------------------------------------- -### -- Script Name : Key Manager Release DB deploy -### -- Deploy Module : MOSIP Key Manager -### -- Purpose : To deploy Key Manager Database alter scripts for the release. -### -- Create By : Sadanandegowda -### -- Created Date : Dec-2020 -### -- -### -- Modified Date Modified By Comments / Remarks -### -- ----------------------------------------------------------------------------------------------------------- - -### -- ----------------------------------------------------------------------------------------------------------- - -#########Properties file ############# -set -e -properties_file="$1" -release_version="$2" - echo `date "+%m/%d/%Y %H:%M:%S"` ": Properties File Name - $properties_file" - echo `date "+%m/%d/%Y %H:%M:%S"` ": DB Deploymnet Version - $release_version" -#properties_file="./app.properties" -if [ -f "$properties_file" ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file \"$properties_file\" found." - while IFS='=' read -r key value - do - key=$(echo $key | tr '.' '_') - eval ${key}=\${value} - done < "$properties_file" -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file not found, Pass property file name as argument." -fi -echo `date "+%m/%d/%Y %H:%M:%S"` ": ------------------ Database server and service status check for ${MOSIP_DB_NAME}------------------------" - -today=`date '+%d%m%Y_%H%M%S'`; -LOG="${LOG_PATH}${MOSIP_DB_NAME}-release-${release_version}-${today}.log" -touch $LOG - -SERVICE=$(PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "select count(1) from pg_roles where rolname IN('sysadmin')";exit; > /dev/null) - -if [ "$SERVICE" -eq 0 ] || [ "$SERVICE" -eq 1 ] -then -echo `date "+%m/%d/%Y %H:%M:%S"` ": Postgres database server and service is up and running" | tee -a $LOG 2>&1 -else -echo `date "+%m/%d/%Y %H:%M:%S"` ": Postgres database server or service is not running" | tee -a $LOG 2>&1 -fi - -echo `date "+%m/%d/%Y %H:%M:%S"` ": ----------------------------------------------------------------------------------------" - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Started sourcing the $MOSIP_DB_NAME Database Alter scripts" | tee -a $LOG 2>&1 - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Database Alter scripts are sourcing from :$BASEPATH/$MOSIP_DB_NAME/" | tee -a $LOG 2>&1 - -#========================================DB Alter Scripts deployment process begins on Key Manager DB SERVER================================== - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Alter scripts deployment on $MOSIP_DB_NAME database is started....Deployment Version...$release_version" | tee -a $LOG 2>&1 - -ALTER_SCRIPT_FILENAME_VERSION="sql/${release_version}_${ALTER_SCRIPT_FILENAME}" - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Alter scripts file which is considered for release deployment - $ALTER_SCRIPT_FILENAME_VERSION" | tee -a $LOG 2>&1 - -cd /$BASEPATH/$MOSIP_DB_NAME/ - -pwd | tee -a $LOG 2>&1 - -CONN=$(PGPASSWORD=$SYSADMIN_PWD psql --username=$SYSADMIN_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "SELECT count(pg_terminate_backend(pg_stat_activity.pid)) FROM pg_stat_activity WHERE datname = '$MOSIP_DB_NAME' AND pid <> pg_backend_pid()";exit; >> $LOG 2>&1) - -if [ ${CONN} == 0 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": No active database connections exist on ${MOSIP_DB_NAME}" | tee -a $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Active connections exist on the database server and active connection will be terminated for DB deployment." | tee -a $LOG 2>&1 -fi - -if [ ${ALTER_SCRIPT_FLAG} == 1 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Deploying Alter scripts for ${MOSIP_DB_NAME} database" | tee -a $LOG 2>&1 - PGPASSWORD=$SYSADMIN_PWD psql --username=$SYSADMIN_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $ALTER_SCRIPT_FILENAME_VERSION >> $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": There are no alter scripts available for this deployment at ${MOSIP_DB_NAME}" | tee -a $LOG 2>&1 -fi - -if [ $(grep -c ERROR $LOG) -ne 0 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Database Alter scripts deployment version $release_version is completed with ERRORS, Please check the logs for more information" | tee -a $LOG 2>&1 - echo `date "+%m/%d/%Y %H:%M:%S"` ": END of Alter scripts MOSIP database deployment" | tee -a $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Database Alter scripts deployment version $release_version completed successfully, Please check the logs for more information" | tee -a $LOG 2>&1 - echo `date "+%m/%d/%Y %H:%M:%S"` ": END of MOSIP \"${MOSIP_DB_NAME}\" database alter scripts deployment" | tee -a $LOG 2>&1 -fi - -echo "******************************************"`date "+%m/%d/%Y %H:%M:%S"` "*****************************************************" >> $LOG 2>&1 - - diff --git a/db_release_scripts/mosip_regdevice/regdevice_release_deploy.properties b/db_release_scripts/mosip_regdevice/regdevice_release_deploy.properties deleted file mode 100644 index e93518bfcb1..00000000000 --- a/db_release_scripts/mosip_regdevice/regdevice_release_deploy.properties +++ /dev/null @@ -1,12 +0,0 @@ -DB_SERVERIP= -DB_PORT=30090 -SU_USER=postgres -DEFAULT_DB_NAME=postgres -MOSIP_DB_NAME=mosip_regdevice -SYSADMIN_USER=sysadmin -BASEPATH=/home/madmin/database_release -LOG_PATH=/home/madmin/logs/ -ALTER_SCRIPT_FLAG=1 -ALTER_SCRIPT_FILENAME=regdevice-scripts_release.sql -REVOKE_SCRIPT_FLAG=1 -REVOKE_SCRIPT_FILENAME=regdevice-scripts_revoke.sql diff --git a/db_release_scripts/mosip_regdevice/regdevice_revoke_db_deploy.sh b/db_release_scripts/mosip_regdevice/regdevice_revoke_db_deploy.sh deleted file mode 100644 index 308d94a4254..00000000000 --- a/db_release_scripts/mosip_regdevice/regdevice_revoke_db_deploy.sh +++ /dev/null @@ -1,92 +0,0 @@ -### -- --------------------------------------------------------------------------------------------------------- -### -- Script Name : Key Manager Revoke DB deploy -### -- Deploy Module : MOSIP Key Manager -### -- Purpose : To revoke Key Manager Database alter scripts for the release. -### -- Create By : Sadanandegowda -### -- Created Date : Dec-2020 -### -- -### -- Modified Date Modified By Comments / Remarks -### -- ----------------------------------------------------------------------------------------------------------- - -### -- ----------------------------------------------------------------------------------------------------------- - -#########Properties file ############# -set -e -properties_file="$1" -revoke_version="$2" - echo `date "+%m/%d/%Y %H:%M:%S"` ": $properties_file" - echo `date "+%m/%d/%Y %H:%M:%S"` ": DB Revoke Version - $revoke_version" -#properties_file="./app.properties" -if [ -f "$properties_file" ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file \"$properties_file\" found." - while IFS='=' read -r key value - do - key=$(echo $key | tr '.' '_') - eval ${key}=\${value} - done < "$properties_file" -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file not found, Pass property file name as argument." -fi -echo `date "+%m/%d/%Y %H:%M:%S"` ": ------------------ Database server and service status check for ${MOSIP_DB_NAME}------------------------" - -today=`date '+%d%m%Y_%H%M%S'`; -LOG="${LOG_PATH}${MOSIP_DB_NAME}-revoke-${today}.log" -touch $LOG - -SERVICE=$(PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "select count(1) from pg_roles where rolname IN('sysadmin')";exit; > /dev/null) - -if [ "$SERVICE" -eq 0 ] || [ "$SERVICE" -eq 1 ] -then -echo `date "+%m/%d/%Y %H:%M:%S"` ": Postgres database server and service is up and running" | tee -a $LOG 2>&1 -else -echo `date "+%m/%d/%Y %H:%M:%S"` ": Postgres database server or service is not running" | tee -a $LOG 2>&1 -fi - -echo `date "+%m/%d/%Y %H:%M:%S"` ": ----------------------------------------------------------------------------------------" - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Started sourcing the $MOSIP_DB_NAME Database Deployment Revoke scripts" | tee -a $LOG 2>&1 - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Database revoke scripts are sourcing from :$BASEPATH/$MOSIP_DB_NAME/alter-scripts" | tee -a $LOG 2>&1 - -#========================================DB Alter Scripts deployment process begins on Key Manager DB SERVER================================== - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Revoke scripts for DB deployment on $MOSIP_DB_NAME database is started....Revoke Version...$revoke_version" | tee -a $LOG 2>&1 - -REVOKE_SCRIPT_FILENAME_VERSION="sql/${revoke_version}_${REVOKE_SCRIPT_FILENAME}" - -echo `date "+%m/%d/%Y %H:%M:%S"` ": Alter scripts file which is considered for deployment revoke - $REVOKE_SCRIPT_FILENAME_VERSION" | tee -a $LOG 2>&1 - -cd /$BASEPATH/$MOSIP_DB_NAME/ - -pwd | tee -a $LOG 2>&1 - -CONN=$(PGPASSWORD=$SYSADMIN_PWD psql --username=$SYSADMIN_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "SELECT count(pg_terminate_backend(pg_stat_activity.pid)) FROM pg_stat_activity WHERE datname = '$MOSIP_DB_NAME' AND pid <> pg_backend_pid()";exit; >> $LOG 2>&1) - -if [ ${CONN} == 0 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": No active database connections exist on ${MOSIP_DB_NAME}" | tee -a $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Active connections exist on the database server and active connection will be terminated for DB deployment." | tee -a $LOG 2>&1 -fi - -if [ ${REVOKE_SCRIPT_FLAG} == 1 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Executing revoke scripts for ${MOSIP_DB_NAME} database" | tee -a $LOG 2>&1 - PGPASSWORD=$SYSADMIN_PWD psql --username=$SYSADMIN_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $REVOKE_SCRIPT_FILENAME_VERSION >> $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": There are no revoke scripts available for this deployment at ${MOSIP_DB_NAME}" | tee -a $LOG 2>&1 -fi - -if [ $(grep -c ERROR $LOG) -ne 0 ] -then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Database deployment revoke version $revoke_version is completed with ERRORS, Please check the logs for more information" | tee -a $LOG 2>&1 - echo `date "+%m/%d/%Y %H:%M:%S"` ": END of Alter scripts MOSIP database deployment" | tee -a $LOG 2>&1 -else - echo `date "+%m/%d/%Y %H:%M:%S"` ": Database deployment revoke version $revoke_version completed successfully, Please check the logs for more information" | tee -a $LOG 2>&1 - echo `date "+%m/%d/%Y %H:%M:%S"` ": END of MOSIP \"${MOSIP_DB_NAME}\" database deployment revoke" | tee -a $LOG 2>&1 -fi - -echo "******************************************"`date "+%m/%d/%Y %H:%M:%S"` "*****************************************************" >> $LOG 2>&1 - - diff --git a/db_release_scripts/mosip_regdevice/sql/1.1.5_regdevice-scripts_release.sql b/db_release_scripts/mosip_regdevice/sql/1.1.5_regdevice-scripts_release.sql deleted file mode 100644 index c8d54c8a423..00000000000 --- a/db_release_scripts/mosip_regdevice/sql/1.1.5_regdevice-scripts_release.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ------------------------------------------------------------------------------------------------- --- Database Name : mosip_regdevice --- Release Version : 1.2.0-SNAPSHOT --- Purpose : Database Alter scripts for the release for Regdevice DB. --- Create By : Ram Bhatt --- Created Date : Jan-2021 --- --- Modified Date Modified By Comments / Remarks --- ------------------------------------------------------------------------------------------------- - -\c mosip_regdevice sysadmin - - ----------------------------------------------------------------------------------------------------- diff --git a/db_release_scripts/mosip_regdevice/sql/1.1.5_regdevice-scripts_revoke.sql b/db_release_scripts/mosip_regdevice/sql/1.1.5_regdevice-scripts_revoke.sql deleted file mode 100644 index 237d6416b0b..00000000000 --- a/db_release_scripts/mosip_regdevice/sql/1.1.5_regdevice-scripts_revoke.sql +++ /dev/null @@ -1,13 +0,0 @@ --- ------------------------------------------------------------------------------------------------- --- Database Name : mosip_keymgr --- Release Version : 1.2.0-SNAPSHOT --- Purpose : Revoking Database Alter deployement done for release in Key manager DB. --- Create By : Ram Bhatt --- Created Date : Jan-2021 --- --- Modified Date Modified By Comments / Remarks --- ------------------------------------------------------------------------------------------------- - -\c mosip_kernel sysadmin - ------------------------------------------------------------------------------------------------------ diff --git a/db_release_scripts/mosip_regdevice/sql/1.2_regdevice-scripts_release.sql b/db_release_scripts/mosip_regdevice/sql/1.2_regdevice-scripts_release.sql deleted file mode 100644 index 2dac3e0d284..00000000000 --- a/db_release_scripts/mosip_regdevice/sql/1.2_regdevice-scripts_release.sql +++ /dev/null @@ -1,14 +0,0 @@ --- ------------------------------------------------------------------------------------------------- --- Database Name : mosip_regdevice --- Release Version : 1.2.0-SNAPSHOT --- Purpose : Database Alter scripts for the release for Regdevice DB. --- Create By : Ram Bhatt --- Created Date : Nov-2021 --- --- Modified Date Modified By Comments / Remarks --- ------------------------------------------------------------------------------------------------- - -\c mosip_regdevice sysadmin - -ALTER TABLE regdevice.secure_biometric_interface DROP CONSTRAINT IF EXISTS fk_sbi_id CASCADE; ----------------------------------------------------------------------------------------------------- diff --git a/db_scripts/mosip_authdevice/deploy.sh b/db_scripts/mosip_authdevice/deploy.sh index 16f2473b108..a92ed4528e9 100644 --- a/db_scripts/mosip_authdevice/deploy.sh +++ b/db_scripts/mosip_authdevice/deploy.sh @@ -33,7 +33,7 @@ PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_S ## Create DB echo "Creating DB" -PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f db.sql +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f db.sql PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f ddl.sql ## Grants @@ -43,6 +43,6 @@ PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_S if [ ${DML_FLAG} == 1 ] then echo `date "+%m/%d/%Y %H:%M:%S"` ": Deploying DML for ${MOSIP_DB_NAME} database" - PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f dml.sql + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f dml.sql fi diff --git a/db_scripts/mosip_kernel/deploy.sh b/db_scripts/mosip_kernel/deploy.sh index 3b166828361..f7e228ffdc6 100644 --- a/db_scripts/mosip_kernel/deploy.sh +++ b/db_scripts/mosip_kernel/deploy.sh @@ -29,7 +29,7 @@ PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_S ## Create DB echo "Creating DB and tables" -PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f db.sql +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f db.sql PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f ddl.sql ## Create users @@ -41,6 +41,6 @@ PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_S if [ ${DML_FLAG} == 1 ] then echo `date "+%m/%d/%Y %H:%M:%S"` ": Deploying DML for ${MOSIP_DB_NAME} database" - PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f dml.sql + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f dml.sql fi diff --git a/db_scripts/mosip_regdevice/deploy.sh b/db_scripts/mosip_regdevice/deploy.sh index d78f82c4dfd..dedfb684920 100644 --- a/db_scripts/mosip_regdevice/deploy.sh +++ b/db_scripts/mosip_regdevice/deploy.sh @@ -29,20 +29,20 @@ PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_S ## Create users echo `date "+%m/%d/%Y %H:%M:%S"` ": Creating database users" -PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f role_dbuser.sql -v dbuserpwd=\'$DBUSER_PWD\' +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f role_dbuser.sql -v dbuserpwd=\'$DBUSER_PWD\' ## Create DB echo "Creating DB" PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f db.sql -PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f ddl.sql +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f ddl.sql ## Grants -PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f grants.sql +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f grants.sql ## Populate tables if [ ${DML_FLAG} == 1 ] then echo `date "+%m/%d/%Y %H:%M:%S"` ": Deploying DML for ${MOSIP_DB_NAME} database" - PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f dml.sql + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f dml.sql fi diff --git a/db_release_scripts/README.MD b/db_upgrade_scripts/README.MD similarity index 100% rename from db_release_scripts/README.MD rename to db_upgrade_scripts/README.MD diff --git a/db_upgrade_scripts/mosip_kernel/sql/1.1.5.5_to_1.2.0.1-B1_rollback.sql b/db_upgrade_scripts/mosip_kernel/sql/1.1.5.5_to_1.2.0.1-B1_rollback.sql new file mode 100644 index 00000000000..80b4115a3fc --- /dev/null +++ b/db_upgrade_scripts/mosip_kernel/sql/1.1.5.5_to_1.2.0.1-B1_rollback.sql @@ -0,0 +1,5 @@ +\c mosip_kernel + +REASSIGN OWNED BY postgres TO sysadmin; + +GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA kernel TO sysadmin; diff --git a/db_upgrade_scripts/mosip_kernel/sql/1.1.5.5_to_1.2.0.1-B1_upgrade.sql b/db_upgrade_scripts/mosip_kernel/sql/1.1.5.5_to_1.2.0.1-B1_upgrade.sql new file mode 100644 index 00000000000..98d6d039609 --- /dev/null +++ b/db_upgrade_scripts/mosip_kernel/sql/1.1.5.5_to_1.2.0.1-B1_upgrade.sql @@ -0,0 +1,17 @@ +\c mosip_kernel + +REASSIGN OWNED BY sysadmin TO postgres; + +REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA kernel FROM kerneluser; + +REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA kernel FROM sysadmin; + +GRANT SELECT, INSERT, TRUNCATE, REFERENCES, UPDATE, DELETE ON ALL TABLES IN SCHEMA kernel TO kerneluser; + +GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA kernel TO postgres; + + +CREATE INDEX IF NOT EXISTS idx_prid_status + ON kernel.prid USING btree + (prid_status COLLATE pg_catalog."default" ASC NULLS LAST) + TABLESPACE pg_default; diff --git a/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B1_to_1.2.0.1-B2_rollback.sql b/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B1_to_1.2.0.1-B2_rollback.sql new file mode 100644 index 00000000000..381e2be11c1 --- /dev/null +++ b/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B1_to_1.2.0.1-B2_rollback.sql @@ -0,0 +1 @@ +\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION' \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B1_to_1.2.0.1-B2_upgrade.sql b/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B1_to_1.2.0.1-B2_upgrade.sql new file mode 100644 index 00000000000..381e2be11c1 --- /dev/null +++ b/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B1_to_1.2.0.1-B2_upgrade.sql @@ -0,0 +1 @@ +\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION' \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B2_to_1.2.0.1_rollback.sql b/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B2_to_1.2.0.1_rollback.sql new file mode 100644 index 00000000000..381e2be11c1 --- /dev/null +++ b/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B2_to_1.2.0.1_rollback.sql @@ -0,0 +1 @@ +\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION' \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B2_to_1.2.0.1_upgrade.sql b/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B2_to_1.2.0.1_upgrade.sql new file mode 100644 index 00000000000..381e2be11c1 --- /dev/null +++ b/db_upgrade_scripts/mosip_kernel/sql/1.2.0.1-B2_to_1.2.0.1_upgrade.sql @@ -0,0 +1 @@ +\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION' \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_kernel/upgrade.properties b/db_upgrade_scripts/mosip_kernel/upgrade.properties new file mode 100644 index 00000000000..1b337f9025d --- /dev/null +++ b/db_upgrade_scripts/mosip_kernel/upgrade.properties @@ -0,0 +1,12 @@ +ACTION=upgrade +MOSIP_DB_NAME=mosip_kernel +DB_SERVERIP= +DB_PORT= +SU_USER=postgres +SU_USER_PWD= +SYS_ADMIN_USER= +SYS_ADMIN_PWD= +DEFAULT_DB_NAME=postgres +DBUSER_PWD= +CURRENT_VERSION= +UPGRADE_VERSION= diff --git a/db_upgrade_scripts/mosip_kernel/upgrade.sh b/db_upgrade_scripts/mosip_kernel/upgrade.sh new file mode 100644 index 00000000000..f5fc706f8c3 --- /dev/null +++ b/db_upgrade_scripts/mosip_kernel/upgrade.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +set -e +properties_file="$1" +echo `date "+%m/%d/%Y %H:%M:%S"` ": $properties_file" +if [ -f "$properties_file" ] +then + echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file \"$properties_file\" found." + while IFS='=' read -r key value + do + key=$(echo $key | tr '.' '_') + eval ${key}=\${value} + done < "$properties_file" +else + echo `date "+%m/%d/%Y %H:%M:%S"` ": Property file not found, Pass property file name as argument." +fi + +echo "Current version: "$CURRENT_VERSION +echo "UPGRADE version: "$UPGRADE_VERSION +echo "Action: "$ACTION + +# Terminate existing connections +echo "Terminating active connections" +CONN=$(PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "SELECT count(pg_terminate_backend(pg_stat_activity.pid)) FROM pg_stat_activity WHERE datname = '$MOSIP_DB_NAME' AND pid <> pg_backend_pid()";exit;) +echo "Terminated connections" + +# Execute upgrade or rollback +if [ $ACTION == "upgrade" ]; then + echo "Upgrading database from $CURRENT_VERSION to $UPGRADE_VERSION" + UPGRADE_SCRIPT_FILE="sql/${CURRENT_VERSION}_to_${UPGRADE_VERSION}_upgrade.sql" + if [ -f "$UPGRADE_SCRIPT_FILE" ]; then + echo "Executing upgrade script $UPGRADE_SCRIPT_FILE" + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $UPGRADE_SCRIPT_FILE + else + echo "Upgrade script not found, exiting." + exit 1 + fi +elif [ $ACTION == "rollback" ]; then + echo "Rolling back database for $CURRENT_VERSION to $UPGRADE_VERSION" + REVOKE_SCRIPT_FILE="sql/${CURRENT_VERSION}_to_${UPGRADE_VERSION}_rollback.sql" + if [ -f "$REVOKE_SCRIPT_FILE" ]; then + echo "Executing rollback script $REVOKE_SCRIPT_FILE" + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f $REVOKE_SCRIPT_FILE + else + echo "rollback script not found, exiting." + exit 1 + fi +else + echo "Unknown action: $ACTION, must be 'upgrade' or 'rollback'." + exit 1 +fi diff --git a/kernel/kernel-authcodeflowproxy-api/src/main/java/io/mosip/kernel/authcodeflowproxy/api/service/LoginService.java b/kernel/kernel-authcodeflowproxy-api/src/main/java/io/mosip/kernel/authcodeflowproxy/api/service/LoginService.java index 9762d3f217b..1d739234238 100644 --- a/kernel/kernel-authcodeflowproxy-api/src/main/java/io/mosip/kernel/authcodeflowproxy/api/service/LoginService.java +++ b/kernel/kernel-authcodeflowproxy-api/src/main/java/io/mosip/kernel/authcodeflowproxy/api/service/LoginService.java @@ -6,7 +6,6 @@ import io.mosip.kernel.authcodeflowproxy.api.dto.AccessTokenResponseDTO; import io.mosip.kernel.authcodeflowproxy.api.dto.MosipUserDto; -import io.mosip.kernel.core.authmanager.model.AuthResponseDto; public interface LoginService { diff --git a/kernel/kernel-authcodeflowproxy-api/src/test/java/io/mosip/kernel/authcodeflowproxy/api/test/controller/AuthProxyControllerTests.java b/kernel/kernel-authcodeflowproxy-api/src/test/java/io/mosip/kernel/authcodeflowproxy/api/test/controller/AuthProxyControllerTests.java index 1dcd4c8d829..3761e2353cf 100644 --- a/kernel/kernel-authcodeflowproxy-api/src/test/java/io/mosip/kernel/authcodeflowproxy/api/test/controller/AuthProxyControllerTests.java +++ b/kernel/kernel-authcodeflowproxy-api/src/test/java/io/mosip/kernel/authcodeflowproxy/api/test/controller/AuthProxyControllerTests.java @@ -684,4 +684,4 @@ public void logoutRedirectHostCheckTest() throws Exception { } -} +} \ No newline at end of file diff --git a/kernel/kernel-biometrics-api/README.md b/kernel/kernel-biometrics-api/README.md index a3f31815c91..d55fbeb07de 100644 --- a/kernel/kernel-biometrics-api/README.md +++ b/kernel/kernel-biometrics-api/README.md @@ -1,4 +1,12 @@ # Kernel Biometrics Api ## [DEPRECATED] + THIS MODULE IS MOVED TO https://github.com/mosip/bio-utils + +## Overview +This library provides core funtions related to biometrics. + +## Technical features +- Creation and conversion of XML and BIR models. +- Biometric opertions like matching and quality assessment. diff --git a/kernel/kernel-core/src/main/java/io/mosip/kernel/core/util/ZipUtils.java b/kernel/kernel-core/src/main/java/io/mosip/kernel/core/util/ZipUtils.java index 706d0b99efb..9e204124beb 100644 --- a/kernel/kernel-core/src/main/java/io/mosip/kernel/core/util/ZipUtils.java +++ b/kernel/kernel-core/src/main/java/io/mosip/kernel/core/util/ZipUtils.java @@ -361,7 +361,7 @@ public static boolean unZipDirectory(String zipFilePath, String destDirectory) t try (ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath))) { - ZipEntry entry = zipIn.getNextEntry(); + ZipEntry entry = zipIn.getNextEntry(); //NOSONAR Setting the ZipEntry here. while (entry != null) { String filePath = destDirectory + File.separator + entry.getName(); @@ -387,7 +387,7 @@ public static boolean unZipDirectory(String zipFilePath, String destDirectory) t } } zipIn.closeEntry(); - entry = zipIn.getNextEntry(); + entry = zipIn.getNextEntry(); //NOSONAR Setting the Next Entry here. } } catch (java.io.FileNotFoundException e) { throw new FileNotFoundException(ZipUtilConstants.FILE_NOT_FOUND_ERROR_CODE.getErrorCode(), diff --git a/kernel/kernel-logger-logback/src/main/java/io/mosip/kernel/logger/logback/impl/LoggerImpl.java b/kernel/kernel-logger-logback/src/main/java/io/mosip/kernel/logger/logback/impl/LoggerImpl.java index be8b426287d..88684461e9f 100644 --- a/kernel/kernel-logger-logback/src/main/java/io/mosip/kernel/logger/logback/impl/LoggerImpl.java +++ b/kernel/kernel-logger-logback/src/main/java/io/mosip/kernel/logger/logback/impl/LoggerImpl.java @@ -68,12 +68,12 @@ private LoggerImpl(ConsoleAppender mosipConsoleAppender, String name, LogLevel l consoleAppender.setTarget(mosipConsoleAppender.getTarget()); consoleAppender.start(); if (logLevel != null) { - this.logger.setLevel(Level.valueOf(logLevel.getLevel())); + this.logger.setLevel(Level.valueOf(logLevel.getLevel())); //NOSONAR Setting the loglevel here. } else { - this.logger.setLevel(Level.valueOf(LogLevel.DEBUG.getLevel())); + this.logger.setLevel(Level.valueOf(LogLevel.DEBUG.getLevel())); //NOSONAR Setting the loglevel to DEBUG here. } this.logger.setAdditive(false); - this.logger.addAppender(consoleAppender); + this.logger.addAppender(consoleAppender); //NOSONAR Adding the console appender here. } /** @@ -106,11 +106,11 @@ private LoggerImpl(FileAppender mosipFileAppender, String name, LogLevel logLeve .get(mosipFileAppender.getAppenderName()); } if (logLevel != null) { - this.logger.setLevel(Level.valueOf(logLevel.getLevel())); + this.logger.setLevel(Level.valueOf(logLevel.getLevel())); //NOSONAR Setting the loglevel here. } else { - this.logger.setLevel(Level.valueOf(LogLevel.DEBUG.getLevel())); + this.logger.setLevel(Level.valueOf(LogLevel.DEBUG.getLevel())); //NOSONAR Setting the loglevel to DEBUG here. } - this.logger.addAppender(fileAppender); + this.logger.addAppender(fileAppender); //NOSONAR Adding the file appender here. } /** @@ -148,11 +148,11 @@ private LoggerImpl(RollingFileAppender mosipRollingFileAppender, String name, Lo .get(mosipRollingFileAppender.getAppenderName()); } if (logLevel != null) { - this.logger.setLevel(Level.valueOf(logLevel.getLevel())); + this.logger.setLevel(Level.valueOf(logLevel.getLevel())); //NOSONAR Setting the loglevel here. } else { - this.logger.setLevel(Level.valueOf(LogLevel.DEBUG.getLevel())); + this.logger.setLevel(Level.valueOf(LogLevel.DEBUG.getLevel())); //NOSONAR Setting the loglevel to DEBUG here. } - this.logger.addAppender(rollingFileAppender); + this.logger.addAppender(rollingFileAppender); //NOSONAR Adding the rolling file appender here. } From 2d7e0d356c96b3fd97d96a758fafa460c35d7a2f Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Fri, 31 May 2024 11:03:10 +0530 Subject: [PATCH 09/10] Added repository in pom Signed-off-by: Loganathan Sekar --- kernel/kernel-config-server/pom.xml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/kernel-config-server/pom.xml b/kernel/kernel-config-server/pom.xml index 07d2a70ff00..d867b7f7698 100644 --- a/kernel/kernel-config-server/pom.xml +++ b/kernel/kernel-config-server/pom.xml @@ -69,8 +69,18 @@ spring-cloud-starter-bootstrap - - + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + org.springframework.boot spring-boot-maven-plugin From f78f7fa2a03412ffce209035e237a403939ab94b Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Fri, 31 May 2024 13:31:18 +0530 Subject: [PATCH 10/10] commit id fix Signed-off-by: Loganathan Sekar --- kernel/kernel-config-server/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kernel-config-server/pom.xml b/kernel/kernel-config-server/pom.xml index d867b7f7698..3dfaa9ef720 100644 --- a/kernel/kernel-config-server/pom.xml +++ b/kernel/kernel-config-server/pom.xml @@ -196,7 +196,7 @@ true - ${project.build.outputDirectory}/git.properties + ${project.build.outputDirectory}/service-git.properties ^git.build.(time|version)$ ^git.commit.id.(abbrev|full)$