Compare commits
10 Commits
fix-get-da
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e82f4776c | ||
|
|
aa7bbd6a4c | ||
|
|
7800953960 | ||
|
|
1fc4581106 | ||
|
|
081447008c | ||
|
|
24ff5a8687 | ||
|
|
a55574ac9b | ||
|
|
9c736b4804 | ||
|
|
3efa16e19e | ||
|
|
c4d2bab59c |
@@ -1,8 +1,9 @@
|
||||
language: php
|
||||
language: python
|
||||
before_script:
|
||||
- git clone --depth 1 git://github.com/YunoHost/package_linter ../package_linter && cd ../package_linter
|
||||
- mv ../vpnclient_ynh vpnclient_ynh
|
||||
script:
|
||||
- python -m json.tool vpnclient_ynh/manifest.json
|
||||
- ./package_linter.py vpnclient_ynh
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# VPN Client
|
||||
[](https://travis-ci.org/labriqueinternet/vpnclient_ynh)
|
||||
# VPN Client [](https://travis-ci.org/labriqueinternet/vpnclient_ynh) [](https://ci-apps.yunohost.org/jenkins/job/vpnclient%20%28Community%29/lastBuild/consoleFull)
|
||||
[](https://install-app.yunohost.org/?app=vpnclient)
|
||||
|
||||
## Overview
|
||||
|
||||
VPN Client app for [YunoHost](http://yunohost.org/).
|
||||
|
||||
40
check_process
Normal file
40
check_process
Normal file
@@ -0,0 +1,40 @@
|
||||
;; Test complet
|
||||
; pre-install
|
||||
echo -n "Si j'avais des commandes à exécuter ce serait ici "
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/vpnconfig" (PATH)
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=0
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=0
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=355b24ea0cd3467d7ba1390ab7d34dd4b2500229
|
||||
upgrade=1 from_commit=1fc458110660ce775f7613091cde3c5fdcfbe4e6
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
incorrect_path=1
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
Level 4=0
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=pitchum@gramaton.org
|
||||
Notification=down
|
||||
#;;; Upgrade options
|
||||
# ; commit=65c382d138596fcb32b4c97c39398815a1dcd4e8
|
||||
# name=Name of this previous version
|
||||
# manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1&
|
||||
#
|
||||
@@ -129,6 +129,10 @@ start_openvpn() {
|
||||
[ "${ynh_server_proto}" == tcp ] && proto=tcp-client
|
||||
fi
|
||||
|
||||
# Unset firewall to let DNS and NTP resolution works
|
||||
# Firewall is reset after vpn is mounted (more details on #1016)
|
||||
unset_firewall
|
||||
|
||||
sync_time
|
||||
|
||||
cp /etc/openvpn/client.conf{.tpl,}
|
||||
@@ -200,6 +204,20 @@ stop_openvpn() {
|
||||
sync_time() {
|
||||
systemctl stop ntp
|
||||
timeout 20 ntpd -qg &> /dev/null
|
||||
|
||||
# Some networks drop ntp port (udp 123).
|
||||
# Try to get the date with an http request on the internetcube web site
|
||||
if [ $? -ne 0 ]; then
|
||||
http_date=`curl -sD - labriqueinter.net | grep '^Date:' | cut -d' ' -f3-6`
|
||||
http_date_seconds=`date -d "${http_date}" +%s`
|
||||
curr_date_seconds=`date +%s`
|
||||
|
||||
# Set the new date if it's greater than the current date
|
||||
# So it does if 1970 year or if old fake-hwclock date is used
|
||||
if [ $http_date_seconds -ge $curr_date_seconds ]; then
|
||||
date -s "${http_date}"
|
||||
fi
|
||||
fi
|
||||
systemctl start ntp
|
||||
}
|
||||
|
||||
|
||||
@@ -41,3 +41,76 @@ function ynh_systemctl()
|
||||
mv $LOCKFILE.bkp.$$ $LOCKFILE
|
||||
}
|
||||
|
||||
# Read the value of a key in a ynh manifest file
|
||||
#
|
||||
# usage: ynh_read_manifest manifest key
|
||||
# | arg: manifest - Path of the manifest to read
|
||||
# | arg: key - Name of the key to find
|
||||
ynh_read_manifest () {
|
||||
manifest="$1"
|
||||
key="$2"
|
||||
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])"
|
||||
}
|
||||
|
||||
# Read the upstream version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number before ~ynh
|
||||
# In the last example it return 4.3-2
|
||||
#
|
||||
# usage: ynh_app_upstream_version
|
||||
ynh_app_upstream_version () {
|
||||
manifest_path="../manifest.json"
|
||||
if [ ! -e "$manifest_path" ]; then
|
||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||
echo "${version_key/~ynh*/}"
|
||||
}
|
||||
|
||||
# Read package version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number after ~ynh
|
||||
# In the last example it return 3
|
||||
#
|
||||
# usage: ynh_app_package_version
|
||||
ynh_app_package_version () {
|
||||
manifest_path="../manifest.json"
|
||||
if [ ! -e "$manifest_path" ]; then
|
||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||
echo "${version_key/*~ynh/}"
|
||||
}
|
||||
|
||||
# Exit without error if the package is up to date
|
||||
#
|
||||
# This helper should be used to avoid an upgrade of a package
|
||||
# when it's not needed.
|
||||
#
|
||||
# To force an upgrade, even if the package is up to date,
|
||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||
#
|
||||
# usage: ynh_abort_if_up_to_date
|
||||
ynh_abort_if_up_to_date () {
|
||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||
|
||||
local version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
|
||||
local last_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0)
|
||||
if [ "$version" = "$last_version" ]
|
||||
then
|
||||
if [ "$force_upgrade" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||
unset YNH_FORCE_UPGRADE
|
||||
elif [ "$package_check" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced for package check." >&2
|
||||
else
|
||||
ynh_die "Up-to-date, nothing to do" 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user