mkswapfile 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 72de3e3922fa29e712137c39e66a6bcf24678d3fe96eb9cd3a4c997749d2ef61
4
+ data.tar.gz: 725585273a17a5fd84597f7954040dd74b8510ffb1910626396ba0aa0d67b224
5
+ SHA512:
6
+ metadata.gz: 767f1582fbd287744ea50e6425491d366876d780af68771ba380880715a15fac1b0bf00928d89c5a92f3429ba2464e17c5b9634ada4618504f4a0f699720bf5d
7
+ data.tar.gz: 174fb0ba62e735a0a7d99466a9227cf3f64d0ee165ed9a2574dc4525b5092c8ef9a72e9c54e9bec63e494cd681a934ee8fef91b5ff1f9ffc121a62b7f96663c4
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in mkswapfile.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 s3fxn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # mkswapfile
2
+
3
+ mkswapfile - make and enable a swap file easily.
4
+
5
+ **This gem support only Linux.**
6
+
7
+ ## Installation
8
+
9
+ $ gem install mkswapfile
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ $ sudo mkswapfile size
15
+ size: 1-8 (GB)
16
+
17
+
18
+ EXAMPLE
19
+
20
+ $ sudo mkswapfile 2
21
+ dd if=/dev/zero of=/swap bs=1M count=2049 && chmod 600 /swap && mkswap /swap && \
22
+ (echo '/swap swap swap defaults 0 0' | tee -a /etc/fstab) && swapon /swap
23
+ ....
24
+
25
+ $ free -m
26
+ total used free shared buff/cache available
27
+ Mem: 481 90 11 0 379 378
28
+ Swap: 2048 0 2048
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/s3fxn/mkswapfile.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mkswapfile"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/mkswapfile ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ size = ARGV[0].to_i
4
+ if ARGV == [] or size < 1 or size > 8
5
+ puts
6
+ puts 'mkswapfile - make and enable a swap file easily.'
7
+ puts
8
+ puts 'Usage: sudo mkswapfile size'
9
+ puts 'size: 1-8 (GB)'
10
+ puts
11
+ puts
12
+ puts '$ sudo mkswapfile 2'
13
+ puts 'dd if=/dev/zero of=/swap bs=1M count=2049 && chmod 600 /swap && mkswap /swap && \ '
14
+ puts '(echo \'/swap swap swap defaults 0 0\' | tee -a /etc/fstab) && swapon /swap'
15
+ puts '....'
16
+ puts
17
+ puts '$ free -m'
18
+ puts ' total used free shared buff/cache available'
19
+ puts 'Mem: 481 90 11 0 379 378'
20
+ puts 'Swap: 2048 0 2048'
21
+ puts
22
+ exit 1
23
+ end
24
+
25
+ if Process.uid != 0
26
+ puts 'mkswapfile requires privilege.'
27
+ exit 1
28
+ end
29
+
30
+ uname = `uname -a` rescue ''
31
+ unless uname.include?('Linux')
32
+ puts 'mkswapfile support only Linux.'
33
+ exit 1
34
+ end
35
+
36
+ if FileTest.exist?('/swap')
37
+ puts '/swap already exists.'
38
+ exit 1
39
+ end
40
+
41
+ count = 1024 * size + 1
42
+ cmd = "dd if=/dev/zero of=/swap bs=1M count=#{count} && chmod 600 /swap && mkswap /swap && \\\n" +
43
+ "(echo '/swap swap swap defaults 0 0' | tee -a /etc/fstab) && swapon /swap"
44
+
45
+ puts cmd
46
+ puts `#{cmd}`
47
+
@@ -0,0 +1,3 @@
1
+ module Mkswapfile
2
+ VERSION = "0.1.0"
3
+ end
data/lib/mkswapfile.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "mkswapfile/version"
2
+
3
+ module Mkswapfile
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,25 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "mkswapfile/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mkswapfile"
8
+ spec.version = Mkswapfile::VERSION
9
+ spec.authors = ["s3fxn"]
10
+ spec.email = ["sssfxn@gmail.com"]
11
+
12
+ spec.summary = %q{mkswapfile - make and enable a swap file easily.}
13
+ spec.homepage = "https://github.com/s3fxn/mkswapfile"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.16"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mkswapfile
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - s3fxn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - sssfxn@gmail.com
44
+ executables:
45
+ - mkswapfile
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - exe/mkswapfile
57
+ - lib/mkswapfile.rb
58
+ - lib/mkswapfile/version.rb
59
+ - mkswapfile.gemspec
60
+ homepage: https://github.com/s3fxn/mkswapfile
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.7.6
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: mkswapfile - make and enable a swap file easily.
84
+ test_files: []